1 package org.jbpm.bpel.def; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 import org.jbpm.graph.exe.ExecutionContext; 6 import org.jbpm.graph.exe.Token; 7 8 import org.jbpm.bpel.exe.EventInstance; 9 import org.jbpm.bpel.exe.ScopeInstance; 10 import org.jbpm.bpel.exe.state.ActiveState; 11 import org.jbpm.bpel.timer.def.Alarm; 12 import org.jbpm.bpel.timer.def.AlarmListener; 13 14 18 public class AlarmHandler extends ScopeHandler implements AlarmListener { 19 20 public AlarmHandler() { 21 super(); 22 } 23 24 private static final Log log = LogFactory.getLog(AlarmHandler.class); 25 private static final long serialVersionUID = 1L; 26 27 private Alarm alarm; 28 29 public void alarmTriggered(Token token, Alarm alarm) { 30 ScopeInstance scopeInstance = ScopeInstance.get(token); 31 if (!scopeInstance.getState().equals(ActiveState.NORMAL_PROCESSING)) { 32 log.error("Incoming events are only accepted when a scope instance is normally processing"); 33 return; 34 } 35 36 Token child = new Token(token, Scope.EVENT_TOKEN + token.getChildren().size()); 37 EventInstance.create(child); 39 40 execute(new ExecutionContext(child)); 41 } 42 43 public Alarm getAlarm() { 44 return alarm; 45 } 46 47 public void setAlarm(Alarm alarm) { 48 this.alarm = alarm; 49 } 50 } 51 | Popular Tags |