net.sf.sasl.common.schedule
Class QuartzSchedulerServiceAdapter

java.lang.Object
  extended by net.sf.sasl.common.schedule.QuartzSchedulerServiceAdapter
All Implemented Interfaces:
IScheduleService

public class QuartzSchedulerServiceAdapter
extends Object
implements IScheduleService

Adapter class which delegates calls to IScheduleService to a Quartz scheduler.
The adapter has some restrictions and will only work as expected, if the Quartz scheduler runs in a non clustered mode and uses a RAMJobStore. The adapter needs some other helper classes to get the adaption work together with Quartz.

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

Field Summary
static String JOBMAP_CALLABLE_EXECUTION_STATUS_KEY
          Name of the key in the job data map under which the execution status object is stored.
static String JOBMAP_CALLABLE_INPUT_CALLABLE_KEY
          Name of the key in the job data map under which the callable object is stored.
 
Constructor Summary
QuartzSchedulerServiceAdapter()
           
 
Method Summary
 org.quartz.Scheduler getQuartzSchedulerService()
          Returns the Quartz scheduler instance which will be used to schedule futures.
<V> ScheduledFuture<V>
schedule(Callable<V> callable, long millis)
          Tries to schedule the given callable over the setted Quartz scheduler.
 void setQuartzSchedulerService(org.quartz.Scheduler quartzSchedulerService)
          Sets the a Quartz scheduler instance which will be used to schedule futures.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JOBMAP_CALLABLE_INPUT_CALLABLE_KEY

public static final String JOBMAP_CALLABLE_INPUT_CALLABLE_KEY
Name of the key in the job data map under which the callable object is stored.

Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Constant Field Values

JOBMAP_CALLABLE_EXECUTION_STATUS_KEY

public static final String JOBMAP_CALLABLE_EXECUTION_STATUS_KEY
Name of the key in the job data map under which the execution status object is stored.

Since:
0.0.1 (sasl-common-aspect-library)
See Also:
Constant Field Values
Constructor Detail

QuartzSchedulerServiceAdapter

public QuartzSchedulerServiceAdapter()
Method Detail

schedule

public <V> ScheduledFuture<V> schedule(Callable<V> callable,
                                       long millis)
                            throws IllegalArgumentException
Tries to schedule the given callable over the setted Quartz scheduler. If everything worked fine a ScheduledFuture instance for the callable is returned.

Specified by:
schedule in interface IScheduleService
Parameters:
callable - non null
millis - the amount of milliseconds from now at which the callable should be executed in the future.
Returns:
null or non null
Throws:
IllegalArgumentException - if callable is null or millis is lesser than 0.
Since:
0.0.1 (sasl-common-aspect-library)
See Also:
IScheduleService.schedule(java.util.concurrent.Callable, long)

setQuartzSchedulerService

public void setQuartzSchedulerService(org.quartz.Scheduler quartzSchedulerService)
                               throws IllegalArgumentException
Sets the a Quartz scheduler instance which will be used to schedule futures. The Quartz scheduler should not run in a clustered mode and must use a RAMJobStore, otherwise the adapter will possibly not work correctly and strange things could happen.

Parameters:
quartzSchedulerService - non null
Throws:
IllegalArgumentException - if quartzSchedulerService is null
Since:
0.0.1 (sasl-common-aspect-library)

getQuartzSchedulerService

public org.quartz.Scheduler getQuartzSchedulerService()
Returns the Quartz scheduler instance which will be used to schedule futures.

Returns:
null or non null
Since:
0.0.1 (sasl-common-aspect-library)


Copyright © 2010. All Rights Reserved.