Skip to content

Commit

Permalink
Fix FORGE-1735 - List of Commands sometimes shows up empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Apr 4, 2014
1 parent 1dfdb8c commit a991162
Showing 1 changed file with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,25 @@
public enum FurnaceService {
INSTANCE;

private transient Furnace forge;
private ConverterFactory converterFactory;
private transient Furnace furnace;

private FurnaceService() {
}

public void setFurnace(Furnace forge) {
this.forge = forge;
this.furnace = forge;
}

public void start(final ClassLoader loader) {
forge.startAsync(loader);
furnace.startAsync(loader);
}

public AddonRegistry getAddonRegistry() {
return forge.getAddonRegistry();
return furnace.getAddonRegistry();
}

public void stop() {
forge.stop();
furnace.stop();
}

public void waitUntilContainerIsStarted() throws InterruptedException {
Expand All @@ -53,41 +52,40 @@ public void waitUntilContainerIsStarted() throws InterruptedException {
}

public ContainerStatus getContainerStatus() {
return (forge == null) ? ContainerStatus.STOPPED : forge.getStatus();
return (furnace == null) ? ContainerStatus.STOPPED : furnace
.getStatus();
}

public ConverterFactory getConverterFactory() {
if (converterFactory == null) {
converterFactory = lookup(ConverterFactory.class);
while (converterFactory == null) {
try {
Thread.sleep(100);
converterFactory = lookup(ConverterFactory.class);
} catch (InterruptedException e) {
break;
}
ConverterFactory converterFactory = lookup(ConverterFactory.class);
while (converterFactory == null) {
try {
Thread.sleep(100);
converterFactory = lookup(ConverterFactory.class);
} catch (InterruptedException e) {
break;
}
}
return converterFactory;
}

public <S> Imported<S> lookupImported(Class<S> service) {
Imported<S> instance = null;
if (forge != null) {
instance = forge.getAddonRegistry().getServices(service);
if (furnace != null) {
instance = furnace.getAddonRegistry().getServices(service);
}
return instance;
}

public <S> S lookup(Class<S> service) {
Imported<S> instance = null;
if (forge != null) {
instance = forge.getAddonRegistry().getServices(service);
if (furnace != null) {
instance = furnace.getAddonRegistry().getServices(service);
}
return (instance == null) ? null : instance.get();
}

public LockManager getLockManager() {
return forge.getLockManager();
return furnace.getLockManager();
}
}

0 comments on commit a991162

Please sign in to comment.