diff --git a/.settings/edu.umd.cs.findbugs.core.prefs b/.settings/edu.umd.cs.findbugs.core.prefs index 6f70f90ffe86235b99fc8a50c7e587cab982b90e..46ef676a8d028bb10ec315cd730646983be68151 100644 --- a/.settings/edu.umd.cs.findbugs.core.prefs +++ b/.settings/edu.umd.cs.findbugs.core.prefs @@ -1,5 +1,5 @@ #FindBugs User Preferences -#Fri Oct 17 09:51:45 CEST 2014 +#Fri Oct 17 09:58:28 CEST 2014 detector_threshold=3 effort=max excludefilter0=.fbExcludeFilterFile|true diff --git a/pom.xml b/pom.xml index c1729b872580e2cac05620ecb5bdead9757470e5..b12eb967b1ac42e12b45f4974f9d30ecff7e5852 100644 --- a/pom.xml +++ b/pom.xml @@ -7,14 +7,52 @@ <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> - <name>teetime</name> - <url>http://maven.apache.org</url> + <name>TeeTime</name> + <description>TeeTime is a Pipes-and-Filters framework for Java</description> + <url>http://teetime.sourceforge.org</url> + + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + </license> + </licenses> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.6</java.version> </properties> + <distributionManagement> + <snapshotRepository> + <id>ossrh</id> + <url>https://oss.sonatype.org/content/repositories/snapshots</url> + </snapshotRepository> + <repository> + <id>ossrh</id> + <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> + </repository> + </distributionManagement> + + <developers> + <developer> + <id>chw</id> + <name>Christian Wulf</name> + <email>chw@informatik.uni-kiel.de</email> + </developer> + <developer> + <id>ntd</id> + <name>Nelson Tavares de Sousa</name> + <email>ntd@informatik.uni-kiel.de</email> + </developer> + </developers> + + <scm> + <connection>scm:git:https://build.se.informatik.uni-kiel.de/gitlab/chw/teetime.git</connection> + <developerConnection>scm:git:ssh://gitlab@build.se.informatik.uni-kiel.de:chw/teetime.git</developerConnection> + <url>http://teetime.sourceforge.net</url> + </scm> + <repositories> <repository> <!-- kieker:1.10-SNAPSHOT --> @@ -102,7 +140,60 @@ <version>2.5</version> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.2.1</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.9.1</version> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-gpg-plugin</artifactId> + <version>1.5</version> + <executions> + <execution> + <id>sign-artifacts</id> + <phase>verify</phase> + <goals> + <goal>sign</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>nexus-staging-maven-plugin</artifactId> + <version>1.6.3</version> + <extensions>true</extensions> + <configuration> + <serverId>ossrh</serverId> + <nexusUrl>https://oss.sonatype.org/</nexusUrl> + <autoReleaseAfterClose>true</autoReleaseAfterClose> + </configuration> + </plugin> <!-- <plugin> --> <!-- <groupId>org.apache.maven.plugins</groupId> --> diff --git a/run-configurations/ComparisonMethodcallWithPorts.launch b/run-configurations/ComparisonMethodcallWithPorts.launch index 2be0908c088fbcdcc87b190a4d547de431bbb181..c5391996699e84d0ac1ab95bb6495293d3efdb62 100644 --- a/run-configurations/ComparisonMethodcallWithPorts.launch +++ b/run-configurations/ComparisonMethodcallWithPorts.launch @@ -14,4 +14,5 @@ <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="teetime.examples.ComparisonMethodcallWithPorts"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="teetime"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/> </launchConfiguration> diff --git a/src/main/java/teetime/framework/pipe/IPipeFactory.java b/src/main/java/teetime/framework/pipe/IPipeFactory.java index 8ff43cae918cbad003e0282a9af5e794cdf41c06..a37955e86dacd9e3dc61df0f902628d393306a67 100644 --- a/src/main/java/teetime/framework/pipe/IPipeFactory.java +++ b/src/main/java/teetime/framework/pipe/IPipeFactory.java @@ -5,26 +5,48 @@ import teetime.framework.OutputPort; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; +/** + * Represents the interface, which is must be defined in every PipeFactory + */ public interface IPipeFactory { - @Deprecated - IPipe create(int capacity); - /** - * with the default capacity + * Connects two stages with a pipe of default capacity. * * @param sourcePort + * OutputPort of the stage, which produces data. * @param targetPort - * @return + * Input port of the receiving stage. + * @return The connecting pipe. */ <T> IPipe create(OutputPort<? extends T> sourcePort, InputPort<T> targetPort); + /** + * Connects two stages with a pipe. + * + * @param sourcePort + * OutputPort of the stage, which produces data. + * @param targetPort + * Input port of the receiving stage. + * @param capacity + * Number of elements the pipe can carry. + * @return The connecting pipe. + */ <T> IPipe create(OutputPort<? extends T> sourcePort, InputPort<T> targetPort, int capacity); + /** + * @return Type of ThreadCommunication, which is used by the created pipes. + */ ThreadCommunication getThreadCommunication(); + /** + * @return Ordering type, which is used by the created pipes. + */ PipeOrdering getOrdering(); + /** + * @return Wether or not the created pipes are growable + */ boolean isGrowable(); } diff --git a/src/main/java/teetime/framework/pipe/OrderedGrowableArrayPipeFactory.java b/src/main/java/teetime/framework/pipe/OrderedGrowableArrayPipeFactory.java index 9142b80e11d7cbcfe4cd057f857840bf167ae9ab..ce5c89d844ed5b1458cd9317803e125db6991aff 100644 --- a/src/main/java/teetime/framework/pipe/OrderedGrowableArrayPipeFactory.java +++ b/src/main/java/teetime/framework/pipe/OrderedGrowableArrayPipeFactory.java @@ -7,11 +7,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; public class OrderedGrowableArrayPipeFactory implements IPipeFactory { - @Override - public IPipe create(final int capacity) { - return create(null, null, capacity); - } - @Override public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) { return create(sourcePort, targetPort, 4); diff --git a/src/main/java/teetime/framework/pipe/PipeFactoryRegistry.java b/src/main/java/teetime/framework/pipe/PipeFactoryRegistry.java index 2817b034be35f965bdc93254ae719d92b60f7dfc..44c209205e7a49b025ca61bb7a484dcc073c13a6 100644 --- a/src/main/java/teetime/framework/pipe/PipeFactoryRegistry.java +++ b/src/main/java/teetime/framework/pipe/PipeFactoryRegistry.java @@ -8,14 +8,27 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Represents a Registry which provides PipeFactories that are used to create pipes. + * The instance of this singleton class is saved in {@link PipeFactoryRegistry#INSTANCE}. + * <p> + * To get a PipeFactory instance, call {@link #getPipeFactory(ThreadCommunication, PipeOrdering, boolean)}. + * + */ public class PipeFactoryRegistry { private static final Logger LOGGER = LoggerFactory.getLogger(PipeFactoryRegistry.class); + /** + * Represent a communication type between two connected stages + */ public enum ThreadCommunication { INTER, INTRA } + /** + * Represents the ordering behavior of a pipe + */ public enum PipeOrdering { /** * FIFO @@ -30,6 +43,9 @@ public class PipeFactoryRegistry { private final Map<String, IPipeFactory> pipeFactories = new HashMap<String, IPipeFactory>(); + /** + * The singleton instance of PipeFactoryRegistry + */ public static PipeFactoryRegistry INSTANCE = new PipeFactoryRegistry(); private PipeFactoryRegistry() { @@ -43,23 +59,17 @@ public class PipeFactoryRegistry { } } - @Deprecated - public IPipe create(final ThreadCommunication tc, final PipeOrdering ordering, final boolean growable, final int capacity) { - IPipeFactory pipeFactory = getPipeFactory(tc, ordering, growable); - return pipeFactory.create(capacity); - } - /** - * Returns a PipeFactory Instance + * Returns a PipeFactory Instance. * * @param tc - * Communication type between two connected stages + * Communication type between two connected stages. These are defined in PipeFactoryRegistry.ThreadCommunication * @param ordering - * Specifies the ordering behavior of the pipe + * Specifies the ordering behavior of the pipe. See PipeFactoryRegistry.PipeOrdering * @param growable - * Whether the queue size is fixed or not + * Whether the queue size is fixed or not. * @return - * A PipeFactory, which provides suitable pipes + * A PipeFactory, which provides suitable pipes. */ public IPipeFactory getPipeFactory(final ThreadCommunication tc, final PipeOrdering ordering, final boolean growable) { String key = this.buildKey(tc, ordering, growable); @@ -71,8 +81,12 @@ public class PipeFactoryRegistry { } /** + * Adds a new PipeFactory to the registry.<br /> + * The new PipeFactory will be automatically selected by the Registry, if it is the most suitable Factory + * corresponding to the requirements. * * @param pipeFactory + * A PipeFactory which will be added to the registry */ public void register(final IPipeFactory pipeFactory) { String key = this.buildKey(pipeFactory.getThreadCommunication(), pipeFactory.getOrdering(), pipeFactory.isGrowable()); @@ -80,13 +94,6 @@ public class PipeFactoryRegistry { LOGGER.info("Registered pipe factory: " + pipeFactory.getClass().getCanonicalName()); } - /** - * - * @param tc - * @param ordering - * @param growable - * @return - */ private String buildKey(final ThreadCommunication tc, final PipeOrdering ordering, final boolean growable) { return tc.toString() + ordering.toString() + growable; } diff --git a/src/main/java/teetime/framework/pipe/SingleElementPipeFactory.java b/src/main/java/teetime/framework/pipe/SingleElementPipeFactory.java index b51000fab0dc391fcb2c627cc3089e3508a5044d..7a76c7448953b793cc762241e6b879c18be93051 100644 --- a/src/main/java/teetime/framework/pipe/SingleElementPipeFactory.java +++ b/src/main/java/teetime/framework/pipe/SingleElementPipeFactory.java @@ -7,14 +7,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; public class SingleElementPipeFactory implements IPipeFactory { - /** - * Hint: The capacity for this pipe implementation is ignored - */ - @Override - public IPipe create(final int capacity) { - return create(null, null); - } - @Override public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) { return create(sourcePort, targetPort, 1); diff --git a/src/main/java/teetime/framework/pipe/SpScPipeFactory.java b/src/main/java/teetime/framework/pipe/SpScPipeFactory.java index 745e79715025cb5e4d5ad6690f1d6ba7c5265147..88e4d59bbe0389afc39171e427c1cd2fc2d168ae 100644 --- a/src/main/java/teetime/framework/pipe/SpScPipeFactory.java +++ b/src/main/java/teetime/framework/pipe/SpScPipeFactory.java @@ -7,11 +7,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; public class SpScPipeFactory implements IPipeFactory { - @Override - public IPipe create(final int capacity) { - return create(null, null, capacity); - } - @Override public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) { return create(sourcePort, targetPort, 4); diff --git a/src/main/java/teetime/framework/pipe/UnorderedGrowablePipeFactory.java b/src/main/java/teetime/framework/pipe/UnorderedGrowablePipeFactory.java index 219d95d796c6d688dbf09e8356c283bd24ac75c3..7809347aa36c4d10269add05055d7051a6b96c64 100644 --- a/src/main/java/teetime/framework/pipe/UnorderedGrowablePipeFactory.java +++ b/src/main/java/teetime/framework/pipe/UnorderedGrowablePipeFactory.java @@ -7,14 +7,6 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; public class UnorderedGrowablePipeFactory implements IPipeFactory { - /** - * Hint: The capacity for this pipe implementation is ignored - */ - @Override - public IPipe create(final int capacity) { - return create(null, null, capacity); - } - @Override public <T> IPipe create(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) { return create(sourcePort, targetPort, 4); diff --git a/src/test/java/teetime/examples/cipher/CipherConfiguration.java b/src/test/java/teetime/examples/cipher/CipherConfiguration.java index a945e25f6e260cbea71c54795b49c503a029d70c..5b036d173a0cf6ae0f0a14e3a5d283ebfdc2b8bc 100644 --- a/src/test/java/teetime/examples/cipher/CipherConfiguration.java +++ b/src/test/java/teetime/examples/cipher/CipherConfiguration.java @@ -3,6 +3,7 @@ package teetime.examples.cipher; import java.io.File; import teetime.framework.AnalysisConfiguration; +import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; import teetime.stage.CipherByteArray; @@ -27,18 +28,14 @@ public class CipherConfiguration extends AnalysisConfiguration { CipherByteArray decrypt = new CipherByteArray(password, CipherMode.DECRYPT); ByteArrayFileWriter writer = new ByteArrayFileWriter(output); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(init.getOutputPort(), f2b.getInputPort()); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(f2b.getOutputPort(), enc.getInputPort()); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(enc.getOutputPort(), comp.getInputPort()); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(comp.getOutputPort(), decomp.getInputPort()); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(decomp.getOutputPort(), decrypt.getInputPort()); - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(decrypt.getOutputPort(), writer.getInputPort()); + IPipeFactory factory = PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); + + factory.create(init.getOutputPort(), f2b.getInputPort()); + factory.create(f2b.getOutputPort(), enc.getInputPort()); + factory.create(enc.getOutputPort(), comp.getInputPort()); + factory.create(comp.getOutputPort(), decomp.getInputPort()); + factory.create(decomp.getOutputPort(), decrypt.getInputPort()); + factory.create(decrypt.getOutputPort(), writer.getInputPort()); this.getFiniteProducerStages().add(init);