Package org.opt4j.config
Class ExecutionEnvironment
- java.lang.Object
-
- org.opt4j.config.ExecutionEnvironment
-
- All Implemented Interfaces:
TaskStateListener
public class ExecutionEnvironment extends Object implements TaskStateListener
TheExecutionEnvironment
forTask
s. The environment starts and monitors optimization tasks. Tasks are not submitted directly, instead a collection ofModule
s is submitted and aTask
is created. TheExecutionEnvironment
is processing theTask
s sequentially.- See Also:
Task
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutorService
executor
protected Set<TaskListener>
listeners
protected com.google.inject.Provider<Task>
taskProvider
protected 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 void
addListener(TaskListener listener)
Adds aTaskListener
.protected void
addTask(Task task)
Adds aTask
and calls the listeners.void
execute(Collection<com.google.inject.Module> modules)
Executes the specified modules: ATask
is created and submitted.List<Task>
getTasks()
Returns the list of allTask
s.void
removeListener(TaskListener listener)
Removes aTaskListener
.void
stateChanged(Task task)
Invoked if aTask
changes 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: ATask
is created and submitted.- Parameters:
modules
- the collection of modules for aTask
-
addTask
protected void addTask(Task task)
Adds aTask
and 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:TaskStateListener
Invoked if aTask
changes its state.- Specified by:
stateChanged
in interfaceTaskStateListener
- Parameters:
task
- the task that changed its state
-
-