ch.javasoft.job
Class MultiJobExecutable<R>

java.lang.Object
  extended by ch.javasoft.job.MultiJobExecutable<R>
All Implemented Interfaces:
Executable<Queue<R>>

public class MultiJobExecutable<R>
extends Object
implements Executable<Queue<R>>

The MultiJobExecutable executes multiple jobs, each in its own thread. The result is a queue of the single job results, if all jobs terminated normally. If any of the jobs terminated with an exception, the result if this executable is also exceptional. The first occurring exception is returned by this executable, and all other jobs are interrupted if an exception occurs.


Constructor Summary
MultiJobExecutable(Iterable<Job<? extends R>> jobs)
           
MultiJobExecutable(Job<? extends R> jobA, Job<? extends R> jobB)
           
MultiJobExecutable(Job<? extends R> jobA, Job<? extends R> jobB, Job<? extends R> jobC)
           
MultiJobExecutable(Job<? extends R> jobA, Job<? extends R> jobB, Job<? extends R> jobC, Job<? extends R> jobD)
           
 
Method Summary
 JobMonitor<Queue<R>> exec()
          Executes and returns immediately, without waiting for completion.
 JobMonitor<Queue<R>> exec(JobTerminationHandler<Queue<R>> terminationHandler)
          Executes and returns immediately, without waiting for completion.
 JobResult<Queue<R>> execAndWait()
          Executes and waits for completion.
 Queue<R> execAndWaitThrowException()
          Executes and waits for completion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiJobExecutable

public MultiJobExecutable(Job<? extends R> jobA,
                          Job<? extends R> jobB)

MultiJobExecutable

public MultiJobExecutable(Job<? extends R> jobA,
                          Job<? extends R> jobB,
                          Job<? extends R> jobC)

MultiJobExecutable

public MultiJobExecutable(Job<? extends R> jobA,
                          Job<? extends R> jobB,
                          Job<? extends R> jobC,
                          Job<? extends R> jobD)

MultiJobExecutable

public MultiJobExecutable(Iterable<Job<? extends R>> jobs)
Method Detail

exec

public JobMonitor<Queue<R>> exec()
Description copied from interface: Executable
Executes and returns immediately, without waiting for completion.

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

exec

public JobMonitor<Queue<R>> exec(JobTerminationHandler<Queue<R>> terminationHandler)
Description copied from interface: Executable
Executes and returns immediately, without waiting for completion. The submitted termination handler is notified upon normal or exceptional termination.

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

execAndWait

public JobResult<Queue<R>> execAndWait()
                                throws InterruptedException
Description copied from interface: Executable
Executes and waits for completion.

Specified by:
execAndWait in interface Executable<Queue<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 Queue<R> execAndWaitThrowException()
                                   throws InterruptedException,
                                          Throwable
Description copied from interface: Executable
Executes and waits for completion. The result is returned on normal termination, and an exception is thrown on abnormal (exceptional) termination.

Specified by:
execAndWaitThrowException in interface Executable<Queue<R>>
Returns:
the result if termination is normal
Throws:
InterruptedException
Throwable