The idea is to have the possiblitiy to use the task timeout and onCancel() functionalities for tasks that are not instances of JPPFTask (Task<E> in v3.0)
This includes:
- Callable tasks
- Runnable
- POJO
- @JPPFRunnable annotated tasks
- Callable and Runnable tasks submitted with the JPPFExecutorService

Some possiblitlities come to mind:

- We could use interfaces to be implemented by the tasks:
public interface TimeoutAware {
JPPFSchedule getTimeoutSchedule();
void onTimeout();
}

public interface CancelAware {
void onCancel();
}

- We could check via reflection whether the functionality is implemented in the task, look for existence of methods getTimeoutSchedule(), onTimeout(), onCancel()

- We could use annotations: @GetTimeout, @OnTimeout, @OnCancel

One issue to deal with, is to provide the functionalities for JPPFExecutorService tasks without breaking the semantics of the java.util.concurrent.ExecutorService interface. Methods that apply to the executor itself could be ok,but not methods that modify the behavior of submitting tasks.

Discussion

To avoid the dependency on JPPF APIs for timeout, it would be good to have a way to set these sorts of properties via a config file on the client's side (or editing a property of something that can be easily accessed via the JPPFClient object).

For tasks added to a JPPFJob, these features are already available, since JPPFJob.addTask(...) returns a JPPFTask.
We have added an API to allow configuring jobs and tasks submitted via a JPPFExecutorService.