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 class
JDKTimerService.JDKJobHandle
-
Field Summary
Fields Modifier and Type Field Description protected TimerJobFactoryManager
jobFactoryManager
protected java.util.concurrent.ScheduledThreadPoolExecutor
scheduler
-
Constructor Summary
Constructors Constructor Description JDKTimerService()
JDKTimerService(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getCurrentTime()
Returns the current time from the scheduler clockTimerJobFactoryManager
getTimerJobFactoryManager()
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.long
getTimeToNextJob()
Returns the number of time units (usually ms) to the next scheduled jobvoid
internalSchedule(TimerJobInstance timerJobInstance)
void
removeJob(org.drools.base.time.JobHandle jobHandle)
Remove the job identified by the given job handle from the scheduled queuevoid
reset()
Reset this serviceorg.drools.base.time.JobHandle
scheduleJob(Job job, JobContext ctx, org.drools.base.time.Trigger trigger)
Schedule a job for later executionvoid
setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
void
shutdown()
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:
setTimerJobFactoryManager
in interfaceTimerService
-
getTimerJobFactoryManager
public TimerJobFactoryManager getTimerJobFactoryManager()
- Specified by:
getTimerJobFactoryManager
in interfaceTimerService
-
getCurrentTime
public long getCurrentTime()
Description copied from interface:TimerService
Returns the current time from the scheduler clock- Specified by:
getCurrentTime
in interfaceorg.kie.api.time.SessionClock
- Specified by:
getCurrentTime
in interfaceTimerService
- Returns:
- the current timestamp
-
reset
public void reset()
Description copied from interface:TimerService
Reset this service- Specified by:
reset
in interfaceTimerService
-
shutdown
public void shutdown()
Description copied from interface:TimerService
Shuts the service down- Specified by:
shutdown
in interfaceTimerService
-
scheduleJob
public org.drools.base.time.JobHandle scheduleJob(Job job, JobContext ctx, org.drools.base.time.Trigger trigger)
Description copied from interface:SchedulerService
Schedule a job for later execution- Specified by:
scheduleJob
in interfaceSchedulerService
- Returns:
-
internalSchedule
public void internalSchedule(TimerJobInstance timerJobInstance)
- Specified by:
internalSchedule
in interfaceInternalSchedulerService
-
removeJob
public void removeJob(org.drools.base.time.JobHandle jobHandle)
Description copied from interface:SchedulerService
Remove the job identified by the given job handle from the scheduled queue- Specified by:
removeJob
in interfaceSchedulerService
- Parameters:
jobHandle
- the job identity handle
-
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 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:TimerService
This method may return null for some TimerService implementations that do not want the overhead of maintain this.- Specified by:
getTimerJobInstances
in interfaceTimerService
- Returns:
-
-