org.drools.time.impl
Class PseudoClockScheduler

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

public class PseudoClockScheduler
extends Object
implements TimerService, SessionPseudoClock, Externalizable

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

See Also:
Serialized Form

Nested Class Summary
static class PseudoClockScheduler.ScheduledJob
          An Scheduled Job class with all fields final to make it multi-thread safe.
 
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()
           
 long getTimeToNextJob()
          Returns the number of time units (usually ms) to the next scheduled job
 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 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

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)

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


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.