API changes in JPPF 4.0
From JPPF 6.2 Documentation
|
Main Page > API changes > API changes in JPPF 4.0 |
1 The new Task API
1.1 New design
In JPPF 3.x, JPPFTask was, for all practical purposes, the base class for all tasks in JPPF. Version 4.0 introduces a more generic API, based on the Task<T> interface and its concrete implementation AbstractTask<T>, with JPPFTask redefined as public class JPPFTask extends AbstractTask<Object> {}.
Most of of the API changes listed here relate to this new design, which has implications well beyond the scope of the tasks implementation.
As of JPPF 4.0, the base interface for concrete task implementations is offically Task<T>, with JPPF providing a generic abstract implementation AbstractTask<T>, which implements all methods of the interface, except the run() method inherited from the Runnable interface. All JPPF 4.0 users are strongly encouraged to use AbstractTask<T>, for consistency with the framework.
1.2 New and changed methods
In Task<T>, the methods getException() and setException(Exception) were deprecated and are now replaced with the more generic getThrowable() and setThrowable(Throwable) respectively.
Since these new methods may be inconsistent with catch(Some_Exception_Class) {} clauses in existing code, a utility class ExceptionUtils is provided, with helper methods to convert a generic Throwable into a more specfic exception type.
A new method fireNotification(Object userObject, boolean sendViaJmx) was added, which allows the tasks to send notifications to local listeners ot remote listners via JMX.
2 Package org.jppf.client
2.1 Class JPPFClient
submit(JPPFJob job), which returns a List<JPPFTask>, is deprecated and replaced with submitJob(JPPFJob), which returns a List<Task<?>>.
reset() and reset(TypedProperties) methods have been added.
2.2 Class AbstractJPPFClient
As for JPPFClient, the abstract definition of submit(JPPFJob job) is deprecated and replaced with the method submitJob(JPPFJob).
2.3 Class JPPFJob
addTask(Object, Object...) and addTask(String, Object, Object...), which return a JPPFTask, are deprecated and replaced with add(Object, Object...) and add(String, Object, Object...) respectively, which return a Task<?>.
2.4 Class JPPFResultCollector
getResults(), waitForResults(), and waitForResults(long), which return a List<JPPFTask>, have been deprecated and replaced with getAllResults(), awaitResults() and awaitResults(long) respectively, which return a List<Task<?>>.
2.5 Class JobResults
getAll() : Collection<JPPFTask> is replaced with getAllResults() : Collection<Task<?>>
getResult(int) : JPPFTask is deprecated and replaced with getResultTask(int) : Task<?>
putResults(List<JPPFTask>) is deprecated and replaced with addResults(List<Task<?>>)
3 Package org.jppf.client.event
3.1 Class JobEvent
getTasks() : List<JPPFTask> is deprecated and replaced with getJobTasks() : List<Task<?>>.
3.2 Class TaskResultEvent
getTaskList() : List<JPPFTask> is deprecated and replaced with getTasks() : List<Task<?>>.
4 Package org.jppf.client.persistence
4.1 Class JobPersistence
storeJob(K, JPPFJob, List<JPPFTask>) was changed into storeJob(K, JPPFJob, List<Task<?>>).
4.2 Class DefaultFilePersistenceManager
storeJob(K, JPPFJob, List<JPPFTask>) was changed into storeJob(K, JPPFJob, List<Task<?>>).
5 Package org.jppf.client.taskwrapper
5.1 JPPFTaskCallback
The class JPPFTaskCallback has been genericized into JPPFTaskCallback<T>.
getTask() : JPPFTask was changed into getTask() : Task<T>.
6 Package org.jppf.client.utils
6.1 Class ClientWithFailover
submit(JPPFJob): List<JPPFTask> is deprecated and replaced with submitJob(JPPFJob): List<Task<?>>.
7 Package org.jppf.server.protocol
7.1 Class CommandLineTask genericized
CommandLineTask is now defined as CommandLineTask<T> extends AbstractTask<T>.
8 Package org.jppf.node.event
The classes TaskExecutionListener and TaskExecutionEvent moved from package org.jppf.server.node.
8.1 Class TasKExecutionListener
The method taskNotification(TaskExecutionEvent) has been added.
8.2 TasKExecutionEvent
The method getTask() : JPPFTask was changed into getTask() : Task<?>.
9 Package org.jppf.jca.cci (J2E connector)
9.1 Class JPPFConnection
getSubmissionResults(String): List<JPPFTask> and waitForResults(String): List<JPPFTask> have been deprecated and replaced with getResults(String): List<Task<?>> and awaitResults(String): List<Task<?>> respectively
The method resetClient() was added.
Main Page > API changes > API changes in JPPF 4.0 |