Package org.drools.core.time.impl
Class JDKTimerService
- java.lang.Object
-
- org.drools.core.time.impl.JDKTimerService
-
- All Implemented Interfaces:
InternalSchedulerService,SchedulerService,TimerService,org.kie.api.time.SessionClock
public class JDKTimerService extends java.lang.Object implements TimerService, org.kie.api.time.SessionClock, InternalSchedulerService
A default Scheduler implementation that uses the JDK built-in ScheduledThreadPoolExecutor as the scheduler and the system clock as the clock.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJDKTimerService.JDKJobHandle
-
Field Summary
Fields Modifier and Type Field Description protected TimerJobFactoryManagerjobFactoryManagerprotected java.util.concurrent.ScheduledThreadPoolExecutorscheduler
-
Constructor Summary
Constructors Constructor Description JDKTimerService()JDKTimerService(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCurrentTime()Returns the current time from the scheduler clockTimerJobFactoryManagergetTimerJobFactoryManager()java.util.Collection<TimerJobInstance>getTimerJobInstances(long id)This method may return null for some TimerService implementations that do not want the overhead of maintain this.longgetTimeToNextJob()Returns the number of time units (usually ms) to the next scheduled jobvoidinternalSchedule(TimerJobInstance timerJobInstance)booleanremoveJob(JobHandle jobHandle)Remove the job identified by the given job handle from the scheduled queuevoidreset()Reset this serviceJobHandlescheduleJob(Job job, JobContext ctx, Trigger trigger)Schedule a job for later executionvoidsetTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)voidshutdown()Shuts the service down
-
-
-
Field Detail
-
scheduler
protected java.util.concurrent.ScheduledThreadPoolExecutor scheduler
-
jobFactoryManager
protected TimerJobFactoryManager jobFactoryManager
-
-
Method Detail
-
setTimerJobFactoryManager
public void setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
- Specified by:
setTimerJobFactoryManagerin interfaceTimerService
-
getTimerJobFactoryManager
public TimerJobFactoryManager getTimerJobFactoryManager()
- Specified by:
getTimerJobFactoryManagerin interfaceTimerService
-
getCurrentTime
public long getCurrentTime()
Description copied from interface:TimerServiceReturns the current time from the scheduler clock- Specified by:
getCurrentTimein interfaceorg.kie.api.time.SessionClock- Specified by:
getCurrentTimein interfaceTimerService- Returns:
- the current timestamp
-
reset
public void reset()
Description copied from interface:TimerServiceReset this service- Specified by:
resetin interfaceTimerService
-
shutdown
public void shutdown()
Description copied from interface:TimerServiceShuts the service down- Specified by:
shutdownin interfaceTimerService
-
scheduleJob
public JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger)
Description copied from interface:SchedulerServiceSchedule a job for later execution- Specified by:
scheduleJobin interfaceSchedulerService- Returns:
-
internalSchedule
public void internalSchedule(TimerJobInstance timerJobInstance)
- Specified by:
internalSchedulein interfaceInternalSchedulerService
-
removeJob
public boolean removeJob(JobHandle jobHandle)
Description copied from interface:SchedulerServiceRemove the job identified by the given job handle from the scheduled queue- Specified by:
removeJobin interfaceSchedulerService- Parameters:
jobHandle- the job identity handle- Returns:
-
getTimeToNextJob
public long getTimeToNextJob()
Description copied from interface:TimerServiceReturns the number of time units (usually ms) to the next scheduled job- Specified by:
getTimeToNextJobin interfaceTimerService- Returns:
- the number of time units until the next scheduled job or -1 if there is no job scheduled
-
getTimerJobInstances
public java.util.Collection<TimerJobInstance> getTimerJobInstances(long id)
Description copied from interface:TimerServiceThis method may return null for some TimerService implementations that do not want the overhead of maintain this.- Specified by:
getTimerJobInstancesin interfaceTimerService- Returns:
-
-