ch.javasoft.job
Class AbstractJobProcessor<JR,R,J extends Job<? extends JR>>
java.lang.Object
ch.javasoft.job.AbstractJobProcessor<JR,R,J>
- All Implemented Interfaces:
- JobProcessor<JR,R,J>
- Direct Known Subclasses:
- CurrentThreadJobProcessor, ExecJobProcessor, NewThreadJobProcessor
public abstract class AbstractJobProcessor<JR,R,J extends Job<? extends JR>>
- extends Object
- implements JobProcessor<JR,R,J>
An abstract implementation of JobProcessor, mainly implementing
JobTerminationHandler support.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractJobProcessor
public AbstractJobProcessor()
addJobTerminatedHandler
public void addJobTerminatedHandler(JobTerminationHandler<R> handler)
- Description copied from interface:
JobProcessor
- Add a job termination handler, being notified after successful or
exceptional job termination
- Specified by:
addJobTerminatedHandler in interface JobProcessor<JR,R,J extends Job<? extends JR>>
- Parameters:
handler - the termination handler to be registered
removeJobTerminatedHandler
public boolean removeJobTerminatedHandler(JobTerminationHandler<R> handler)
- Description copied from interface:
JobProcessor
- Removes a job termination handler.
- Specified by:
removeJobTerminatedHandler in interface JobProcessor<JR,R,J extends Job<? extends JR>>
- Parameters:
handler - the termination handler to be unregistered
- Returns:
true if such a handler existed and was removed
invokeTerminationHandlers
protected void invokeTerminationHandlers(J job,
R result)
invokeTerminationExceptionHandlers
protected void invokeTerminationExceptionHandlers(J job,
Throwable throwable)
execAndWait
public JobResult<R> execAndWait(J job)
throws InterruptedException
- Description copied from interface:
JobProcessor
- Usually executes the given job and waits for completion, corresponding to
Executable.execAndWait(). Note that the exact behaviour is up to
the implementor and might diverge from this general description.
- Specified by:
execAndWait in interface JobProcessor<JR,R,J extends Job<? extends JR>>
- Parameters:
job - the job to execute
- Returns:
- the job result, giving access to the return value on success,
or to the exception if execution caused any.
- Throws:
InterruptedException
execAndWaitThrowException
public R execAndWaitThrowException(J job)
throws InterruptedException,
Throwable
- Specified by:
execAndWaitThrowException in interface JobProcessor<JR,R,J extends Job<? extends JR>>
- Throws:
InterruptedException
Throwable