Skip to content

Commit

Permalink
coding style fixes for new project run code
Browse files Browse the repository at this point in the history
also remove a little left over cruft.

refs #354
  • Loading branch information
ervandew committed Nov 23, 2014
1 parent bd861ce commit c5a0661
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 110 deletions.
Expand Up @@ -31,44 +31,14 @@
*/
public class EclimLaunchManager implements Runnable
{

public interface OutputHandler
{
/**
* NB: If your OutputHandler's prepare might take
* a non-trivial amount of time, you MUST
* queue up any outputs that come along before
* you started. Future work could abstract that
* out as necessary
*/
public void prepare(final String launchId)
throws Exception;
public void sendErr(String line);
public void sendOut(String line);
public void sendTerminated();
}

static class LaunchSet
{
final String id;
final ILaunch launch;
final OutputHandler output;

LaunchSet(String id, ILaunch launch, OutputHandler output)
{
this.id = id;
this.launch = launch;
this.output = output;
}
}

static HashMap<String, LaunchSet> sLaunches = new HashMap<String, LaunchSet>();
static Thread thread;
private static HashMap<String, LaunchSet> sLaunches =
new HashMap<String, LaunchSet>();
private static Thread thread;

@Override
public void run()
{
for (;;) {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Expand All @@ -81,7 +51,7 @@ public void run()
}
}

static synchronized void cleanLaunches()
private static synchronized void cleanLaunches()
{
Iterator<LaunchSet> iter = sLaunches.values().iterator();
while (iter.hasNext()) {
Expand Down Expand Up @@ -114,7 +84,7 @@ public static synchronized boolean terminate(final String launchId)
return true;
}

static void terminate(final LaunchSet set)
private static void terminate(final LaunchSet set)
throws DebugException
{
if (set.launch.isTerminated()) {
Expand Down Expand Up @@ -146,7 +116,8 @@ public static synchronized void terminateAll()
* to perform it. The original exception can be retreived
* from #getCause()
*/
public static synchronized void manage(final ILaunch launch,
public static synchronized void manage(
final ILaunch launch,
final OutputHandler output)
throws IllegalArgumentException
{
Expand Down Expand Up @@ -182,8 +153,12 @@ public void streamAppended(String text, IStreamMonitor monitor)
// dump buffered content, if any
final String pendingOut = stdout.getContents();
final String pendingErr = stderr.getContents();
if (pendingOut.length() > 0) output.sendOut(pendingOut);
if (pendingErr.length() > 0) output.sendErr(pendingErr);
if (pendingOut.length() > 0){
output.sendOut(pendingOut);
}
if (pendingErr.length() > 0){
output.sendErr(pendingErr);
}

// attach listeners
stdout.addListener(outListener);
Expand All @@ -205,11 +180,10 @@ public void streamAppended(String text, IStreamMonitor monitor)

// re-raise
throw new IllegalArgumentException(
"OutputHandler does not support async output",
e);
"OutputHandler does not support async output", e);
}

sLaunches.put(id, new LaunchSet(id, launch, output));
sLaunches.put(id, new LaunchSet(launch, output));

if (thread == null) {
thread = new Thread(new EclimLaunchManager());
Expand All @@ -218,7 +192,7 @@ public void streamAppended(String text, IStreamMonitor monitor)
}
}

static synchronized String allocateId(ILaunch launch)
private static synchronized String allocateId(ILaunch launch)
{
final String name = launch.getLaunchConfiguration().getName();
if (!sLaunches.containsKey(name)) {
Expand All @@ -237,8 +211,36 @@ static synchronized String allocateId(ILaunch launch)
return id;
}

static synchronized void remove(String id)
private static synchronized void remove(String id)
{
sLaunches.remove(id);
}

public interface OutputHandler
{
/**
* NB: If your OutputHandler's prepare might take
* a non-trivial amount of time, you MUST
* queue up any outputs that come along before
* you started. Future work could abstract that
* out as necessary
*/
public void prepare(final String launchId)
throws Exception;
public void sendErr(String line);
public void sendOut(String line);
public void sendTerminated();
}

private static class LaunchSet
{
final ILaunch launch;
final OutputHandler output;

LaunchSet(ILaunch launch, OutputHandler output)
{
this.launch = launch;
this.output = output;
}
}
}

0 comments on commit c5a0661

Please sign in to comment.