org.drools.time.impl
Class PseudoClockScheduler

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

public class PseudoClockScheduler
extends Object
implements TimerService, SessionPseudoClock, Externalizable, InternalSchedulerService, AcceptsTimerJobFactoryManager

A PseudoClockScheduler is a scheduler based on a user controlled clock that allows the user to explicitly control current time.

See Also:
Serialized Form

Constructor Summary
PseudoClockScheduler()
           
PseudoClockScheduler(InternalWorkingMemory session)
           
 
Method Summary
 long advanceTime(long amount, TimeUnit unit)
          Advances the clock time in the specified unit amount.
 long getCurrentTime()
          Returns the current time from the scheduler clock
 InternalWorkingMemory getSession()
           
 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)
           
 void readExternal(ObjectInput in)
           
 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 setSession(InternalWorkingMemory session)
           
 void setStartupTime(long i)
           
 void setTimerJobFactoryManager(TimerJobFactoryManager timerJobFactoryManager)
           
 void shutdown()
          Shuts the service down
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PseudoClockScheduler

public PseudoClockScheduler()

PseudoClockScheduler

public PseudoClockScheduler(InternalWorkingMemory session)
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

setTimerJobFactoryManager

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

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
See Also:
org.drools.temporal.SessionClock#getCurrentTime()

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:
See Also:
SchedulerService.scheduleJob(org.drools.time.Job, org.drools.time.JobContext, org.drools.time.Trigger)

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:
See Also:
SchedulerService.removeJob(org.drools.time.JobHandle)

advanceTime

public long advanceTime(long amount,
                        TimeUnit unit)
Description copied from interface: SessionPseudoClock
Advances the clock time in the specified unit amount.

Specified by:
advanceTime in interface SessionPseudoClock
Parameters:
amount - the amount of units to advance in the clock
unit - the used time unit
Returns:
the current absolute timestamp

setStartupTime

public void setStartupTime(long i)

getSession

public InternalWorkingMemory getSession()
Returns:
the session

setSession

public void setSession(InternalWorkingMemory session)
Parameters:
session - the session to set

shutdown

public void shutdown()
Shuts the service down

Specified by:
shutdown in interface TimerService

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.