ch.javasoft.job
Class AbstractJob<R>

java.lang.Object
  extended by ch.javasoft.job.AbstractJob<R>
Type Parameters:
R - The return value type of the result
All Implemented Interfaces:
Executable<R>, Job<R>
Direct Known Subclasses:
PipeJob

public abstract class AbstractJob<R>
extends Object
implements Job<R>, Executable<R>

AbstractJob is an abstract base implementation for most jobs implementing both Job and Executable.


Constructor Summary
AbstractJob()
           
 
Method Summary
 JobMonitor<R> exec()
          Executes the job in a new thread.
 JobMonitor<R> exec(JobTerminationHandler<R> terminationHandler)
          Executes the job in a new thread.
 JobResult<R> execAndWait()
          Executes the job in a new thread and waits for completion.
 R execAndWaitThrowException()
          Executes the job in a new thread and waits for completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.javasoft.job.Job
run
 

Constructor Detail

AbstractJob

public AbstractJob()
Method Detail

exec

public JobMonitor<R> exec()
Executes the job in a new thread. The call immediately returns without waiting for job completion.

Specified by:
exec in interface Executable<R>
Returns:
the job status, which also allows access to the result when execution completed

exec

public JobMonitor<R> exec(JobTerminationHandler<R> terminationHandler)
Executes the job in a new thread. The call immediately returns without waiting for job completion.

Specified by:
exec in interface Executable<R>
Parameters:
terminationHandler - the handler for normal and exceptional termination of this job
Returns:
the job monitor

execAndWait

public JobResult<R> execAndWait()
                         throws InterruptedException
Executes the job in a new thread and waits for completion. The current thread is blocked until the job thread terminates.

Specified by:
execAndWait in interface Executable<R>
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()
                            throws InterruptedException,
                                   Throwable
Executes the job in a new thread and waits for completion. The current thread is blocked until the job thread terminates. If the job terminates normally, the result is returned. Otherwise, the job exception is thrown.

Specified by:
execAndWaitThrowException in interface Executable<R>
Returns:
the result if the job terminates normally
Throws:
InterruptedException
Throwable