org.drools.time.impl
Class JDKTimerService

java.lang.Object
  extended by org.drools.time.impl.JDKTimerService
All Implemented Interfaces:
SchedulerService, org.drools.time.SessionClock, TimerService
Direct Known Subclasses:
JpaJDKTimerService

public class JDKTimerService
extends Object
implements TimerService, org.drools.time.SessionClock

A default Scheduler implementation that uses the JDK built-in ScheduledThreadPoolExecutor as the scheduler and the system clock as the clock.


Nested Class Summary
static class JDKTimerService.JDKCallableJob
           
static class JDKTimerService.JDKJobHandle
           
 
Field Summary
protected  ScheduledThreadPoolExecutor scheduler
           
 
Constructor Summary
JDKTimerService()
           
JDKTimerService(int size)
           
 
Method Summary
protected  Callable<Void> createCallableJob(Job job, JobContext ctx, Trigger trigger, JDKTimerService.JDKJobHandle handle, ScheduledThreadPoolExecutor scheduler)
           
 long getCurrentTime()
          Returns the current time from the scheduler clock
 long getTimeToNextJob()
          Returns the number of time units (usually ms) to the next scheduled job
 boolean removeJob(JobHandle jobHandle)
          Remove the job identified by the given job handle from the scheduled queue
 JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger)
          Schedule a job for later execution
 void shutdown()
          Shuts the service down
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scheduler

protected ScheduledThreadPoolExecutor scheduler
Constructor Detail

JDKTimerService

public JDKTimerService()

JDKTimerService

public JDKTimerService(int size)
Method Detail

getCurrentTime

public long getCurrentTime()
Description copied from interface: TimerService
Returns the current time from the scheduler clock

Specified by:
getCurrentTime in interface org.drools.time.SessionClock
Specified by:
getCurrentTime in interface TimerService
Returns:
the current timestamp

shutdown

public void shutdown()
Description copied from interface: TimerService
Shuts the service down

Specified by:
shutdown in interface TimerService

scheduleJob

public JobHandle scheduleJob(Job job,
                             JobContext ctx,
                             Trigger trigger)
Description copied from interface: SchedulerService
Schedule a job for later execution

Specified by:
scheduleJob in interface SchedulerService
Returns:

createCallableJob

protected Callable<Void> createCallableJob(Job job,
                                           JobContext ctx,
                                           Trigger trigger,
                                           JDKTimerService.JDKJobHandle handle,
                                           ScheduledThreadPoolExecutor scheduler)

removeJob

public boolean removeJob(JobHandle jobHandle)
Description copied from interface: SchedulerService
Remove the job identified by the given job handle from the scheduled queue

Specified by:
removeJob in interface SchedulerService
Parameters:
jobHandle - the job identity handle
Returns:

getTimeToNextJob

public long getTimeToNextJob()
Description copied from interface: TimerService
Returns the number of time units (usually ms) to the next scheduled job

Specified by:
getTimeToNextJob in interface TimerService
Returns:
the number of time units until the next scheduled job or -1 if there is no job scheduled


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.