diff --git a/src/main/java/teetime/framework/Execution.java b/src/main/java/teetime/framework/Execution.java index ac6791eea37b03dfdad671bc5e00ececf1d672ee..7a6710b83efe758fa00d4247f3cde83daac4a19a 100644 --- a/src/main/java/teetime/framework/Execution.java +++ b/src/main/java/teetime/framework/Execution.java @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; import teetime.framework.exceptionHandling.AbstractExceptionListener; import teetime.framework.exceptionHandling.IExceptionListenerFactory; -import teetime.framework.exceptionHandling.IgnoringExceptionListenerFactory; +import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory; import teetime.framework.signal.InitializingSignal; import teetime.framework.signal.ValidatingSignal; import teetime.framework.validation.AnalysisNotValidException; @@ -73,11 +73,11 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti * to be used for the analysis */ public Execution(final T configuration) { - this(configuration, false, new IgnoringExceptionListenerFactory()); + this(configuration, false, new TerminatingExceptionListenerFactory()); } public Execution(final T configuration, final boolean validationEnabled) { - this(configuration, validationEnabled, new IgnoringExceptionListenerFactory()); + this(configuration, validationEnabled, new TerminatingExceptionListenerFactory()); } /** diff --git a/src/main/java/teetime/framework/RunnableConsumerStage.java b/src/main/java/teetime/framework/RunnableConsumerStage.java index c1a78e20917d21a7052dd47f66fd3ed18e3f023b..506ec8644e789639294feb842ff4570d009e4658 100644 --- a/src/main/java/teetime/framework/RunnableConsumerStage.java +++ b/src/main/java/teetime/framework/RunnableConsumerStage.java @@ -15,8 +15,6 @@ */ package teetime.framework; -import teetime.framework.idle.IdleStrategy; -import teetime.framework.idle.YieldStrategy; import teetime.framework.signal.ISignal; import teetime.framework.signal.TerminatingSignal; @@ -26,16 +24,12 @@ final class RunnableConsumerStage extends AbstractRunnableStage { private final InputPort<?>[] inputPorts; /** - * Creates a new instance with the {@link YieldStrategy} as default idle strategy. + * Creates a new instance. * * @param stage * to execute within an own thread */ public RunnableConsumerStage(final Stage stage) { - this(stage, new YieldStrategy()); - } - - public RunnableConsumerStage(final Stage stage, final IdleStrategy idleStrategy) { super(stage); this.inputPorts = stage.getInputPorts(); // FIXME should getInputPorts() really be defined in Stage? } diff --git a/src/main/java/teetime/framework/idle/IdleStrategy.java b/src/main/java/teetime/framework/idle/IdleStrategy.java deleted file mode 100644 index 454a128739564e097cfcfd4acd329cc6a81146f1..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/idle/IdleStrategy.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.idle; - -/** - * - * @author Christian Wulf - * - * @deprecated since 1.1 - */ -@Deprecated -public interface IdleStrategy { - - void execute() throws InterruptedException; -} diff --git a/src/main/java/teetime/framework/idle/SleepStrategy.java b/src/main/java/teetime/framework/idle/SleepStrategy.java deleted file mode 100644 index aa88c78b8fe59eaaf80fcf41898ec052f4cdb05b..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/idle/SleepStrategy.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.idle; - -public final class SleepStrategy implements IdleStrategy { - - private final long timeoutInMs; - - public SleepStrategy(final long timeoutInMs) { - super(); - this.timeoutInMs = timeoutInMs; - } - - @Override - public void execute() throws InterruptedException { - Thread.sleep(timeoutInMs); - } - -} diff --git a/src/main/java/teetime/framework/idle/YieldStrategy.java b/src/main/java/teetime/framework/idle/YieldStrategy.java deleted file mode 100644 index 52bddcbd1511cef773286129d798c54809f66f0f..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/idle/YieldStrategy.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package teetime.framework.idle; - -/** - * @deprecated since 1.1 - */ -@Deprecated -public final class YieldStrategy implements IdleStrategy { - - @Override - public void execute() throws InterruptedException { - Thread.yield(); - } - -} diff --git a/src/main/java/teetime/stage/basic/AbstractTransformation.java b/src/main/java/teetime/stage/basic/AbstractTransformation.java index 39cc348154866c1e7467c3dff9bd4d1bec804f53..1e65a45a81f69ff60c6b87b271b82a1cb5e9906c 100644 --- a/src/main/java/teetime/stage/basic/AbstractTransformation.java +++ b/src/main/java/teetime/stage/basic/AbstractTransformation.java @@ -18,7 +18,7 @@ package teetime.stage.basic; import teetime.framework.AbstractConsumerStage; import teetime.framework.OutputPort; -public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage<I> { +public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage<I> implements ITransformation<I, O> { private final OutputPort<O> outputPort = createOutputPort(); @@ -26,7 +26,8 @@ public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage super(); } - public OutputPort<O> getOutputPort() { + @Override + public final OutputPort<O> getOutputPort() { return outputPort; } } diff --git a/src/main/java/teetime/stage/basic/ITransformation.java b/src/main/java/teetime/stage/basic/ITransformation.java new file mode 100644 index 0000000000000000000000000000000000000000..7efae2a0363cfed129b6f99b83e7c7e5abe1524f --- /dev/null +++ b/src/main/java/teetime/stage/basic/ITransformation.java @@ -0,0 +1,12 @@ +package teetime.stage.basic; + +import teetime.framework.InputPort; +import teetime.framework.OutputPort; + +public interface ITransformation<I, O> { + + public abstract InputPort<I> getInputPort(); + + public abstract OutputPort<O> getOutputPort(); + +} diff --git a/src/main/java/teetime/stage/string/WordCounter.java b/src/main/java/teetime/stage/string/WordCounter.java index 08e10ed9de237288fd615d62676d7e7b01d01e60..1508c15edbf052f26a265df4253c750ef2917944 100644 --- a/src/main/java/teetime/stage/string/WordCounter.java +++ b/src/main/java/teetime/stage/string/WordCounter.java @@ -15,13 +15,10 @@ */ package teetime.stage.string; -import java.util.ArrayList; - import teetime.framework.AbstractCompositeStage; import teetime.framework.ConfigurationContext; import teetime.framework.InputPort; import teetime.framework.OutputPort; -import teetime.framework.Stage; import teetime.stage.MappingCounter; import teetime.stage.util.CountingMap; @@ -36,24 +33,18 @@ import teetime.stage.util.CountingMap; */ public final class WordCounter extends AbstractCompositeStage { - // This fields are needed for the methods to work. - private final Tokenizer tokenizer = new Tokenizer(" "); - private final MappingCounter<String> mapCounter = new MappingCounter<String>(); - private final ArrayList<Stage> lastStages = new ArrayList<Stage>(); + private final Tokenizer tokenizer; + private final MappingCounter<String> mapCounter; - // The connection of the different stages is realized within the construction of a instance of this class. public WordCounter(final ConfigurationContext context) { super(context); - this.lastStages.add(this.mapCounter); + + this.tokenizer = new Tokenizer(" "); final ToLowerCase toLowerCase = new ToLowerCase(); + this.mapCounter = new MappingCounter<String>(); connectPorts(this.tokenizer.getOutputPort(), toLowerCase.getInputPort()); connectPorts(toLowerCase.getOutputPort(), this.mapCounter.getInputPort()); - // connectStages(wordcharacterFilter.getOutputPort(), this.mapCounter.getInputPort()); - } - - public Stage getFirstStage() { - return this.tokenizer; } public InputPort<String> getInputPort() { diff --git a/src/site/markdown/wiki b/src/site/markdown/wiki deleted file mode 160000 index 0a5bd4ddb82684ce1ae2ec84c67ff2117ebff143..0000000000000000000000000000000000000000 --- a/src/site/markdown/wiki +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a5bd4ddb82684ce1ae2ec84c67ff2117ebff143 diff --git a/src/test/java/teetime/framework/TraversorTest.java b/src/test/java/teetime/framework/TraversorTest.java index 0b312dcdadb5ad77776754d5d4d8f370075123dd..dcbb167a883ad83e30543a798066963cdef098d3 100644 --- a/src/test/java/teetime/framework/TraversorTest.java +++ b/src/test/java/teetime/framework/TraversorTest.java @@ -83,8 +83,7 @@ public class TraversorTest { connectPorts(distributor.getNewOutputPort(), wc.getInputPort()); connectPorts(wc.getOutputPort(), merger.getNewInputPort()); // Add WordCounter as a threadable stage, so it runs in its own thread - addThreadableStage(wc.getFirstStage()); - + addThreadableStage(wc.getInputPort().getOwningStage()); } // Connect the stages of the last part