Package org.drools.core.time.impl
Class JDKTimerService
java.lang.Object
org.drools.core.time.impl.JDKTimerService
- All Implemented Interfaces:
InternalSchedulerService,SchedulerService,TimerService,SessionClock
public class JDKTimerService
extends Object
implements TimerService, 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TimerJobFactoryManagerprotected ScheduledThreadPoolExecutor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the current time from the scheduler clockgetTimerJobInstances(long id) This method may return null for some TimerService implementations that do not want the overhead of maintain this.longReturns the number of time units (usually ms) to the next scheduled jobvoidinternalSchedule(TimerJobInstance timerJobInstance) voidRemove the job identified by the given job handle from the scheduled queuevoidreset()Reset this servicescheduleJob(Job job, JobContext ctx, Trigger trigger) Schedule a job for later executionvoidsetTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager) voidshutdown()Shuts the service down
-
Field Details
-
scheduler
-
jobFactoryManager
-
-
Constructor Details
-
JDKTimerService
public JDKTimerService() -
JDKTimerService
public JDKTimerService(int size)
-
-
Method Details
-
setTimerJobFactoryManager
- Specified by:
setTimerJobFactoryManagerin interfaceTimerService
-
getTimerJobFactoryManager
- Specified by:
getTimerJobFactoryManagerin interfaceTimerService
-
getCurrentTime
public long getCurrentTime()Description copied from interface:TimerServiceReturns the current time from the scheduler clock- Specified by:
getCurrentTimein interfaceSessionClock- 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
Description copied from interface:SchedulerServiceSchedule a job for later execution- Specified by:
scheduleJobin interfaceSchedulerService- Returns:
-
internalSchedule
- Specified by:
internalSchedulein interfaceInternalSchedulerService
-
removeJob
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
-
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
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:
-