[jbpm-commits] JBoss JBPM SVN: r6824 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/parser and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Nov 14 12:01:38 EST 2010
Author: rebody
Date: 2010-11-14 12:01:38 -0500 (Sun, 14 Nov 2010)
New Revision: 6824
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundarySignalEvent.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/BoundarySignalEventTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_interrupting.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_none_interrupting.bpmn.xml
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
Log:
JBPM-2724 signal end event
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundarySignalEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundarySignalEvent.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundarySignalEvent.java 2010-11-14 17:01:38 UTC (rev 6824)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.api.model.Transition;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.op.AtomicOperation;
+
+/**
+ * boundary escalation event.
+ *
+ * @author Huisheng Xu
+ */
+public class BoundarySignalEvent extends BpmnActivity implements EventListener, BpmnEvent {
+
+ protected String boundarySignalEventActivityName;
+ protected boolean interrupting;
+
+ @SuppressWarnings("unchecked")
+ public void execute(ExecutionImpl execution) {
+ if (interrupting) {
+ ExecutionImpl parent = execution.destroyScope(execution.getActivity());
+ this.executeBoundaryEventBranch(parent);
+ } else {
+ ExecutionImpl parent = execution.getParent();
+ ExecutionImpl childExecution = parent.createExecution();
+ childExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ this.executeBoundaryEventBranch(childExecution);
+ if (execution.getState() != Execution.STATE_INACTIVE_CONCURRENT_ROOT) {
+ this.proceed(execution, this.findOutgoingSequenceFlow(execution, true));
+ } else {
+ ExecutionImpl noneInterruptingExecution = parent.createExecution();
+ this.proceed(noneInterruptingExecution, this.findOutgoingSequenceFlow(noneInterruptingExecution, true));
+ }
+ }
+ }
+
+ protected void executeBoundaryEventBranch(ExecutionImpl execution) {
+ ProcessDefinitionImpl processDefinitionImpl = execution.getProcessDefinition();
+ ActivityImpl activityImpl = processDefinitionImpl.getActivity(boundarySignalEventActivityName);
+ execution.moveTo(activityImpl);
+ execution.take(activityImpl.getOutgoingTransitions().get(0));
+ }
+
+ public void notify(EventListenerExecution execution) {
+ this.execute((ExecutionImpl) execution);
+ }
+
+ public void setBoundarySignalEventActivityName(String boundarySignalEventActivityName) {
+ this.boundarySignalEventActivityName = boundarySignalEventActivityName;
+ }
+
+ public boolean isInterrupting() {
+ return interrupting;
+ }
+
+ public void setInterrupting(boolean interrupting) {
+ this.interrupting = interrupting;
+ }
+
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java 2010-11-14 16:38:29 UTC (rev 6823)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndActivity.java 2010-11-14 17:01:38 UTC (rev 6824)
@@ -50,6 +50,8 @@
protected String escalationCode = null;
+ protected String signalCode = null;
+
public void execute(ActivityExecution execution) {
execute((ExecutionImpl)execution);
}
@@ -76,6 +78,8 @@
parent.fire(errorCode, (ActivityImpl) activity.getParentActivity());
} else if (parent != null && escalationCode != null) {
parent.fire(escalationCode, (ActivityImpl) activity.getParentActivity());
+ } else if (parent != null && signalCode != null) {
+ parent.fire(signalCode, (ActivityImpl) activity.getParentActivity());
} else {
execution.signal();
}
@@ -105,6 +109,10 @@
parent.fire(escalationCode, (ActivityImpl) activity.getParentActivity());
}
+ if (parent != null && signalCode != null) {
+ parent.fire(signalCode, (ActivityImpl) activity.getParentActivity());
+ }
+
// Special case: if during concurrent execution all child executions are ended,
// then the parent execution must be ended too.
if (parent != null && parent.getExecutions().isEmpty()
@@ -130,4 +138,8 @@
public void setEscalationCode(String escalationCode) {
this.escalationCode = escalationCode;
}
+
+ public void setSignalCode(String signalCode) {
+ this.signalCode = signalCode;
+ }
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-11-14 16:38:29 UTC (rev 6823)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-11-14 17:01:38 UTC (rev 6824)
@@ -61,6 +61,11 @@
endActivity.setEscalationCode(XmlUtil.attribute(escalationEventDefinition, "escalationRef"));
}
+ Element signalEventDefinition = XmlUtil.element(element, "signalEventDefinition");
+ if (signalEventDefinition != null) {
+ endActivity.setSignalCode(XmlUtil.attribute(signalEventDefinition, "signalRef"));
+ }
+
return endActivity;
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-11-14 16:38:29 UTC (rev 6823)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-11-14 17:01:38 UTC (rev 6824)
@@ -41,6 +41,7 @@
import org.jbpm.bpmn.flownodes.BpmnActivity;
import org.jbpm.bpmn.flownodes.BoundaryEscalationEvent;
import org.jbpm.bpmn.flownodes.BoundaryErrorEvent;
+import org.jbpm.bpmn.flownodes.BoundarySignalEvent;
import org.jbpm.bpmn.flownodes.BoundaryTimerEvent;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.bpmn.model.SequenceflowCondition;
@@ -279,12 +280,15 @@
Element timerEventDefinition = XmlUtil.element(boundaryEventElement, "timerEventDefinition");
Element errorEventDefinition = XmlUtil.element(boundaryEventElement, "errorEventDefinition");
Element escalationEventDefinition = XmlUtil.element(boundaryEventElement, "escalationEventDefinition");
+ Element signalEventDefinition = XmlUtil.element(boundaryEventElement, "signalEventDefinition");
if (timerEventDefinition != null) {
this.parseBoundaryTimerEventDefinition(timerEventDefinition, interrupting, nestedActivity, refActivity, parse);
} else if (errorEventDefinition != null) {
this.parseBoundaryErrorEventDefinition(errorEventDefinition, nestedActivity, refActivity, parse);
} else if (escalationEventDefinition != null) {
this.parseBoundaryEscalationEventDefinition(escalationEventDefinition, interrupting, nestedActivity, refActivity, parse);
+ } else if (signalEventDefinition != null) {
+ this.parseBoundarySignalEventDefinition(signalEventDefinition, interrupting, nestedActivity, refActivity, parse);
} else {
parse.addProblem("Unsupported boundary event type : " + boundaryEventElement);
}
@@ -341,6 +345,27 @@
escalationActivity.setActivityBehaviour(boundaryEscalationEvent);
}
+ public void parseBoundarySignalEventDefinition(Element signalEventDefinition,
+ boolean interrupting,
+ ActivityImpl signalActivity,
+ ActivityImpl refActivity,
+ Parse parse) {
+
+ BoundarySignalEvent boundarySignalEvent = new BoundarySignalEvent();
+ boundarySignalEvent.setInterrupting(interrupting);
+ boundarySignalEvent.setBoundarySignalEventActivityName(signalActivity.getName());
+
+ String eventName = XmlUtil.attribute(signalEventDefinition, "signalRef");
+
+ EventImpl event = refActivity.getEvent(eventName);
+ if (event == null) {
+ event = refActivity.createEvent(eventName);
+ }
+ EventListenerReference eventListenerReference = event.createEventListenerReference(boundarySignalEvent);
+
+ signalActivity.setActivityBehaviour(boundarySignalEvent);
+ }
+
public void parseBoundaryErrorEventDefinition(Element errorEventDefinition,
ActivityImpl errorActivity,
ActivityImpl refActivity,
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/BoundarySignalEventTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/BoundarySignalEventTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/BoundarySignalEventTest.java 2010-11-14 17:01:38 UTC (rev 6824)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.bpmn.event.error;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Huisheng Xu
+ */
+public class BoundarySignalEventTest extends JbpmTestCase {
+
+ public void testInterruptingSignalBoundaryEvent() {
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/signal/boundary_signal_event_interrupting.bpmn.xml");
+ registerDeployment(deployment.deploy());
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_signal_event");
+ assertProcessInstanceEnded(processInstance);
+
+ HistoryProcessInstance hip = historyService.createHistoryProcessInstanceQuery().uniqueResult();
+ assertNotNull(hip);
+ }
+
+ public void testNoneInterruptingSignalBoundaryEvent() {
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/signal/boundary_signal_event_none_interrupting.bpmn.xml");
+ registerDeployment(deployment.deploy());
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_signal_event");
+ // assertProcessInstanceEnded(processInstance);
+
+ HistoryProcessInstance hip = historyService.createHistoryProcessInstanceQuery().uniqueResult();
+ assertNotNull(hip);
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_interrupting.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_interrupting.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_interrupting.bpmn.xml 2010-11-14 17:01:38 UTC (rev 6824)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
+ xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
+ typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath"
+ targetNamespace="http://jbpm.org/example/bpmn2/boundary_signal_event"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <signal id="MySignal" signalCode="MySignal" />
+
+ <process id="boundary_signal_event" name="Signal Boundary Event Process">
+ <startEvent id="startEvent" name="StartProcess"/>
+ <sequenceFlow id="flow1" sourceRef="startEvent" targetRef="subProcess"/>
+ <subProcess id="subProcess" name="Hello" >
+ <startEvent id="sub-start" name="StartSubProcess"/>
+ <sequenceFlow id="flow2" sourceRef="sub-start" targetRef="sub-parallel"/>
+ <parallelGateway id="sub-parallel" gatewayDirection="Diverging"/>
+ <sequenceFlow id="flow3" sourceRef="sub-parallel" targetRef="sub-error"/>
+ <endEvent id="sub-error" name="SignalEvent">
+ <signalEventDefinition signalRef="MySignal"/>
+ </endEvent>
+ <sequenceFlow id="flow4" sourceRef="sub-parallel" targetRef="sub-task"/>
+ <userTask id="sub-task" name="Task" />
+ <sequenceFlow id="flow5" sourceRef="sub-task" targetRef="sub-end"/>
+ <endEvent id="sub-end" name="EndEvent"/>
+ </subProcess>
+ <sequenceFlow id="flow6" sourceRef="subProcess" targetRef="terminateEnd"/>
+ <endEvent id="terminateEnd" name="EndProcess">
+ <terminateEventDefinition/>
+ </endEvent>
+ <boundaryEvent id="signalEvent" name="SignalEvent" attachedToRef="subProcess" >
+ <signalEventDefinition signalRef="MySignal" />
+ </boundaryEvent>
+ <sequenceFlow id="flow7" sourceRef="signalEvent" targetRef="task"/>
+ <scriptTask id="task" name="Goodbye">
+ <script>System.out.println("Escalation handled");</script>
+ </scriptTask>
+ <sequenceFlow id="flow8" sourceRef="task" targetRef="endEvent"/>
+ <endEvent id="endEvent" name="EndProcess"/>
+ </process>
+</definitions>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_none_interrupting.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_none_interrupting.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/boundary_signal_event_none_interrupting.bpmn.xml 2010-11-14 17:01:38 UTC (rev 6824)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
+ xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
+ typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath"
+ targetNamespace="http://jbpm.org/example/bpmn2/boundary_signal_event"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <signal id="MySignal" signalCode="MySignal" />
+
+ <process id="boundary_signal_event" name="Signal Boundary Event Process">
+ <startEvent id="startEvent" name="StartProcess"/>
+ <sequenceFlow id="flow1" sourceRef="startEvent" targetRef="subProcess"/>
+ <subProcess id="subProcess" name="Hello" >
+ <startEvent id="sub-start" name="StartSubProcess"/>
+ <sequenceFlow id="flow2" sourceRef="sub-start" targetRef="sub-parallel"/>
+ <parallelGateway id="sub-parallel" gatewayDirection="Diverging"/>
+ <sequenceFlow id="flow3" sourceRef="sub-parallel" targetRef="sub-error"/>
+ <endEvent id="sub-error" name="SignalEvent">
+ <signalEventDefinition signalRef="MySignal"/>
+ </endEvent>
+ <sequenceFlow id="flow4" sourceRef="sub-parallel" targetRef="sub-task"/>
+ <userTask id="sub-task" name="Task" />
+ <sequenceFlow id="flow5" sourceRef="sub-task" targetRef="sub-end"/>
+ <endEvent id="sub-end" name="EndEvent"/>
+ </subProcess>
+ <sequenceFlow id="flow6" sourceRef="subProcess" targetRef="terminateEnd"/>
+ <endEvent id="terminateEnd" name="EndProcess">
+ <terminateEventDefinition/>
+ </endEvent>
+ <boundaryEvent id="signalEvent" name="SignalEvent" attachedToRef="subProcess" cancelActivity="false">
+ <signalEventDefinition signalRef="MySignal" />
+ </boundaryEvent>
+ <sequenceFlow id="flow7" sourceRef="signalEvent" targetRef="task"/>
+ <scriptTask id="task" name="Goodbye">
+ <script>System.out.println("Escalation handled");</script>
+ </scriptTask>
+ <sequenceFlow id="flow8" sourceRef="task" targetRef="endEvent"/>
+ <endEvent id="endEvent" name="EndProcess"/>
+ </process>
+</definitions>
More information about the jbpm-commits
mailing list