public abstract class Task
extends java.lang.Object
implements java.util.concurrent.Callable<java.lang.Void>
Task
is an abstract class for optimization tasks.ExecutionEnvironment
Modifier and Type | Class and Description |
---|---|
static class |
Task.State
The
Task.State of a task. |
Modifier and Type | Field and Description |
---|---|
protected java.lang.Exception |
e |
protected boolean |
isInit |
protected java.util.Set<TaskStateListener> |
listeners |
protected java.util.List<com.google.inject.Module> |
modules |
protected Task.State |
state |
Constructor and Description |
---|
Task() |
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(TaskStateListener listener)
Adds a
TaskStateListener . |
java.lang.Void |
call() |
abstract void |
execute()
Executes the
Task . |
java.lang.Exception |
getException()
Returns the
Exception that was thrown during the Task
execution if an error occurred. |
java.util.Collection<com.google.inject.Module> |
getModules()
Returns a copy of the
Module s of this Task . |
Task.State |
getState()
Returns the state of the
Task . |
void |
init(java.util.Collection<com.google.inject.Module> modules)
Initializes the
Task with modules. |
void |
init(com.google.inject.Module... modules)
Initializes the
Task with modules. |
void |
removeStateListener(TaskStateListener listener)
Removes a
TaskStateListener . |
protected void |
setState(Task.State state)
Sets the state of the
Task . |
java.lang.String |
toString() |
protected Task.State state
protected java.lang.Exception e
protected final java.util.List<com.google.inject.Module> modules
protected boolean isInit
protected final java.util.Set<TaskStateListener> listeners
public void init(com.google.inject.Module... modules)
Task
with modules.modules
- the modules for the taskinit(Collection)
public void init(java.util.Collection<com.google.inject.Module> modules)
Task
with modules. Note that if a module is a
PropertyModule
, a copy is made with the
PropertyModule.clone()
method. If the Module
is not a
PropertyModule
, the module is copied as a reference, i.e., it can
be changed until the execute()
is called.modules
- the modules for the taskpublic abstract void execute() throws java.lang.Exception
Task
.java.lang.Exception
public java.lang.Void call() throws java.lang.Exception
call
in interface java.util.concurrent.Callable<java.lang.Void>
java.lang.Exception
public java.lang.Exception getException()
Exception
that was thrown during the Task
execution if an error occurred.public Task.State getState()
Task
.protected void setState(Task.State state)
Task
.state
- the state of the task to be setpublic java.lang.String toString()
toString
in class java.lang.Object
public void addStateListener(TaskStateListener listener)
TaskStateListener
.listener
- the listener to be addedremoveStateListener(org.opt4j.core.config.TaskStateListener)
public void removeStateListener(TaskStateListener listener)
TaskStateListener
.listener
- the listener to be removedaddStateListener(org.opt4j.core.config.TaskStateListener)
public java.util.Collection<com.google.inject.Module> getModules()
Module
s of this Task
.