org.opt4j.core.config
Class Task

java.lang.Object
  extended by org.opt4j.core.config.Task
All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Void>
Direct Known Subclasses:
Opt4JTask

public abstract class Task
extends java.lang.Object
implements java.util.concurrent.Callable<java.lang.Void>

The Task is an abstract class for optimization tasks.

See Also:
ExecutionEnvironment

Nested Class Summary
static class Task.State
          The Task.State of a task.
 
Field Summary
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 Summary
Task()
           
 
Method Summary
 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 Modules 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

state

protected Task.State state

e

protected java.lang.Exception e

modules

protected final java.util.List<com.google.inject.Module> modules

isInit

protected boolean isInit

listeners

protected final java.util.Set<TaskStateListener> listeners
Constructor Detail

Task

public Task()
Method Detail

init

public void init(com.google.inject.Module... modules)
Initializes the Task with modules.

Parameters:
modules - the modules for the task
See Also:
init(Collection)

init

public void init(java.util.Collection<com.google.inject.Module> modules)
Initializes the 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.

Parameters:
modules - the modules for the task

execute

public abstract void execute()
                      throws java.lang.Exception
Executes the Task.

Throws:
java.lang.Exception

call

public java.lang.Void call()
                    throws java.lang.Exception
Specified by:
call in interface java.util.concurrent.Callable<java.lang.Void>
Throws:
java.lang.Exception

getException

public java.lang.Exception getException()
Returns the Exception that was thrown during the Task execution if an error occurred.

Returns:
the occurred exception

getState

public Task.State getState()
Returns the state of the Task.

Returns:
the state of the task

setState

protected void setState(Task.State state)
Sets the state of the Task.

Parameters:
state - the state of the task to be set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addStateListener

public void addStateListener(TaskStateListener listener)
Adds a TaskStateListener.

Parameters:
listener - the listener to be added
See Also:
removeStateListener(org.opt4j.core.config.TaskStateListener)

removeStateListener

public void removeStateListener(TaskStateListener listener)
Removes a TaskStateListener.

Parameters:
listener - the listener to be removed
See Also:
addStateListener(org.opt4j.core.config.TaskStateListener)

getModules

public java.util.Collection<com.google.inject.Module> getModules()
Returns a copy of the Modules of this Task.

Returns:
a set of modules