Skip to content
Snippets Groups Projects
Commit 7fff8d6d authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Added Javadoc to PipeFactoryRegistry and IPipeFactory

parent d33d2d5c
No related branches found
No related tags found
No related merge requests found
......@@ -7,24 +7,53 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public interface IPipeFactory {
/**
* @deprecated Use {@link #create(OutputPort, InputPort)} or {@link #create(OutputPort, InputPort, int)} instead
*
* @param capacity
* Number of elements the pipe can carry
* @return instance of the created pipe
*/
@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();
}
......@@ -8,14 +8,27 @@ import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Provides PipeFactories, which are used to connect stages.
* The instance of this singleton class is saved in <code>PipeFactoryRegistry.INSTANCE</code>.
* <p>
* To get a PipeFactory instance, call {@link #getPipeFactory(ThreadCommunication, PipeOrdering, boolean)}.
*
*/
public class PipeFactoryRegistry {
private static final Logger LOGGER = LoggerFactory.getLogger(PipeFactoryRegistry.class);
/**
* Communication type between two connected stages
*/
public enum ThreadCommunication {
INTER, INTRA
}
/**
* Specifies the ordering behavior of the pipe
*/
public enum PipeOrdering {
/**
* FIFO
......@@ -43,6 +56,16 @@ public class PipeFactoryRegistry {
}
}
/**
* @deprecated Use {@link IPipeFactory#create(OutputPort, InputPort, int)} instead,
* after obtaining a PipeFactory with {@link #getPipeFactory(ThreadCommunication, PipeOrdering, boolean)}.
*
* @param tc
* @param ordering
* @param growable
* @param capacity
* @return
*/
@Deprecated
public IPipe create(final ThreadCommunication tc, final PipeOrdering ordering, final boolean growable, final int capacity) {
IPipeFactory pipeFactory = getPipeFactory(tc, ordering, growable);
......@@ -50,16 +73,16 @@ public class PipeFactoryRegistry {
}
/**
* 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 +94,12 @@ public class PipeFactoryRegistry {
}
/**
* Registers 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 +107,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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment