diff --git a/src/main/java/teetime/framework/AbstractCompositeStage.java b/src/main/java/teetime/framework/AbstractCompositeStage.java index 07aa5c982b47eee8eafaa7d1b782409f57ab5309..060f0e773d0124af0379c72efbb7c005ef437b99 100644 --- a/src/main/java/teetime/framework/AbstractCompositeStage.java +++ b/src/main/java/teetime/framework/AbstractCompositeStage.java @@ -36,7 +36,7 @@ public abstract class AbstractCompositeStage { this.context = new ConfigurationContext(); } - protected ConfigurationContext getContext() { + ConfigurationContext getContext() { return context; } diff --git a/src/main/java/teetime/framework/ConfigurationContext.java b/src/main/java/teetime/framework/ConfigurationContext.java index 555e0e30a7098946b0c4e9fe6070e613f81c5caa..87bb41bf49b0cf5d0e12c1391673ac44dff551e7 100644 --- a/src/main/java/teetime/framework/ConfigurationContext.java +++ b/src/main/java/teetime/framework/ConfigurationContext.java @@ -29,7 +29,9 @@ import teetime.framework.pipe.InstantiationPipe; * * @since 2.0 */ -public class ConfigurationContext { +final class ConfigurationContext { + + public static final ConfigurationContext EMPTY_CONTEXT = new ConfigurationContext(); private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationContext.class); @@ -70,7 +72,7 @@ public class ConfigurationContext { } final void mergeContexts(final Stage stage) { - if (!stage.owningContext.equals(EmptyContext.getInstance())) { + if (!stage.owningContext.equals(EMPTY_CONTEXT)) { if (stage.owningContext != this) { // Performance this.threadableStages.putAll(stage.owningContext.threadableStages); stage.owningContext.threadableStages = this.threadableStages; diff --git a/src/main/java/teetime/framework/EmptyContext.java b/src/main/java/teetime/framework/EmptyContext.java deleted file mode 100644 index 3a676ebc9bdc556ad474775955b4955ed9233d48..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/EmptyContext.java +++ /dev/null @@ -1,15 +0,0 @@ -package teetime.framework; - -class EmptyContext extends ConfigurationContext { - - private static final EmptyContext INSTANCE = new EmptyContext(); - - private EmptyContext() { - - } - - static EmptyContext getInstance() { - return EmptyContext.INSTANCE; - } - -} diff --git a/src/main/java/teetime/framework/Stage.java b/src/main/java/teetime/framework/Stage.java index 4625f610869d10e0240778e26ddba87c39ec5151..08a0e47bc833f479d846a58d1f8f999664015c76 100644 --- a/src/main/java/teetime/framework/Stage.java +++ b/src/main/java/teetime/framework/Stage.java @@ -48,7 +48,7 @@ public abstract class Stage { /** The owning thread of this stage if this stage is directly executed by a {@link AbstractRunnableStage}, <code>null</code> otherwise. */ protected Thread owningThread; - public ConfigurationContext owningContext = EmptyContext.getInstance(); + public ConfigurationContext owningContext = ConfigurationContext.EMPTY_CONTEXT; protected Stage() { this.id = this.createId(); diff --git a/src/main/java/teetime/stage/io/EveryXthPrinter.java b/src/main/java/teetime/stage/io/EveryXthPrinter.java index 4b62916d1f65cae5b08540e4ea7d5fff8bce7826..c03f564679d2112ba9dceae96a8b58f8c7a4b6fb 100644 --- a/src/main/java/teetime/stage/io/EveryXthPrinter.java +++ b/src/main/java/teetime/stage/io/EveryXthPrinter.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.List; import teetime.framework.AbstractCompositeStage; -import teetime.framework.ConfigurationContext; import teetime.framework.InputPort; import teetime.framework.OutputPort; import teetime.framework.Stage; @@ -32,7 +31,7 @@ public final class EveryXthPrinter<T> extends AbstractCompositeStage { private final Distributor<T> distributor; private final List<Stage> lastStages = new ArrayList<Stage>(); - public EveryXthPrinter(final int threshold, final ConfigurationContext context) { + public EveryXthPrinter(final int threshold) { distributor = new Distributor<T>(new CopyByReferenceStrategy()); EveryXthStage<T> everyXthStage = new EveryXthStage<T>(threshold); Printer<Integer> printer = new Printer<Integer>(); diff --git a/src/main/java/teetime/stage/string/WordCounter.java b/src/main/java/teetime/stage/string/WordCounter.java index 6d15a3f20f5833463f1cd3ee37bea1173edc06e7..46d22380f947bc1023eb2594f404928d2f79a347 100644 --- a/src/main/java/teetime/stage/string/WordCounter.java +++ b/src/main/java/teetime/stage/string/WordCounter.java @@ -16,7 +16,6 @@ package teetime.stage.string; import teetime.framework.AbstractCompositeStage; -import teetime.framework.ConfigurationContext; import teetime.framework.InputPort; import teetime.framework.OutputPort; import teetime.stage.MappingCounter; @@ -36,7 +35,7 @@ public final class WordCounter extends AbstractCompositeStage { private final Tokenizer tokenizer; private final MappingCounter<String> mapCounter; - public WordCounter(final ConfigurationContext context) { + public WordCounter() { this.tokenizer = new Tokenizer(" "); final ToLowerCase toLowerCase = new ToLowerCase(); diff --git a/src/test/java/teetime/framework/TraversorTest.java b/src/test/java/teetime/framework/TraversorTest.java index 95e118b1695bafeda2d14f3829c383e10bcfcff2..ec0829cecaff06ad0627c66ef225bfb9a491c4eb 100644 --- a/src/test/java/teetime/framework/TraversorTest.java +++ b/src/test/java/teetime/framework/TraversorTest.java @@ -77,7 +77,7 @@ public class TraversorTest { // Middle part... multiple instances of WordCounter are created and connected to the merger and distrubuter stages for (int i = 0; i < threads; i++) { // final InputPortSizePrinter<String> inputPortSizePrinter = new InputPortSizePrinter<String>(); - final WordCounter wc = new WordCounter(this.getContext()); + final WordCounter wc = new WordCounter(); // intraFact.create(inputPortSizePrinter.getOutputPort(), wc.getInputPort()); connectPorts(distributor.getNewOutputPort(), wc.getInputPort());