Add the given {@link org.quartz.JobDetail} to the Scheduler, and associate the given {@link Trigger} with it.
{@link org.quartz.JobDetail}
{@link Trigger}
If the given Trigger does not reference any Job, then it will be set to reference the Job passed with it into this method.
Job
676677678679680681682683684685686
TimerService clock = inCtx.wm.getTimerService(); JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction(factHandle, otn), inCtx.wm ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( _expire.getNextFireTimestamp(), null, null ) ); jobctx.setJobHandle( handle );
2223242526272829303132
public void testSingleExecutionJob() throws Exception { TimerService timeService = TimerServiceFactory.getTimerService( ClockType.REALTIME_CLOCK ); Trigger trigger = new DelayedTrigger( 100 ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 500 ); assertEquals( 1, ctx.getList().size() ); } public void testRepeatedExecutionJob() throws Exception {
3132333435363738394041
public void testRepeatedExecutionJob() throws Exception { TimerService timeService = TimerServiceFactory.getTimerService( ClockType.REALTIME_CLOCK ); Trigger trigger = new DelayedTrigger( new long[] { 100, 100, 100} ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 500 ); assertEquals( 3, ctx.getList().size() ); }
4344454647484950515253
public void testRepeatedExecutionJobWithRemove() throws Exception { TimerService timeService = TimerServiceFactory.getTimerService( ClockType.REALTIME_CLOCK ); Trigger trigger = new DelayedTrigger( new long[] { 100, 100, 100, 100, 100 } ); HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService); ctx.setLimit( 3 ); timeService.scheduleJob( new HelloWorldJob(), ctx, trigger); Thread.sleep( 1000 ); assertEquals( 4, ctx.getList().size() ); }
224225226227228229230231232233234
long nextTimestamp = Math.max( clock.getCurrentTime() + this.expirationOffset, ((EventFactHandle) factHandle).getStartTimestamp() + this.expirationOffset ); JobContext jobctx = new ExpireJobContext( expire, workingMemory ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimestamp, null, null ) ); jobctx.setJobHandle( handle );
683684685686687688689690691692693
TimerService clock = inCtx.wm.getTimerService(); JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction(factHandle, otn), inCtx.wm ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimeStamp, null, null ) ); jobctx.setJobHandle( handle );
704705706707708709710711712713714
193194195196197198199200201202203
long nextTimestamp = Math.max( clock.getCurrentTime() + this.expirationOffset, ((EventFactHandle)factHandle).getStartTimestamp() + this.expirationOffset ); JobContext jobctx = new ExpireJobContext( expire, workingMemory ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimestamp ) ); jobctx.setJobHandle( handle ); }
191192193194195196197198199200201
if ( rightTuple != null ) { long nextTimestamp = ((EventFactHandle) rightTuple.getFactHandle()).getStartTimestamp() + this.size; JobContext jobctx = new BehaviorJobContext( workingMemory, this, context ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimestamp ) ); jobctx.setJobHandle( handle ); } }
217218219220221222223224225226227
if ( rightTuple != null ) { long nextTimestamp = ((EventFactHandle) rightTuple.getFactHandle()).getStartTimestamp() + stw.getSize(); JobContext jobctx = new BehaviorJobContext( workingMemory, stw, context ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimestamp, null, null ) ); jobctx.setJobHandle( handle ); } }