net.sf.sasl.common.schedule
Class QuartzScheduledFuture<V>

java.lang.Object
  extended by net.sf.sasl.common.schedule.QuartzScheduledFuture<V>
All Implemented Interfaces:
Comparable<Delayed>, Delayed, Future<V>, ScheduledFuture<V>, org.quartz.JobListener

public class QuartzScheduledFuture<V>
extends Object
implements ScheduledFuture<V>, org.quartz.JobListener

The class is a helper class for the QuartzServiceAdapter and should not be used outside the package.
Implements together with other helper classes a ScheduledFuture that gets executed by a Quartz scheduler over the QuartzServiceAdapter.

Since:
0.0.1 (sasl-common-aspect-library)
Author:
Philipp Förmer

Constructor Summary
QuartzScheduledFuture(org.quartz.Scheduler quartzScheduler, org.quartz.JobDetail jobDetail, CallableExecutionStatus callableExecutionStatus, Date expectedExecutionDate)
          Default constructor.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          Tries to cancel the future at the Quartz scheduler.
 int compareTo(Delayed delayed)
          Returns 1, if the given delayed is null or the remaining delay time is lesser than the remaining delay time of this object.
 V get()
           
 V get(long timeVal, TimeUnit timeUnit)
           
 long getDelay(TimeUnit timeUnit)
           
 String getName()
          Returns the name of this job listener which will be a name of the form fullQualifiedPackagename-sharedLogicalClockValue.
 boolean isCancelled()
          Returns true if the future was cancelled before the execution started, false else.
 boolean isDone()
          Returns true, if the future was executed and terminated regular or via an exception.
 void jobExecutionVetoed(org.quartz.JobExecutionContext jobExecutionContext)
          Just a stub method, not relevant.
 void jobToBeExecuted(org.quartz.JobExecutionContext jobExecutionContext)
          Just a stub method, not relevant.
 void jobWasExecuted(org.quartz.JobExecutionContext jobExecutionContext, org.quartz.JobExecutionException jobExecutionException)
          Removes this object from the list of job listeners of the Quartz scheduler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuartzScheduledFuture

public QuartzScheduledFuture(org.quartz.Scheduler quartzScheduler,
                             org.quartz.JobDetail jobDetail,
                             CallableExecutionStatus callableExecutionStatus,
                             Date expectedExecutionDate)
                      throws IllegalArgumentException
Default constructor.

Parameters:
quartzScheduler - non null
jobDetail - non null
callableExecutionStatus - non null
expectedExecutionDate - non null
Throws:
IllegalArgumentException - if one of the input parameters are null.
Since:
0.0.1 (sasl-common-aspect-library)
Method Detail

getName

public String getName()
Returns the name of this job listener which will be a name of the form fullQualifiedPackagename-sharedLogicalClockValue.

Specified by:
getName in interface org.quartz.JobListener
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
JobListener.getName()

jobExecutionVetoed

public void jobExecutionVetoed(org.quartz.JobExecutionContext jobExecutionContext)
Just a stub method, not relevant.

Specified by:
jobExecutionVetoed in interface org.quartz.JobListener
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
JobListener.jobExecutionVetoed(org.quartz.JobExecutionContext)

jobToBeExecuted

public void jobToBeExecuted(org.quartz.JobExecutionContext jobExecutionContext)
Just a stub method, not relevant.

Specified by:
jobToBeExecuted in interface org.quartz.JobListener
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
JobListener.jobToBeExecuted(org.quartz.JobExecutionContext)

jobWasExecuted

public void jobWasExecuted(org.quartz.JobExecutionContext jobExecutionContext,
                           org.quartz.JobExecutionException jobExecutionException)
Removes this object from the list of job listeners of the Quartz scheduler. If the future was not cancelled sets after the done flag and the result value or occured exception and notifies all threads which are currently waiting in the get() or get(long, TimeUnit) methods.

Specified by:
jobWasExecuted in interface org.quartz.JobListener
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
JobListener.jobWasExecuted(org.quartz.JobExecutionContext, org.quartz.JobExecutionException)

getDelay

public long getDelay(TimeUnit timeUnit)
Specified by:
getDelay in interface Delayed
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Delayed.getDelay(java.util.concurrent.TimeUnit)

compareTo

public int compareTo(Delayed delayed)
Returns 1, if the given delayed is null or the remaining delay time is lesser than the remaining delay time of this object. Returns -1, if the remaining delay time of this object is lesser than the remaining delay time of the given delayed. In all other cases 0 will be returned (=remaining delay times are equal).

Specified by:
compareTo in interface Comparable<Delayed>
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Comparable.compareTo(java.lang.Object)

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Tries to cancel the future at the Quartz scheduler. The execution status of the callable will be tried to mark as cancelled. If this succeeds the future will be deleted from the Quartz scheduler and waiting threads in the get() and get(long, TimeUnit) will be notified.

Specified by:
cancel in interface Future<V>
Parameters:
mayInterruptIfRunning - does not have any affect at this implementation.
Returns:
true if the cancellation was successful, false if cancelled successfully already at the past or future was already computed.
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Future.cancel(boolean)

get

public V get()
      throws InterruptedException,
             ExecutionException
Specified by:
get in interface Future<V>
Throws:
InterruptedException
ExecutionException
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Future.get()

get

public V get(long timeVal,
             TimeUnit timeUnit)
      throws InterruptedException,
             ExecutionException,
             TimeoutException,
             IllegalArgumentException
Specified by:
get in interface Future<V>
Throws:
IllegalArgumentException - if timeUnit is null or timeVal is lesser than 0.
InterruptedException
ExecutionException
TimeoutException
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Future.get(long, java.util.concurrent.TimeUnit)

isCancelled

public boolean isCancelled()
Returns true if the future was cancelled before the execution started, false else.

Specified by:
isCancelled in interface Future<V>
Returns:
true or false.
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Future.isCancelled()

isDone

public boolean isDone()
Returns true, if the future was executed and terminated regular or via an exception. Returns also true, if the the future was successfully cancelled in the past. In all other cases false will be returned.

Specified by:
isDone in interface Future<V>
Returns:
true or false.
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Future.isDone()


Copyright © 2010. All Rights Reserved.