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

refactoring

parent 9b715e4c
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import org.slf4j.Logger; ...@@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import teetime.framework.exceptionHandling.AbstractExceptionListener; import teetime.framework.exceptionHandling.AbstractExceptionListener;
import teetime.framework.exceptionHandling.IExceptionListenerFactory;
import teetime.framework.signal.InitializingSignal; import teetime.framework.signal.InitializingSignal;
import teetime.util.ThreadThrowableContainer; import teetime.util.ThreadThrowableContainer;
import teetime.util.framework.concurrent.SignalingCounter; import teetime.util.framework.concurrent.SignalingCounter;
...@@ -52,18 +53,22 @@ class ThreadService extends AbstractService<ThreadService> { ...@@ -52,18 +53,22 @@ class ThreadService extends AbstractService<ThreadService> {
@Override @Override
void initialize() { void initialize() {
Configuration config = (Configuration) compositeStage; IExceptionListenerFactory factory;
try {
factory = ((Configuration) compositeStage).getFactory();
} catch (ClassCastException e) {
throw new IllegalStateException("Something went wrong");
}
if (threadableStages.isEmpty()) { if (threadableStages.isEmpty()) {
throw new IllegalStateException("No stage was added using the addThreadableStage(..) method. Add at least one stage."); throw new IllegalStateException("No stage was added using the addThreadableStage(..) method. Add at least one stage.");
} }
for (Stage stage : threadableStages.keySet()) { for (Stage stage : threadableStages.keySet()) {
final Thread thread = initialize(stage); final Thread thread = initializeStage(stage);
final Set<Stage> intraStages = traverseIntraStages(stage); final Set<Stage> intraStages = traverseIntraStages(stage);
// FIXME: receive factory from config! final AbstractExceptionListener newListener = factory.createInstance();
final AbstractExceptionListener newListener = config.getFactory().createInstance();
initializeIntraStages(intraStages, thread, newListener); initializeIntraStages(intraStages, thread, newListener);
} }
...@@ -77,7 +82,7 @@ class ThreadService extends AbstractService<ThreadService> { ...@@ -77,7 +82,7 @@ class ThreadService extends AbstractService<ThreadService> {
} }
} }
private Thread initialize(final Stage stage) { private Thread initializeStage(final Stage stage) {
final Thread thread; final Thread thread;
final TerminationStrategy terminationStrategy = stage.getTerminationStrategy(); final TerminationStrategy terminationStrategy = stage.getTerminationStrategy();
......
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