Package org.drools.time

Examples of org.drools.time.Trigger


    }   
       
   
  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 );
        timeService.shutdown();
View Full Code Here


     */
    public static void scheduleAgendaItem(final ScheduledAgendaItem item, InternalAgenda agenda, InternalWorkingMemory wm) {
        String[] calendarNames = item.getRule().getCalendars();
        Calendars calendars = wm.getCalendars();
       
        Trigger trigger = item.getRule().getTimer().createTrigger( ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().getCurrentTime(), calendarNames, calendars);
       
        ActivationTimerJob job = new ActivationTimerJob();
        ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda );
               
        JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger );
View Full Code Here

        public void read(MarshallerReaderContext inCtx) throws IOException, ClassNotFoundException {                      
            int leftTupleId = inCtx.readInt();
            LeftTuple leftTuple = inCtx.terminalTupleMap.get( leftTupleId  );
            ScheduledAgendaItem item = ( ScheduledAgendaItem ) leftTuple.getObject();
           
            Trigger trigger = InputMarshaller.readTrigger( inCtx );
           
            DefaultAgenda agenda = ( DefaultAgenda ) inCtx.wm.getAgenda();
            ActivationTimerJob job = new ActivationTimerJob();
            ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda );
                   
View Full Code Here

     */
    public static void scheduleAgendaItem(final ScheduledAgendaItem item, InternalAgenda agenda, InternalWorkingMemory wm) {
        String[] calendarNames = item.getRule().getCalendars();
        Calendars calendars = wm.getCalendars();
       
        Trigger trigger = item.getRule().getTimer().createTrigger( ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().getCurrentTime(), calendarNames, calendars);
       
        ActivationTimerJob job = new ActivationTimerJob();
        ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda );
               
        JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger );
View Full Code Here

    @Test
    public void testSingleExecutionJob() throws Exception {
        SessionConfiguration config = new SessionConfiguration();
        config.setClockType(ClockType.REALTIME_CLOCK);
        TimerService timeService = TimerServiceFactory.getTimerService( config );
        Trigger trigger = new DelayedTrigger( 100 );
        HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService);
        timeService.scheduleJob( new HelloWorldJob(), ctx,  trigger);
        Thread.sleep( 500 );
        timeService.shutdown();
        assertEquals( 1, ctx.getList().size() );
View Full Code Here

    @Test
    public void testRepeatedExecutionJob() throws Exception {
        SessionConfiguration config = new SessionConfiguration();
        config.setClockType(ClockType.REALTIME_CLOCK);
        TimerService timeService = TimerServiceFactory.getTimerService( config );
        Trigger trigger = new DelayedTriggernew long[] { 100, 100, 100} );
        HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService);
        timeService.scheduleJob( new HelloWorldJob(), ctx,  trigger);
        Thread.sleep( 500 );
        timeService.shutdown();
        assertEquals( 3, ctx.getList().size() );
View Full Code Here

    @Test
    public void testRepeatedExecutionJobWithRemove() throws Exception {
        SessionConfiguration config = new SessionConfiguration();
        config.setClockType(ClockType.REALTIME_CLOCK);
        TimerService timeService = TimerServiceFactory.getTimerService( config );
        Trigger trigger = new DelayedTriggernew long[] {100, 100, 100, 100, 100, 100, 100, 100} );
        HelloWorldJobContext ctx = new HelloWorldJobContext( "hello world", timeService);
        ctx.setLimit( 3 );
        timeService.scheduleJob( new HelloWorldJob(), ctx,  trigger);
        Thread.sleep( 1000 );
        timeService.shutdown();
View Full Code Here

        CompositeMaxDurationTimer timer = new CompositeMaxDurationTimer();
        timer.addDurationTimer( new DurationTimer( 25 ) );
        timer.addDurationTimer( new DurationTimer( 50 ) );
        timer.addDurationTimer( new DurationTimer( 70 ) );
        Date timestamp = new Date();
        Trigger trigger = timer.createTrigger( timestamp.getTime(), null, null );
       
        assertEquals( new Date( timestamp.getTime() + 70 ), trigger.hasNextFireTime() );
        assertNull( trigger.nextFireTime() );
        assertNull( trigger.hasNextFireTime() );
    }
View Full Code Here

        timer.addDurationTimer( new DurationTimer( 70 ) );
       
        timer.setTimer( new IntervalTimer(null, null, 6, 40, 25) );
        Date timestamp = new Date();       
       
        Trigger trigger = timer.createTrigger( timestamp.getTime(), null, null );
       
        // ignores the first interval timer at 65
        assertEquals( new Date( timestamp.getTime() + 70 ), trigger.hasNextFireTime() );
        assertEquals( new Date( timestamp.getTime() + 90 ), trigger.nextFireTime() );
        assertEquals( new Date( timestamp.getTime() + 115 ), trigger.nextFireTime() );
        assertEquals( new Date( timestamp.getTime() + 140 ), trigger.nextFireTime() );
        assertNull( trigger.nextFireTime() );
        assertNull( trigger.hasNextFireTime() );       
    }   
View Full Code Here

     * @param wm
     *            The working memory session.
     */
    public static void scheduleAgendaItem(final ScheduledAgendaItem item, InternalAgenda agenda, InternalWorkingMemory wm) {

        Trigger trigger = item.getRule().getTimer().createTrigger( item, wm );

        ActivationTimerJob job = new ActivationTimerJob();
        ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda );
               
        JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger );
View Full Code Here

TOP

Related Classes of org.drools.time.Trigger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.