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

the CompositeStage now extends AnalysisConfiguration

parent efa6071d
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,6 @@
*/
package teetime.framework;
import java.util.LinkedList;
import java.util.List;
import teetime.framework.signal.ISignal;
import teetime.framework.validation.InvalidPortConnection;
import teetime.util.Connection;
/**
* Represents a minimal stage that composes several other stages.
......@@ -32,84 +26,8 @@ import teetime.util.Connection;
*
*/
@Deprecated
public abstract class AbstractCompositeStage extends Stage {
private final List<Connection> connections = new LinkedList<Connection>();
public abstract class AbstractCompositeStage extends AnalysisConfiguration {
protected abstract Stage getFirstStage();
protected <T> void connectPorts(final OutputPort<? extends T> out, final InputPort<T> in) {
connections.add(new Connection(out, in));
}
public List<Connection> getConnections() {
return connections;
}
@Override
public final void validateOutputPorts(final List<InvalidPortConnection> invalidPortConnections) {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final void executeStage() {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final void onSignal(final ISignal signal, final InputPort<?> inputPort) {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final TerminationStrategy getTerminationStrategy() {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final void terminate() {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final boolean shouldBeTerminated() {
throw new IllegalStateException("This method must never be called");
}
@Override
public final StageState getCurrentState() {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final InputPort<?>[] getInputPorts() {
throw new IllegalStateException("This method must never be called");
}
@Override
protected final OutputPort<?>[] getOutputPorts() {
throw new IllegalStateException("This method must never be called");
}
@Override
public final void onValidating(final List<InvalidPortConnection> invalidPortConnections) {
throw new IllegalStateException("This method must never be called");
}
@Override
public final void onInitializing() throws Exception {
throw new IllegalStateException("This method must never be called");
}
@Override
public final void onStarting() throws Exception {
throw new IllegalStateException("This method must never be called");
}
@Override
public final void onTerminating() throws Exception {
throw new IllegalStateException("This method must never be called");
}
}
......@@ -32,7 +32,7 @@ import teetime.util.Connection;
public abstract class AnalysisConfiguration {
private final List<Stage> threadableStageJobs = new LinkedList<Stage>();
private final List<Connection> connections = new LinkedList<Connection>();
private final List<Connection<?>> connections = new LinkedList<Connection<?>>();
@SuppressWarnings("deprecation")
private static final PipeFactoryRegistry PIPE_FACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE;
......@@ -61,11 +61,14 @@ public abstract class AnalysisConfiguration {
* A arbitrary stage, which will be added to the configuration and executed in a thread.
*/
protected void addThreadableStage(final Stage stage) {
if (stage instanceof AbstractCompositeStage) {
this.threadableStageJobs.add(((AbstractCompositeStage) stage).getFirstStage());
this.connections.addAll(((AbstractCompositeStage) stage).getConnections());
} else {
this.threadableStageJobs.add(stage);
this.threadableStageJobs.add(stage);
}
protected void addThreadableStage(final AbstractCompositeStage stage) {
this.threadableStageJobs.add(stage.getFirstStage());
this.connections.addAll(stage.getConnections());
for (Stage threadableStage : stage.getThreadableStageJobs()) {
this.addThreadableStage(threadableStage);
}
}
......@@ -169,7 +172,7 @@ public abstract class AnalysisConfiguration {
* the pipe is set to this capacity, if the value is greater than 0. If it is 0, than the pipe is unbounded, thus growing of the pipe is enabled.
*/
protected <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
connections.add(new Connection(sourcePort, targetPort, capacity));
connections.add(new Connection<T>(sourcePort, targetPort, capacity));
}
/**
......@@ -177,7 +180,7 @@ public abstract class AnalysisConfiguration {
*
* @return a list of pairs of Out- and InputPorts, which are connected
*/
protected List<Connection> getConnections() {
protected List<Connection<?>> getConnections() {
return connections;
}
......
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