org.drools.time.impl
Class JDKTimerService

java.lang.Object
  extended by org.drools.time.impl.JDKTimerService
All Implemented Interfaces:
AcceptsTimerJobFactoryManager, InternalSchedulerService, SchedulerService, org.drools.time.SessionClock, TimerService

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

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.JDKJobHandle
           
 
Field Summary
protected  TimerJobFactoryManager jobFactoryManager
           
protected  ScheduledThreadPoolExecutor scheduler
           
 
Constructor Summary
JDKTimerService()
           
JDKTimerService(int size)
           
 
Method Summary
 long getCurrentTime()
          Returns the current time from the scheduler clock
 TimerJobFactoryManager getTimerJobFactoryManager()
           
 Collection<TimerJobInstance> getTimerJobInstances()
          This method may return null for some TimerService implementations that do not want the overhead of maintain this.
 long getTimeToNextJob()
          Returns the number of time units (usually ms) to the next scheduled job
 void internalSchedule(TimerJobInstance timerJobInstance)
           
 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 setCounter(long counter)
           
 void setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
           
 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

jobFactoryManager

protected TimerJobFactoryManager jobFactoryManager
Constructor Detail

JDKTimerService

public JDKTimerService()

JDKTimerService

public JDKTimerService(int size)
Method Detail

setTimerJobFactoryManager

public void setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
Specified by:
setTimerJobFactoryManager in interface AcceptsTimerJobFactoryManager

setCounter

public void setCounter(long counter)

getTimerJobFactoryManager

public TimerJobFactoryManager getTimerJobFactoryManager()
Specified by:
getTimerJobFactoryManager in interface AcceptsTimerJobFactoryManager

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:

internalSchedule

public void internalSchedule(TimerJobInstance timerJobInstance)
Specified by:
internalSchedule in interface InternalSchedulerService

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

getTimerJobInstances

public Collection<TimerJobInstance> getTimerJobInstances()
Description copied from interface: TimerService
This method may return null for some TimerService implementations that do not want the overhead of maintain this.

Specified by:
getTimerJobInstances in interface TimerService
Returns:


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.