diff --git a/src/main/java/teetime/framework/AbstractPort.java b/src/main/java/teetime/framework/AbstractPort.java index f6664b54da56cd08a45f2acf6ddfef021baed278..639f4bd033357f87d50a182dad37d72413324564 100644 --- a/src/main/java/teetime/framework/AbstractPort.java +++ b/src/main/java/teetime/framework/AbstractPort.java @@ -31,11 +31,11 @@ public abstract class AbstractPort<T> { protected IPipe pipe; - public AbstractPort(final Class<T> type, final Stage owningStage, final String name) { + protected AbstractPort(final Class<T> type, final Stage owningStage, final String name) { super(); this.type = type; this.owningStage = owningStage; - this.name = (name != null) ? name : super.toString(); + this.name = name; } public Class<T> getType() { @@ -56,6 +56,6 @@ public abstract class AbstractPort<T> { @Override public String toString() { - return name; + return (name != null) ? name : super.toString(); } } diff --git a/src/main/java/teetime/stage/basic/distributor/Distributor.java b/src/main/java/teetime/stage/basic/distributor/Distributor.java index f780e247c0d54e4638ad69b0ccf80b155fb18301..db0ef4393c0dad4eb58b96355721680b11c9ffd5 100644 --- a/src/main/java/teetime/stage/basic/distributor/Distributor.java +++ b/src/main/java/teetime/stage/basic/distributor/Distributor.java @@ -17,6 +17,8 @@ package teetime.stage.basic.distributor; import teetime.framework.AbstractConsumerStage; import teetime.framework.OutputPort; +import teetime.stage.basic.distributor.strategy.IDistributorStrategy; +import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2; /** * @author Christian Wulf diff --git a/src/main/java/teetime/stage/basic/distributor/dynamic/DynamicDistributor.java b/src/main/java/teetime/stage/basic/distributor/dynamic/DynamicDistributor.java index b068f4df2384342114e8061b8099c5dec792290e..aecb9d1526ba290a36cf4cd0ac4b5b7a60f0df3c 100644 --- a/src/main/java/teetime/stage/basic/distributor/dynamic/DynamicDistributor.java +++ b/src/main/java/teetime/stage/basic/distributor/dynamic/DynamicDistributor.java @@ -8,8 +8,8 @@ import teetime.framework.OutputPortRemovedListener; import teetime.framework.Stage; import teetime.framework.signal.TerminatingSignal; import teetime.stage.basic.distributor.Distributor; -import teetime.stage.basic.distributor.IDistributorStrategy; -import teetime.stage.basic.distributor.RoundRobinStrategy2; +import teetime.stage.basic.distributor.strategy.IDistributorStrategy; +import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2; import teetime.util.framework.port.PortAction; import teetime.util.framework.port.PortActionHelper; diff --git a/src/main/java/teetime/stage/basic/distributor/CloneStrategy.java b/src/main/java/teetime/stage/basic/distributor/strategy/CloneStrategy.java similarity index 92% rename from src/main/java/teetime/stage/basic/distributor/CloneStrategy.java rename to src/main/java/teetime/stage/basic/distributor/strategy/CloneStrategy.java index c41d4177f0510ddfb39a762eeb38885f2a85ed76..7f2a2b00d9a6c6872bd56df0145466eed5584899 100644 --- a/src/main/java/teetime/stage/basic/distributor/CloneStrategy.java +++ b/src/main/java/teetime/stage/basic/distributor/strategy/CloneStrategy.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.distributor; +package teetime.stage.basic.distributor.strategy; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -57,13 +57,11 @@ public final class CloneStrategy implements IDistributorStrategy { return newInstance; } catch (InstantiationException e) { - throw new UnsupportedOperationException(); + throw new IllegalStateException(e); } catch (IllegalAccessException e) { - throw new UnsupportedOperationException(); - } catch (IllegalArgumentException e) { - throw new UnsupportedOperationException(); + throw new IllegalStateException(e); } catch (InvocationTargetException e) { - throw new UnsupportedOperationException(); + throw new IllegalStateException(e); } } diff --git a/src/main/java/teetime/stage/basic/distributor/CopyByReferenceStrategy.java b/src/main/java/teetime/stage/basic/distributor/strategy/CopyByReferenceStrategy.java similarity index 96% rename from src/main/java/teetime/stage/basic/distributor/CopyByReferenceStrategy.java rename to src/main/java/teetime/stage/basic/distributor/strategy/CopyByReferenceStrategy.java index 317a6eae0fbebe980227c64805e5d3f4e228f83e..cb9d35b5207d3e7df47395fb66653cae3fec6b48 100644 --- a/src/main/java/teetime/stage/basic/distributor/CopyByReferenceStrategy.java +++ b/src/main/java/teetime/stage/basic/distributor/strategy/CopyByReferenceStrategy.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.distributor; +package teetime.stage.basic.distributor.strategy; import teetime.framework.OutputPort; import teetime.framework.Stage; diff --git a/src/main/java/teetime/stage/basic/distributor/IDistributorStrategy.java b/src/main/java/teetime/stage/basic/distributor/strategy/IDistributorStrategy.java similarity index 95% rename from src/main/java/teetime/stage/basic/distributor/IDistributorStrategy.java rename to src/main/java/teetime/stage/basic/distributor/strategy/IDistributorStrategy.java index 4e42dc15d3910150c878dc25e451abc1a19f137e..00c76d2f0055ceab2e15acc3af90e63a42af747e 100644 --- a/src/main/java/teetime/stage/basic/distributor/IDistributorStrategy.java +++ b/src/main/java/teetime/stage/basic/distributor/strategy/IDistributorStrategy.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.distributor; +package teetime.stage.basic.distributor.strategy; import teetime.framework.OutputPort; import teetime.framework.OutputPortRemovedListener; diff --git a/src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy.java b/src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy.java similarity index 94% rename from src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy.java rename to src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy.java index 77dae9254342e38c34366652caba9cadb523c584..f2038512849f88377c43b2efa4e4e2e2223b9f99 100644 --- a/src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy.java +++ b/src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.distributor; +package teetime.stage.basic.distributor.strategy; import teetime.framework.OutputPort; import teetime.framework.Stage; +import teetime.stage.basic.distributor.Distributor; /** * @author Nils Christian Ehmke diff --git a/src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy2.java b/src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy2.java similarity index 95% rename from src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy2.java rename to src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy2.java index 54103cb2fe24386f7ae5b45bab760db8285a9587..371ffa774b35cdd3e3b4300a093da889fb6fd252 100644 --- a/src/main/java/teetime/stage/basic/distributor/RoundRobinStrategy2.java +++ b/src/main/java/teetime/stage/basic/distributor/strategy/RoundRobinStrategy2.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.distributor; +package teetime.stage.basic.distributor.strategy; import teetime.framework.OutputPort; import teetime.framework.Stage; +import teetime.stage.basic.distributor.Distributor; /** * @author Christian Wulf diff --git a/src/main/java/teetime/stage/basic/merger/Merger.java b/src/main/java/teetime/stage/basic/merger/Merger.java index 3e37f472727d447ad78990d2ddf96ab69af9df17..4ecec6a604fa7a29494d64255d554400fdfde6d0 100644 --- a/src/main/java/teetime/stage/basic/merger/Merger.java +++ b/src/main/java/teetime/stage/basic/merger/Merger.java @@ -25,6 +25,8 @@ import teetime.framework.DynamicInputPort; import teetime.framework.InputPort; import teetime.framework.OutputPort; import teetime.framework.signal.ISignal; +import teetime.stage.basic.merger.strategy.IMergerStrategy; +import teetime.stage.basic.merger.strategy.RoundRobinStrategy; /** * diff --git a/src/main/java/teetime/stage/basic/merger/dynamic/DynamicMerger.java b/src/main/java/teetime/stage/basic/merger/dynamic/DynamicMerger.java index 4e70a825c008feb7512c8e87ba3baa22cfb61cce..b31216038c3fc8ab260f709292169b1300f54821 100644 --- a/src/main/java/teetime/stage/basic/merger/dynamic/DynamicMerger.java +++ b/src/main/java/teetime/stage/basic/merger/dynamic/DynamicMerger.java @@ -3,8 +3,8 @@ package teetime.stage.basic.merger.dynamic; import java.util.concurrent.BlockingQueue; import teetime.framework.DynamicInputPort; -import teetime.stage.basic.merger.IMergerStrategy; import teetime.stage.basic.merger.Merger; +import teetime.stage.basic.merger.strategy.IMergerStrategy; import teetime.util.framework.port.PortAction; import teetime.util.framework.port.PortActionHelper; diff --git a/src/main/java/teetime/stage/basic/merger/BusyWaitingRoundRobinStrategy.java b/src/main/java/teetime/stage/basic/merger/strategy/BusyWaitingRoundRobinStrategy.java similarity index 95% rename from src/main/java/teetime/stage/basic/merger/BusyWaitingRoundRobinStrategy.java rename to src/main/java/teetime/stage/basic/merger/strategy/BusyWaitingRoundRobinStrategy.java index 0f7dcba71ad478a2933fdfebf42610b4e1bd090b..9e5df6cfc2f3d3d803ce151671adfdf74c91064b 100644 --- a/src/main/java/teetime/stage/basic/merger/BusyWaitingRoundRobinStrategy.java +++ b/src/main/java/teetime/stage/basic/merger/strategy/BusyWaitingRoundRobinStrategy.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.merger; +package teetime.stage.basic.merger.strategy; import teetime.framework.InputPort; import teetime.framework.Stage; +import teetime.stage.basic.merger.Merger; /** * @author Christian Wulf diff --git a/src/main/java/teetime/stage/basic/merger/IMergerStrategy.java b/src/main/java/teetime/stage/basic/merger/strategy/IMergerStrategy.java similarity index 91% rename from src/main/java/teetime/stage/basic/merger/IMergerStrategy.java rename to src/main/java/teetime/stage/basic/merger/strategy/IMergerStrategy.java index 4fa1b4dab399ff94cf3e5eb7e5536847b5beaa0e..2de8659ccb6e4576a5fa5557ecf7bccae5ecf43b 100644 --- a/src/main/java/teetime/stage/basic/merger/IMergerStrategy.java +++ b/src/main/java/teetime/stage/basic/merger/strategy/IMergerStrategy.java @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.merger; +package teetime.stage.basic.merger.strategy; import teetime.framework.InputPortRemovedListener; +import teetime.stage.basic.merger.Merger; /** * @author Nils Christian Ehmke diff --git a/src/main/java/teetime/stage/basic/merger/RoundRobinStrategy.java b/src/main/java/teetime/stage/basic/merger/strategy/RoundRobinStrategy.java similarity index 95% rename from src/main/java/teetime/stage/basic/merger/RoundRobinStrategy.java rename to src/main/java/teetime/stage/basic/merger/strategy/RoundRobinStrategy.java index d554e0acd6123dc4692c875c76f9cc52ee4e9638..cfe269dd12b1e0d444c559e4dcf1b81f8e33172a 100644 --- a/src/main/java/teetime/stage/basic/merger/RoundRobinStrategy.java +++ b/src/main/java/teetime/stage/basic/merger/strategy/RoundRobinStrategy.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.stage.basic.merger; +package teetime.stage.basic.merger.strategy; import teetime.framework.InputPort; import teetime.framework.Stage; +import teetime.stage.basic.merger.Merger; /** * @author Nils Christian Ehmke diff --git a/src/main/java/teetime/stage/io/EveryXthPrinter.java b/src/main/java/teetime/stage/io/EveryXthPrinter.java index 24eb08eca3008c315395eeea6bf9fa1735e86d64..6f38fbab37e218bcde981c63263513d8a993632e 100644 --- a/src/main/java/teetime/stage/io/EveryXthPrinter.java +++ b/src/main/java/teetime/stage/io/EveryXthPrinter.java @@ -24,8 +24,8 @@ import teetime.framework.InputPort; import teetime.framework.OutputPort; import teetime.framework.Stage; import teetime.stage.EveryXthStage; -import teetime.stage.basic.distributor.CopyByReferenceStrategy; import teetime.stage.basic.distributor.Distributor; +import teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy; public final class EveryXthPrinter<T> extends AbstractCompositeStage { diff --git a/src/test/java/teetime/framework/TraversorTest.java b/src/test/java/teetime/framework/TraversorTest.java index dcbb167a883ad83e30543a798066963cdef098d3..95e118b1695bafeda2d14f3829c383e10bcfcff2 100644 --- a/src/test/java/teetime/framework/TraversorTest.java +++ b/src/test/java/teetime/framework/TraversorTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import teetime.stage.CountingMapMerger; import teetime.stage.InitialElementProducer; import teetime.stage.basic.distributor.Distributor; -import teetime.stage.basic.distributor.RoundRobinStrategy2; +import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2; import teetime.stage.basic.merger.Merger; import teetime.stage.io.File2SeqOfWords; import teetime.stage.string.WordCounter; diff --git a/src/test/java/teetime/stage/basic/distributor/DistributorTest.java b/src/test/java/teetime/stage/basic/distributor/DistributorTest.java index 5e9381d86fd95f073025e49173c29b2c2e66aa30..3a8c235bb657af82532f6e5860e23d8198ceafe9 100644 --- a/src/test/java/teetime/stage/basic/distributor/DistributorTest.java +++ b/src/test/java/teetime/stage/basic/distributor/DistributorTest.java @@ -30,6 +30,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import teetime.stage.basic.distributor.strategy.CloneStrategy; +import teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy; +import teetime.stage.basic.distributor.strategy.RoundRobinStrategy; +import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2; + /** * @author Nils Christian Ehmke * @@ -136,19 +141,23 @@ public class DistributorTest { final List<SimpleBean> results = new ArrayList<SimpleBean>(); final SimpleBean originalBean = new SimpleBean(42); - test(distributor).and().send(originalBean).to(distributor.getInputPort()).and().receive(results).from(distributor.getNewOutputPort()).start(); + test(distributor).and() + .send(originalBean).to(distributor.getInputPort()).and() + .receive(results).from(distributor.getNewOutputPort()).start(); final SimpleBean clonedBean = results.get(0); assertThat(originalBean, is(not(clonedBean))); assertThat(originalBean.getValue(), is(clonedBean.getValue())); } - private static class SimpleBean { + // set to "public" to instantiate it via reflection + public static class SimpleBean { private int value; - @SuppressWarnings("unused") - public SimpleBean() {} + public SimpleBean() { + // necessary to instantiate it via reflection + } public SimpleBean(final int value) { this.setValue(value); diff --git a/src/test/java/teetime/stage/basic/merger/MergerTest.java b/src/test/java/teetime/stage/basic/merger/MergerTest.java index 6306cd1c3f0d5ca1b885a66cd380c0dd06b7b684..85d1375c72d70cc30093cbc1a782a56b8a806da8 100644 --- a/src/test/java/teetime/stage/basic/merger/MergerTest.java +++ b/src/test/java/teetime/stage/basic/merger/MergerTest.java @@ -25,6 +25,8 @@ import java.util.List; import org.junit.Test; +import teetime.stage.basic.merger.strategy.RoundRobinStrategy; + /** * @author Nils Christian Ehmke * diff --git a/src/test/java/teetime/stage/basic/merger/dynamic/DynamicMergerTest.java b/src/test/java/teetime/stage/basic/merger/dynamic/DynamicMergerTest.java index ee7dbf57f2f57ea530137f49ec3941f5be350a29..1af3b5636737380a9718117eec444fc07479fe0b 100644 --- a/src/test/java/teetime/stage/basic/merger/dynamic/DynamicMergerTest.java +++ b/src/test/java/teetime/stage/basic/merger/dynamic/DynamicMergerTest.java @@ -16,7 +16,7 @@ import teetime.framework.RunnableProducerStage; import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory; import teetime.stage.CollectorSink; import teetime.stage.InitialElementProducer; -import teetime.stage.basic.merger.BusyWaitingRoundRobinStrategy; +import teetime.stage.basic.merger.strategy.BusyWaitingRoundRobinStrategy; import teetime.util.framework.port.PortAction; public class DynamicMergerTest {