Package org.opt4j.config
Class ExecutionEnvironment
- java.lang.Object
-
- org.opt4j.config.ExecutionEnvironment
-
- All Implemented Interfaces:
TaskStateListener
public class ExecutionEnvironment extends Object implements TaskStateListener
TheExecutionEnvironmentforTasks. The environment starts and monitors optimization tasks. Tasks are not submitted directly, instead a collection ofModules is submitted and aTaskis created. TheExecutionEnvironmentis processing theTasks sequentially.- See Also:
Task
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorServiceexecutorprotected Set<TaskListener>listenersprotected com.google.inject.Provider<Task>taskProviderprotected List<Task>tasks
-
Constructor Summary
Constructors Constructor Description ExecutionEnvironment(com.google.inject.Provider<Task> taskProvider)Constructs aExecutionEnvironment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(TaskListener listener)Adds aTaskListener.protected voidaddTask(Task task)Adds aTaskand calls the listeners.voidexecute(Collection<com.google.inject.Module> modules)Executes the specified modules: ATaskis created and submitted.List<Task>getTasks()Returns the list of allTasks.voidremoveListener(TaskListener listener)Removes aTaskListener.voidstateChanged(Task task)Invoked if aTaskchanges its state.
-
-
-
Field Detail
-
taskProvider
protected final com.google.inject.Provider<Task> taskProvider
-
executor
protected final ExecutorService executor
-
listeners
protected final Set<TaskListener> listeners
-
-
Constructor Detail
-
ExecutionEnvironment
@Inject public ExecutionEnvironment(com.google.inject.Provider<Task> taskProvider)
Constructs aExecutionEnvironment.- Parameters:
taskProvider- the task provider
-
-
Method Detail
-
execute
public void execute(Collection<com.google.inject.Module> modules)
Executes the specified modules: ATaskis created and submitted.- Parameters:
modules- the collection of modules for aTask
-
addTask
protected void addTask(Task task)
Adds aTaskand calls the listeners.- Parameters:
task- the task to add
-
addListener
public void addListener(TaskListener listener)
Adds aTaskListener.- Parameters:
listener- the listener to be added
-
removeListener
public void removeListener(TaskListener listener)
Removes aTaskListener.- Parameters:
listener- the listener to be removed- See Also:
addListener(org.opt4j.config.TaskListener)
-
stateChanged
public void stateChanged(Task task)
Description copied from interface:TaskStateListenerInvoked if aTaskchanges its state.- Specified by:
stateChangedin interfaceTaskStateListener- Parameters:
task- the task that changed its state
-
-