[jbpm-commits] JBoss JBPM SVN: r6834 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/bpmn/event/signal and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Nov 20 22:22:36 EST 2010


Author: rebody
Date: 2010-11-20 22:22:34 -0500 (Sat, 20 Nov 2010)
New Revision: 6834

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/CatchSignalEventTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/catch_signal_event_none_interrupting.bpmn.xml
Modified:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchSignalEvent.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
JBPM-2734 catch signal event

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java	2010-11-18 05:05:16 UTC (rev 6833)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java	2010-11-21 03:22:34 UTC (rev 6834)
@@ -21,9 +21,12 @@
  */
 package org.jbpm.bpmn.flownodes;
 
+import org.jbpm.bpmn.model.BpmnProcessDefinition;
 import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.model.ActivityImpl;
 import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
 import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
 import org.jbpm.pvm.internal.util.XmlUtil;
 import org.jbpm.pvm.internal.xml.Parse;
@@ -34,6 +37,8 @@
  */
 public class IntermediateCatchEventBinding extends BpmnBinding {
 
+  private static final Log log = Log.getLog(IntermediateCatchEventBinding.class.getName());
+
   public IntermediateCatchEventBinding() {
     super("intermediateCatchEvent");
   }
@@ -75,9 +80,26 @@
   protected IntermediateCatchSignalEvent createIntermediateSignalCatchEvent(String catchEventId,
           Element eventDefinitionElement, BpmnParser parser, Parse parse) {
 
+    String eventName = XmlUtil.attribute(eventDefinitionElement, "signalRef");
+    BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
+
     IntermediateCatchSignalEvent intermediateCatchSignalEvent = new IntermediateCatchSignalEvent();
-    intermediateCatchSignalEvent.setSignalCode(XmlUtil.attribute(eventDefinitionElement, "signalCode"));
+    intermediateCatchSignalEvent.setSignalCode(eventName);
+    intermediateCatchSignalEvent.setActivityName(catchEventId);
 
+    BpmnProcessDefinition bpmnProcessDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
+
+    EventImpl event = processDefinition.getEvent(eventName);
+    if (event == null) {
+      event = processDefinition.createEvent(eventName);
+    }
+    EventListenerReference eventListenerReference = event.createEventListenerReference(intermediateCatchSignalEvent);
+    eventListenerReference.setPropagationEnabled(true);
+
+    if (log.isDebugEnabled()) {
+      log.debug("activityId : " + catchEventId + ", event : " + event);
+    }
+
     return intermediateCatchSignalEvent;
   }
 

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchSignalEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchSignalEvent.java	2010-11-18 05:05:16 UTC (rev 6833)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchSignalEvent.java	2010-11-21 03:22:34 UTC (rev 6834)
@@ -21,6 +21,9 @@
  */
 package org.jbpm.bpmn.flownodes;
 
+import java.util.Map;
+
+import org.jbpm.api.Execution;
 import org.jbpm.api.activity.ActivityExecution;
 import org.jbpm.api.listener.EventListener;
 import org.jbpm.api.listener.EventListenerExecution;
@@ -30,12 +33,14 @@
  *
  * @author Huisheng Xu
  */
-public class IntermediateCatchSignalEvent extends BpmnActivity implements EventListener, BpmnEvent {
+public class IntermediateCatchSignalEvent extends BpmnExternalActivity implements EventListener, BpmnEvent {
 
   private static final long serialVersionUID = 1L;
 
   private String signalCode;
 
+  private String activityName;
+
   public void execute(ActivityExecution execution) {
     execute((ExecutionImpl) execution);
   }
@@ -49,12 +54,20 @@
    * The given execution should be continued.
    */
   public void notify(EventListenerExecution execution) throws Exception {
-    ExecutionImpl executionImpl = (ExecutionImpl) execution;
+    Execution processInstance = execution.getProcessInstance();
+    ExecutionImpl executionImpl = (ExecutionImpl) processInstance.findActiveExecutionIn(activityName);
     proceed(executionImpl, findOutgoingSequenceFlow(executionImpl, CONDITIONS_CHECKED));
   }
 
+  public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+  }
+
   public void setSignalCode(String signalCode) {
     this.signalCode = signalCode;
   }
 
+  public void setActivityName(String activityName) {
+    this.activityName = activityName;
+  }
+
 }

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/CatchSignalEventTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/CatchSignalEventTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/signal/CatchSignalEventTest.java	2010-11-21 03:22:34 UTC (rev 6834)
@@ -0,0 +1,45 @@
+/*
+ * 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.signal;
+
+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 CatchSignalEventTest extends JbpmTestCase {
+
+    public void testInterruptingSignalThrowEvent() {
+        NewDeployment deployment = repositoryService.createDeployment();
+        deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/signal/catch_signal_event_none_interrupting.bpmn.xml");
+        registerDeployment(deployment.deploy());
+
+        ProcessInstance processInstance = executionService.startProcessInstanceByKey("catch_signal_event");
+
+        assertEquals(2, taskService.createTaskQuery().list().size());
+    }
+
+}

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/catch_signal_event_none_interrupting.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/catch_signal_event_none_interrupting.bpmn.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/signal/catch_signal_event_none_interrupting.bpmn.xml	2010-11-21 03:22:34 UTC (rev 6834)
@@ -0,0 +1,52 @@
+<?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/catch_signal_event"
+  xmlns:jbpm="http://jbpm.org/bpmn2">
+
+  <signal id="MySignal" name="MySignal" />
+
+  <process id="catch_signal_event" name="Signal Catch Event Process">
+    <startEvent id="startEvent" name="StartProcess"/>
+
+    <sequenceFlow id="flow1" sourceRef="startEvent" targetRef="parallelGatewaySplit"/>
+
+    <parallelGateway id="parallelGatewaySplit" name="Split"
+      gatewayDirection="Diverging"/>
+
+    <sequenceFlow id="flow2" sourceRef="parallelGatewaySplit" targetRef="catchSignal"/>
+
+    <sequenceFlow id="flow3" sourceRef="parallelGatewaySplit" targetRef="throwSignal"/>
+
+    <intermediateCatchEvent id="catchSignal" name="Catch Signal Event">
+      <signalEventDefinition signalRef="MySignal"/>
+    </intermediateCatchEvent>
+
+    <intermediateThrowEvent id="throwSignal" name="Throw Signal Event">
+      <signalEventDefinition signalRef="MySignal"/>
+    </intermediateThrowEvent>
+
+    <sequenceFlow id="flow4" sourceRef="catchSignal" targetRef="subTask1"/>
+
+    <userTask id="subTask1" name="User Task1" />
+
+    <sequenceFlow id="flow5" sourceRef="throwSignal" targetRef="subTask2"/>
+
+    <userTask id="subTask2" name="User Task2" />
+
+    <sequenceFlow id="flow6" sourceRef="subTask1" targetRef="parallelGatewayJoin"/>
+
+    <sequenceFlow id="flow7" sourceRef="subTask2" targetRef="parallelGatewayJoin"/>
+
+    <parallelGateway id="parallelGatewayJoin" name="Join"
+      gatewayDirection="Converging"/>
+
+    <sequenceFlow id="flow8" sourceRef="parallelGatewayJoin" targetRef="endEvent"/>
+
+    <endEvent id="endEvent" name="EndProcess"/>
+  </process>
+</definitions>

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-11-18 05:05:16 UTC (rev 6833)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-11-21 03:22:34 UTC (rev 6834)
@@ -573,6 +573,9 @@
 
   public void fire(String eventName, ObservableElementImpl observableElement,
     AtomicOperation eventCompletedOperation) {
+    if (log.isDebugEnabled()) {
+      log.debug("observableElement : " + observableElement + ", fire event : " + eventName);
+    }
     EventImpl event = findEvent(observableElement, eventName);
     if (event != null) {
       setEvent(event);
@@ -587,12 +590,12 @@
   }
 
   public static EventImpl findEvent(ObservableElementImpl observableElement, String eventName) {
-    if (observableElement==null) {
+    if (observableElement == null) {
       return null;
     }
 
     EventImpl event = observableElement.getEvent(eventName);
-    if (event!=null) {
+    if (event != null) {
       return event;
     }
 



More information about the jbpm-commits mailing list