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

changed visibilities;

added setter to Iterable- and InitialElementProducer
parent 24b51e62
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,9 @@ import teetime.framework.pipe.PipeFactoryRegistry; ...@@ -26,6 +26,9 @@ import teetime.framework.pipe.PipeFactoryRegistry;
*/ */
public abstract class AnalysisConfiguration { public abstract class AnalysisConfiguration {
/**
* Can be used by subclasses, to obtain pipe factories
*/
protected static final PipeFactoryRegistry PIPE_FACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE; protected static final PipeFactoryRegistry PIPE_FACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE;
private final List<Stage> threadableStageJobs = new LinkedList<Stage>(); private final List<Stage> threadableStageJobs = new LinkedList<Stage>();
...@@ -39,7 +42,7 @@ public abstract class AnalysisConfiguration { ...@@ -39,7 +42,7 @@ public abstract class AnalysisConfiguration {
* @param stage * @param stage
* A arbitrary stage, which will be added to the configuration und executed in a thread. * A arbitrary stage, which will be added to the configuration und executed in a thread.
*/ */
public void addThreadableStage(final Stage stage) { protected void addThreadableStage(final Stage stage) {
this.threadableStageJobs.add(stage); this.threadableStageJobs.add(stage);
} }
......
...@@ -35,7 +35,7 @@ import teetime.framework.validation.InvalidPortConnection; ...@@ -35,7 +35,7 @@ import teetime.framework.validation.InvalidPortConnection;
@SuppressWarnings("PMD.AbstractNaming") @SuppressWarnings("PMD.AbstractNaming")
public abstract class CompositeStage extends Stage { public abstract class CompositeStage extends Stage {
protected static final IPipeFactory INTRA_PIPE_FACTORY = PipeFactoryRegistry.INSTANCE private static final IPipeFactory INTRA_PIPE_FACTORY = PipeFactoryRegistry.INSTANCE
.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); .getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false);
protected abstract Stage getFirstStage(); protected abstract Stage getFirstStage();
......
...@@ -19,7 +19,7 @@ import teetime.framework.AbstractProducerStage; ...@@ -19,7 +19,7 @@ import teetime.framework.AbstractProducerStage;
public final class InitialElementProducer<T> extends AbstractProducerStage<T> { public final class InitialElementProducer<T> extends AbstractProducerStage<T> {
private final T[] elements; private T[] elements;
public InitialElementProducer(final T... elements) { public InitialElementProducer(final T... elements) {
this.elements = elements; this.elements = elements;
...@@ -33,4 +33,16 @@ public final class InitialElementProducer<T> extends AbstractProducerStage<T> { ...@@ -33,4 +33,16 @@ public final class InitialElementProducer<T> extends AbstractProducerStage<T> {
this.terminate(); this.terminate();
} }
public void setIter(final T[] elements) {
this.elements = elements;
}
@Override
public void onStarting() throws Exception {
if (elements == null) {
throw new NullPointerException("iter must not be null");
}
super.onStarting();
}
} }
...@@ -17,20 +17,32 @@ package teetime.stage; ...@@ -17,20 +17,32 @@ package teetime.stage;
import teetime.framework.AbstractProducerStage; import teetime.framework.AbstractProducerStage;
public final class IterableProducer<O extends Iterable<T>, T> extends AbstractProducerStage<T> { public final class IterableProducer<T> extends AbstractProducerStage<T> {
private O iter = null; private Iterable<T> iter;
public IterableProducer(final O iter) { public <O extends Iterable<T>> IterableProducer(final O iter) {
this.iter = iter; this.iter = iter;
} }
@Override @Override
protected void execute() { protected void execute() {
for (T i : iter) { for (final T i : this.iter) {
outputPort.send(i); this.outputPort.send(i);
} }
} }
public void setIter(final Iterable<T> iter) {
this.iter = iter;
}
@Override
public void onStarting() throws Exception {
if (iter == null) {
throw new NullPointerException("iter must not be null");
}
super.onStarting();
}
} }
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