|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jppf.server.protocol.JPPFTask
public abstract class JPPFTask
Abstract superclass for all tasks submitted to the execution server. This class provides the basic facilities to handle data shared among tasks, handling of task execution exception, and handling of the execution results.
JPPF clients have to extend this class and must implement the run method. In the
run method the task calculations are performed, and the result of the calculations
is set with the setResult(Object) method:
class MyTask extends JPPFTask {
public void run() {
// do the calculation ...
setResult(myResult);
}
}
| Field Summary | |
|---|---|
protected List<JPPFTaskListener> |
listeners
List of listeners for this task. |
| Constructor Summary | |
|---|---|
JPPFTask()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
addJPPFTaskListener(JPPFTaskListener listener)
Add a connection status listener to this connection's list of listeners. |
void |
fireNotification(Serializable source)
Notify all listeners that an event has occurred within this task. |
DataProvider |
getDataProvider()
Get the provider of shared data for this task. |
Exception |
getException()
Get the exception that was raised by this task's execution. |
String |
getId()
Get the user-assigned id for this task. |
protected List<JPPFTaskListener> |
getListeners()
Get the list of listeners for this task. |
int |
getPosition()
Returns the position of this task at the submission. |
Object |
getResult()
Get the result of the task execution. |
Object |
getTaskObject()
Get the JPPFRunnable-annotated object or POJO wrapped by this task. |
long |
getTimeout()
Get the timeout for this task. |
String |
getTimeoutDate()
Get the timeout date for this task. |
SimpleDateFormat |
getTimeoutDateFormat()
Deprecated. use getTimeoutFormat() instead. |
String |
getTimeoutFormat()
Get the format of timeout date for this task. |
JPPFSchedule |
getTimeoutSchedule()
Get the task timeout schedule configuration. |
void |
onCancel()
Callback invoked when this task is cancelled. |
void |
onRestart()
Callback invoked when this task is restarted. |
void |
onTimeout()
Callback invoked when this task times out. |
void |
removeJPPFTaskListener(JPPFTaskListener listener)
Remove a connection status listener from this connection's list of listeners. |
void |
setDataProvider(DataProvider dataProvider)
Set the provider of shared data for this task. |
void |
setException(Exception exception)
Sets the exception that was raised by this task's execution in the run method. |
void |
setId(String id)
Set the user-assigned id for this task. |
void |
setPosition(int position)
Sets the position of this task into the submission. |
void |
setResult(Object result)
Set the result of the task execution. |
void |
setTimeout(long timeout)
Set the timeout for this task. |
void |
setTimeoutDate(String timeoutDate,
SimpleDateFormat timeoutDateFormat)
Deprecated. use getTimeoutFormat(String, String) instead. |
void |
setTimeoutDate(String timeoutDate,
String format)
Set the timeout date for this task. |
void |
setTimeoutSchedule(JPPFSchedule timeoutSchedule)
Get the task timeout schedule configuration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.lang.Runnable |
|---|
run |
| Field Detail |
|---|
protected transient List<JPPFTaskListener> listeners
| Constructor Detail |
|---|
public JPPFTask()
| Method Detail |
|---|
public Object getResult()
public void setResult(Object result)
result - the result of this task's execution.public Exception getException()
Throwable, the exception is embedded into a JPPFException.
Exception instance, or null if no exception was raised.public void setException(Exception exception)
run method.
The exception is set by the JPPF framework.
exception - a ClientApplicationException instance.public DataProvider getDataProvider()
DataProvider instance.public void setDataProvider(DataProvider dataProvider)
dataProvider - a DataProvider instance.public final int getPosition()
public final void setPosition(int position)
position - The position of this task into the submission.public void addJPPFTaskListener(JPPFTaskListener listener)
listener - the listener to add to the list.public void removeJPPFTaskListener(JPPFTaskListener listener)
listener - the listener to remove from the list.public void fireNotification(Serializable source)
source - an object describing the event, must be serializable.protected List<JPPFTaskListener> getListeners()
JPPFTaskListener instances.public long getTimeout()
public void setTimeout(long timeout)
timeout - the timeout in milliseconds.public String getTimeoutDate()
public SimpleDateFormat getTimeoutDateFormat()
getTimeoutFormat() instead.
SimpleDateFormat instance.public String getTimeoutFormat()
SimpleDateFormat.
public void setTimeoutDate(String timeoutDate,
SimpleDateFormat timeoutDateFormat)
getTimeoutFormat(String, String) instead.
timeoutDate - the date to set in string representation.timeoutDateFormat - the format of of the date to set.
public void setTimeoutDate(String timeoutDate,
String format)
timeoutDate - the date to set in string representation.format - the format of of the date to set, as described in the specfication for SimpleDateFormat.SimpleDateFormatpublic String getId()
public void setId(String id)
id - the id as a string.public void onCancel()
public void onRestart()
public void onTimeout()
public Object getTaskObject()
JPPFRunnable-annotated object or POJO wrapped by this task.
public JPPFSchedule getTimeoutSchedule()
JPPFScheduleConfiguration instance.public void setTimeoutSchedule(JPPFSchedule timeoutSchedule)
timeoutSchedule - a JPPFScheduleConfiguration instance.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||