Package org.drools.process.instance.timer

Examples of org.drools.process.instance.timer.TimerInstance


      }
    }
  }
 
    protected TimerInstance createTimerInstance(Timer timer) {
      TimerInstance timerInstance = new TimerInstance();
      timerInstance.setDelay(TimeUtils.parseTimeString(timer.getDelay()));
      if (timer.getPeriod() == null) {
        timerInstance.setPeriod(0);
      } else {
        timerInstance.setPeriod(TimeUtils.parseTimeString(timer.getPeriod()));
      }
      timerInstance.setTimerId(timer.getId());
      return timerInstance;
    }
View Full Code Here


      return timerInstance;
    }

    public void signalEvent(String type, Object event) {
      if ("timerTriggered".equals(type)) {
        TimerInstance timerInstance = (TimerInstance) event;
            if (timerInstances.contains(timerInstance.getId())) {
                triggerTimer(timerInstance);
            }
      }
    }
View Full Code Here

    public void internalTrigger(NodeInstance from, String type) {
        if (!org.drools.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
            throw new IllegalArgumentException(
                "A TimerNode only accepts default incoming connections!");
        }
        TimerInstance timer = createTimerInstance();
        if (getTimerInstances() == null) {
          addTimerListener();
        }
        ((ProcessInstance) getProcessInstance()).getWorkingMemory().getTimerManager()
            .registerTimer(timer, (ProcessInstance) getProcessInstance());
        timerId = timer.getId();
    }
View Full Code Here

        timerId = timer.getId();
    }
   
    protected TimerInstance createTimerInstance() {
      Timer timer = getTimerNode().getTimer();
      TimerInstance timerInstance = new TimerInstance();
      timerInstance.setDelay(TimeUtils.parseTimeString(timer.getDelay()));
      if (timer.getPeriod() == null) {
        timerInstance.setPeriod(0);
      } else {
        timerInstance.setPeriod(TimeUtils.parseTimeString(timer.getPeriod()));
      }
      timerInstance.setTimerId(timer.getId());
      return timerInstance;
    }
View Full Code Here

      return timerInstance;
    }

    public void signalEvent(String type, Object event) {
      if ("timerTriggered".equals(type)) {
        TimerInstance timer = (TimerInstance) event;
            if (timer.getId() == timerId) {
                triggerCompleted(timer.getPeriod() == 0);
            }
      }
    }
View Full Code Here

        // still need to think on how to fix this.
//        TimerService service = (TimerService) stream.readObject();
//        timerManager.setTimerService( service );

        while ( stream.readShort() == PersisterEnums.TIMER ) {
            TimerInstance timer = readTimer( context );
            timerManager.internalAddTimer( timer );
        }
    }
View Full Code Here

    }

    public static TimerInstance readTimer(MarshallerReaderContext context) throws IOException {
        ObjectInputStream stream = context.stream;

        TimerInstance timer = new TimerInstance();
        timer.setId( stream.readLong() );
        timer.setTimerId( stream.readLong() );
        timer.setDelay( stream.readLong() );
        timer.setPeriod( stream.readLong() );
        timer.setProcessInstanceId( stream.readLong() );
        timer.setActivated( new Date( stream.readLong() ) );
        if ( stream.readBoolean() ) {
            timer.setLastTriggered( new Date( stream.readLong() ) );
        }
        return timer;
    }
View Full Code Here

  public void executeAction(Action action, ExecutionContext executionContext) {
      if (action instanceof CreateTimerAction) {
          CreateTimerAction createTimerAction = (CreateTimerAction) action;
          String timerName = createTimerAction.getTimerName();
          TimerInstance timer = new TimerInstance();
          long delay = BUSINESS_CALENDAR.add(new Date(0),
                new Duration(createTimerAction.getDueDate())).getTime();
            timer.setDelay(delay);
            if (createTimerAction.getRepeat() != null) {
                long period = BUSINESS_CALENDAR.add(new Date(0),
                    new Duration(createTimerAction.getRepeat())).getTime();
                timer.setPeriod(period);
            }
          if (timerActions.isEmpty()) {
              addTimerListener();
          }
          getProcessInstance().getWorkingMemory().getTimerManager()
              .registerTimer(timer, getProcessInstance());
          timerActions.put(timer.getId(), createTimerAction.getTimerAction());
          List<TimerInstance> timerList = timers.get(timerName);
          if (timerList == null) {
              timerList = new ArrayList<TimerInstance>();
              timers.put(timerName, timerList);
          }
          timerList.add(timer);
      } else if (action instanceof CancelTimerAction) {
          String timerName = ((CancelTimerAction) action).getTimerName();
          List<TimerInstance> timerList = timers.get(timerName);
          if (timerList != null) {
              for (TimerInstance timer: timerList) {
                  timerActions.remove(timer.getId());
                  getProcessInstance().getWorkingMemory().getTimerManager()
                      .cancelTimer(timer.getId());
              }
                timers.remove(timerName);
                if (timerActions.isEmpty()) {
                    removeTimerListener();
                }
View Full Code Here

      return new String[] { "timerTriggered" };
    }
   
    public void signalEvent(String type, Object event) {
      if ("timerTriggered".equals(type)) {
        TimerInstance timer = (TimerInstance) event;
            Action action = timerActions.get(timer.getId());
            if (action != null) {
                executeAction(action, new JpdlExecutionContext());
            }
      }
    }
View Full Code Here

        // still need to think on how to fix this.
//        TimerService service = (TimerService) stream.readObject();
//        timerManager.setTimerService( service );

        while ( stream.readShort() == PersisterEnums.TIMER ) {
            TimerInstance timer = readTimer( context );
            timerManager.internalAddTimer( timer );
        }
    }
View Full Code Here

TOP

Related Classes of org.drools.process.instance.timer.TimerInstance

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.