ch.javasoft.job
Interface JobProcessor<JR,R,J extends Job<? extends JR>>

Type Parameters:
JR - Job result type, the (intermediate) result after starting job execution
R - The final result returned by the job after successful termination. Usually, JR and R are identical
J - The job type supported by this job processor
All Known Implementing Classes:
AbstractJobProcessor, CurrentThreadJobProcessor, ExecJobProcessor, NewThreadJobProcessor

public interface JobProcessor<JR,R,J extends Job<? extends JR>>

The JobProcessor is a generic interface which is implemented by different processors, which process jobs in different manners, e.g.

Not all job processors support all jobs, thus the implementation specifies the supported job types with the given parameters:


Method Summary
 void addJobTerminatedHandler(JobTerminationHandler<R> handler)
          Add a job termination handler, being notified after successful or exceptional job termination
 JobMonitor<R> exec(J job)
          Usually executes the given job and returns immediately, without waiting for completion, corresponding to Executable.exec().
 JobResult<R> execAndWait(J job)
          Usually executes the given job and waits for completion, corresponding to Executable.execAndWait().
 R execAndWaitThrowException(J job)
           
 boolean removeJobTerminatedHandler(JobTerminationHandler<R> handler)
          Removes a job termination handler.
 

Method Detail

addJobTerminatedHandler

void addJobTerminatedHandler(JobTerminationHandler<R> handler)
Add a job termination handler, being notified after successful or exceptional job termination

Parameters:
handler - the termination handler to be registered

removeJobTerminatedHandler

boolean removeJobTerminatedHandler(JobTerminationHandler<R> handler)
Removes a job termination handler.

Parameters:
handler - the termination handler to be unregistered
Returns:
true if such a handler existed and was removed

exec

JobMonitor<R> exec(J job)
Usually executes the given job and returns immediately, without waiting for completion, corresponding to Executable.exec(). Note that the exact behaviour is up to the implementor and might diverge from this general description.

Parameters:
job - the job to execute
Returns:
the job status, which also allows access to the result when execution completed

execAndWait

JobResult<R> execAndWait(J job)
                         throws InterruptedException
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.

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

R execAndWaitThrowException(J job)
                            throws InterruptedException,
                                   Throwable
Throws:
InterruptedException
Throwable