[jbpm-commits] JBoss JBPM SVN: r1725 - in jbossbpm/spec/trunk/modules: api/src/main/java/org/jboss/bpm/model and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jul 25 08:09:19 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-07-25 08:09:19 -0400 (Fri, 25 Jul 2008)
New Revision: 1725
Added:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilderFactory.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MessageReceiver.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderFactoryImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilderFactory.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Property.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeProcess.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml
Log:
Add MessageReceiver
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ExecutionManager.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -24,12 +24,12 @@
// $Id$
import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.runtime.Attachments;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.HandlerSupport;
-import org.jboss.bpm.runtime.RuntimeProcess;
import org.jboss.bpm.runtime.SignalHandler;
/**
@@ -54,7 +54,7 @@
* @param att The Attachments in the ExecutionContext
* @return The Future from which to obtain the process result
*/
- public abstract void startProcess(RuntimeProcess proc, Attachments att);
+ public abstract void startProcess(Process proc, Attachments att);
/**
* Locate the signal manager
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/client/ProcessManager.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -41,9 +41,12 @@
import org.jboss.bpm.BPMException;
import org.jboss.bpm.EngineShutdownException;
import org.jboss.bpm.ProcessTimeoutException;
+import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Process.Status;
import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.MessageReceiver;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -188,13 +191,28 @@
public abstract void startProcess(String name, Attachments att);
/**
+ * Send a message to a given {@link MessageReceiver}
+ */
+ public void sendMessage(ObjectName procID, String toName, Message msg)
+ {
+ Process proc = getProcessByID(procID);
+ FlowObject target = proc.findFlowObject(toName);
+ if (target == null)
+ throw new IllegalArgumentException("Cannot find message target: " + toName);
+ if (target instanceof MessageReceiver == false)
+ throw new IllegalArgumentException("Message target is not a valid message receiver: " + toName);
+
+ ((MessageReceiver)target).receiveMessage(msg);
+ }
+
+ /**
* Wait for the Process to end. All Tokens that are generated at the Start Event for that Process must eventually
- * arrive at an End Event. The Process will be in a running state until all Tokens are consumed.
+ * arrive at an End Event. The Process will be in a running state until all Tokens are consumed.
+ * <p/>
+ * If the process was aborted this method throws the causing RuntimeException if avaialable.
*
- * @param id
- * @param timeout
*/
- public void waitForEnd(ObjectName id, long timeout)
+ public Status waitForEnd(ObjectName id, long timeout)
{
Process proc = getProcessByID(id);
Status status = proc.getStatus();
@@ -211,10 +229,18 @@
while (forever || now < until)
{
status = proc.getStatus();
- if (status == Status.Cancelled || status == Status.Aborted || status == Status.Completed)
+ if (status == Status.Cancelled || status == Status.Completed)
{
- return;
+ return status;
}
+ else if (status == Status.Aborted)
+ {
+ RuntimeException rte = proc.getRuntimeException();
+ if (rte == null)
+ return status;
+ else
+ throw rte;
+ }
Thread.currentThread().sleep(100);
now = System.currentTimeMillis();
}
@@ -223,8 +249,8 @@
{
log.warn(ex);
}
-
- // Throw timeout exception if it took too long
+
+ // Throw timeout exception if it took too long
throw new ProcessTimeoutException("Process timeout for: " + id);
}
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -45,6 +45,11 @@
List<Property> getProperties();
/**
+ * Get a Property with a given name.
+ */
+ Property getProperty(String name);
+
+ /**
* This defines the source of the Message.
*/
Participant getFromRef();
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,53 @@
+/*
+ * 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.jboss.bpm.model;
+
+//$Id$
+
+/**
+ * A MessageBuilder can be used to build a {@link Message} dynamically.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MessageBuilder
+{
+ /**
+ * Create a {@link Message} with a given name
+ */
+ MessageBuilder newMessage(String name);
+
+ /**
+ * Add a message property
+ */
+ MessageBuilder addMessageProperty(String name, String value);
+
+ /**
+ * Add a message property
+ */
+ MessageBuilder addMessageProperty(String name, String value, boolean isCorrelation);
+
+ /**
+ * Get the Message
+ */
+ Message getMessage();
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilderFactory.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilderFactory.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilderFactory.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,60 @@
+/*
+ * 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.jboss.bpm.model;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.util.KernelLocator;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+
+//$Id$
+
+/**
+ * A Factory for the {@link MessageBuilder}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public abstract class MessageBuilderFactory
+{
+ /** The bean name - jBPMMessageBuilderFactory */
+ public static final String BEAN_NAME = "jBPMMessageBuilderFactory";
+
+ // Hide the constructor
+ protected MessageBuilderFactory()
+ {
+ }
+
+ /**
+ * Get a MessageBuilderFactory instance.
+ */
+ public static MessageBuilderFactory newInstance()
+ {
+ Kernel kernel = KernelLocator.getKernel();
+ KernelRegistryEntry entry = kernel.getRegistry().getEntry(BEAN_NAME);
+ return (MessageBuilderFactory)entry.getTarget();
+ }
+
+ /**
+ * Get a {@link MessageBuilder}.
+ */
+ public abstract MessageBuilder newMessageBuilder();
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilderFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -112,6 +112,11 @@
Process copyProcess();
/**
+ * Get the possible runtime exception when the process was aborted.
+ */
+ RuntimeException getRuntimeException();
+
+ /**
* Get the start event
*/
StartEvent getStartEvent();
@@ -153,4 +158,9 @@
* This method until the process ends with a given timeout.
*/
void waitForEnd(long timeout);
+
+ /**
+ * Send a message to a given @{link Task} or @{link Event}
+ */
+ void sendMessage(String toName, Message msg);
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -42,12 +42,10 @@
ProcessBuilder addProcess(String name);
/**
- * Get the {@link Process}.
- * <p/>
- * This is the final call to the ProcessBuilder after all elements have been added.
+ * Get the {@link Process}. <p/> This is the final call to the ProcessBuilder after all elements have been added.
*/
Process getProcess();
-
+
/**
* Add a {@link SubProcess} with a given name
*/
@@ -79,10 +77,11 @@
ProcessBuilder addEndEvent(String name);
/**
- * Add a None {@link Task} with a given name
+ * Add a {@link Task} with a given name
+ *
* @param type TODO
*/
- ProcessBuilder addTask(String name, TaskType type);
+ TaskBuilder addTask(String name, TaskType type);
/**
* Add an {@link ExclusiveGateway} with a given name
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilderFactory.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilderFactory.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilderFactory.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -35,7 +35,7 @@
*/
public abstract class ProcessBuilderFactory
{
- /** The process engine bean name - jBPMEngine */
+ /** The bean name - jBPMProcessBuilderFactory */
public static final String BEAN_NAME = "jBPMProcessBuilderFactory";
// Hide the constructor
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Property.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Property.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Property.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -32,6 +32,14 @@
public interface Property extends SupportingElement
{
/**
+ * Supported property types
+ */
+ public enum PropertyType
+ {
+ String
+ }
+
+ /**
* Each Property has a Name (e.g., name=”Customer Name”).
*/
String getName();
@@ -40,7 +48,7 @@
* Each Property has a Type (e.g., type=”String”). Properties may be defined
* hierarchically.
*/
- String getType();
+ PropertyType getType();
/**
* Each Property MAY have a Value specified.
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,38 @@
+/*
+ * 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.jboss.bpm.model;
+
+
+//$Id$
+
+/**
+ * The ProcessBuilder can be used to build a {@link Process} dynamically.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface TaskBuilder extends ProcessBuilder
+{
+ TaskBuilder addMessageRef(String name);
+
+ TaskBuilder addMessageProperty(String name, String value, boolean isCorrelation);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MessageReceiver.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MessageReceiver.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MessageReceiver.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,37 @@
+/*
+ * 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.jboss.bpm.runtime;
+
+import org.jboss.bpm.model.Message;
+
+//$Id$
+
+/**
+ * The {@link FlowScheduler} that can be manipulated.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MessageReceiver
+{
+ void receiveMessage(Message message);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/MessageReceiver.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeProcess.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeProcess.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/RuntimeProcess.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -26,10 +26,8 @@
import org.jboss.bpm.model.Process;
/**
- * A RuntimeProcess add runtime behaviour to the {@link Process}
- * <p/>
- * To protect the engine from maligious user code it does not extend
- * {@link Process} directly.
+ * A RuntimeProcess add runtime behaviour to the {@link Process} <p/> To protect the engine from maligious user code it
+ * does not extend {@link Process} directly.
*
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
@@ -37,12 +35,12 @@
public interface RuntimeProcess
{
/**
- * Get the associated {@link Process}
+ * Get the associated {@link Process}
*/
Process getProcess();
-
- /**
- * Get the {@link FlowScheduler} for this {@link Process}
+
+ /**
+ * Get the {@link FlowScheduler} for this {@link Process}
*/
MutableFlowScheduler getFlowScheduler();
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ExecutionManagerImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -32,6 +32,9 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.StartEvent;
+import org.jboss.bpm.model.Process.Status;
+import org.jboss.bpm.model.internal.ProcessImpl;
+import org.jboss.bpm.model.internal.RuntimeProcessImpl;
import org.jboss.bpm.model.internal.SequenceFlowImpl;
import org.jboss.bpm.runtime.Attachments;
import org.jboss.bpm.runtime.ExecutionHandler;
@@ -59,10 +62,25 @@
}
@Override
- public void startProcess(RuntimeProcess rtProc, Attachments att)
+ public void startProcess(Process proc, Attachments att)
{
- Process proc = rtProc.getProcess();
-
+ ProcessImpl procImpl = (ProcessImpl)proc;
+ procImpl.setStatus(Status.Active);
+
+ // Run the process in a thread
+ // TODO: one thread per process is not scalable
+ ProcessRunner runner = new ProcessRunner(procImpl, att);
+ new Thread(runner).start();
+
+ // Throw possible exception from the runner
+ // if (runner.getException() != null)
+ // throw runner.getException();
+ }
+
+ private void startProcessInternal(ProcessImpl proc, Attachments att)
+ {
+ RuntimeProcess rtProc = new RuntimeProcessImpl(proc);
+
throwSignal(new Signal(proc, Signal.Type.ENTER_PROCESS));
MutableFlowScheduler flowScheduler = rtProc.getFlowScheduler();
try
@@ -98,18 +116,25 @@
// Remove the head tuple
flowScheduler.removeHeadTuple();
-
+
// Transfer the token to the FlowHandler
flowHandler.execute(flowScheduler, token);
}
+ proc.setStatus(Status.Completed);
}
+ catch (RuntimeException rte)
+ {
+ log.error("Process aborted: " + proc, rte);
+ proc.setStatus(Status.Aborted);
+ proc.setRuntimeException(rte);
+ }
finally
{
throwSignal(new Signal(proc, Signal.Type.EXIT_PROCESS));
}
}
- /**
+ /**
* The initial flow 'to' the StartEvent
*/
class InitialFlow extends SequenceFlowImpl
@@ -120,4 +145,21 @@
setTargetRef(start);
}
}
+
+ class ProcessRunner implements Runnable
+ {
+ ProcessImpl proc;
+ Attachments att;
+
+ public ProcessRunner(ProcessImpl proc, Attachments att)
+ {
+ this.proc = proc;
+ this.att = att;
+ }
+
+ public void run()
+ {
+ startProcessInternal(proc, att);
+ }
+ }
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/ProcessManagerImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -36,7 +36,6 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Process.Status;
import org.jboss.bpm.model.internal.ProcessImpl;
-import org.jboss.bpm.model.internal.RuntimeProcessImpl;
import org.jboss.bpm.runtime.Attachments;
/**
@@ -49,7 +48,7 @@
{
// provide logging
private static final Log log = LogFactory.getLog(ProcessManagerImpl.class);
-
+
public void setProcessEngine(ProcessEngine engine)
{
this.engine = engine;
@@ -72,42 +71,15 @@
throw new IllegalStateException("Cannot obtain process with name: " + name);
if (procSet.size() > 1)
throw new IllegalStateException("Multiple processes with name: " + name);
-
+
ProcessImpl proc = (ProcessImpl)procSet.iterator().next();
-
+
// Copy and register a copy of the process instance
Process procCopy = (ProcessImpl)proc.copyProcess();
registerProcess(procCopy);
-
+
// Start the process in a thread
- proc.setStatus(Status.Active);
- new Thread(new ProcessRunner(proc, att)).start();
+ ExecutionManager exm = ExecutionManager.locateExecutionManager();
+ exm.startProcess(proc, att);
}
-
- class ProcessRunner implements Runnable
- {
- ProcessImpl proc;
- Attachments att;
-
- public ProcessRunner(ProcessImpl proc, Attachments att)
- {
- this.proc = proc;
- this.att = att;
- }
-
- public void run()
- {
- try
- {
- ExecutionManager exm = ExecutionManager.locateExecutionManager();
- exm.startProcess(new RuntimeProcessImpl(proc), att);
- proc.setStatus(Status.Completed);
- }
- catch (RuntimeException rte)
- {
- log.error("Process aborted: " + proc, rte);
- proc.setStatus(Status.Aborted);
- }
- }
- }
}
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,54 @@
+/*
+ * 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.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.model.Expression;
+
+/**
+ * An Expression, which is used in the definition of attributes for @{link StartEvent},
+ * @{link IntermediateEvent}, @{link Activity}, @{link ComplexGateway}, and @{link SequenceFlow}
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class ExpressionImpl extends SupportingElementImpl implements Expression
+{
+ private String body;
+
+ public ExpressionImpl(String body)
+ {
+ this.body = body;
+ }
+
+ public String getExpressionBody()
+ {
+ return body;
+ }
+
+ public String getExpressionLanguage()
+ {
+ throw new NotImplementedException();
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderFactoryImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderFactoryImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderFactoryImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,43 @@
+/*
+ * 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.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Message;
+import org.jboss.bpm.model.MessageBuilder;
+import org.jboss.bpm.model.MessageBuilderFactory;
+
+/**
+ * A MessageBuilder can be used to build a {@link Message} dynamically.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class MessageBuilderFactoryImpl extends MessageBuilderFactory
+{
+ @Override
+ public MessageBuilder newMessageBuilder()
+ {
+ return new MessageBuilderImpl();
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,65 @@
+/*
+ * 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.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Message;
+import org.jboss.bpm.model.MessageBuilder;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Property;
+
+/**
+ * The ProcessBuilder can be used to dynamically build a {@link Process}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class MessageBuilderImpl implements MessageBuilder
+{
+ private MessageImpl message;
+
+ public MessageBuilder newMessage(String name)
+ {
+ message = new MessageImpl(name);
+ return this;
+ }
+
+ public MessageBuilder addMessageProperty(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value));
+ message.addProperty(prop);
+ return this;
+ }
+
+ public MessageBuilder addMessageProperty(String name, String value, boolean isCorrelation)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value), isCorrelation);
+ message.addProperty(prop);
+ return this;
+ }
+
+ public Message getMessage()
+ {
+ return message;
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -21,6 +21,7 @@
*/
package org.jboss.bpm.model.internal;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -42,8 +43,13 @@
public class MessageImpl extends SupportingElementImpl implements Message
{
private String name;
- private List<Property> props;
+ private List<Property> props = new ArrayList<Property>();
+ public MessageImpl(String name)
+ {
+ this.name = name;
+ }
+
/**
* Name is an attribute that is text description of the Message.
*/
@@ -53,6 +59,19 @@
}
/**
+ * Get a Property with a given name.
+ */
+ public Property getProperty(String name)
+ {
+ for (Property prop : props)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ /**
* Multiple Properties MAY entered for the Message.
*/
public List<Property> getProperties()
@@ -61,6 +80,14 @@
}
/**
+ * Add a property
+ */
+ public void addProperty(Property prop)
+ {
+ props.add(prop);
+ }
+
+ /**
* This defines the source of the Message.
*/
public Participant getFromRef()
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -26,6 +26,7 @@
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
+import org.jboss.bpm.model.TaskBuilder;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
@@ -39,9 +40,19 @@
*/
public class ProcessBuilderImpl implements ProcessBuilder
{
- private ProcessImpl proc;
- private FlowObjectImpl flowObject;
+ protected ProcessImpl proc;
+ protected FlowObjectImpl flowObject;
+ public ProcessBuilderImpl()
+ {
+ }
+
+ protected ProcessBuilderImpl(ProcessImpl proc, FlowObjectImpl flowObject)
+ {
+ this.proc = proc;
+ this.flowObject = flowObject;
+ }
+
public ProcessBuilder addProcess(String procName)
{
proc = new ProcessImpl(procName);
@@ -123,7 +134,7 @@
return this;
}
- public ProcessBuilder addTask(String name, TaskType type)
+ public TaskBuilder addTask(String name, TaskType type)
{
if (type == TaskType.None)
{
@@ -138,7 +149,7 @@
throw new NotImplementedException("Task type: " + type);
}
addFlowObject();
- return this;
+ return new TaskBuilderImpl(proc, flowObject);
}
public ProcessBuilder addExclusiveDataBasedGateway(String name)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -37,6 +37,7 @@
import org.jboss.bpm.model.EndEvent;
import org.jboss.bpm.model.FlowObject;
import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.NameSupport;
import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Process;
@@ -52,9 +53,14 @@
*/
public class ProcessImpl extends SupportingElementImpl implements Process
{
+ // The required process name
private String name;
+ // The list of associated flow objects
private List<FlowObject> flowObjects = new ArrayList<FlowObject>();
+ // the status of the process
private Status status = Status.None;
+ // The possible exception that caused the process to abort
+ private RuntimeException runtimeException;
public ProcessImpl(String name)
{
@@ -102,6 +108,16 @@
flowObjects.add(flowObject);
}
+ public RuntimeException getRuntimeException()
+ {
+ return runtimeException;
+ }
+
+ public void setRuntimeException(RuntimeException rte)
+ {
+ this.runtimeException = rte;
+ }
+
public StartEventImpl getStartEvent()
{
StartEventImpl start = null;
@@ -214,6 +230,12 @@
this.status = status;
}
+ public void sendMessage(String toName, Message msg)
+ {
+ ProcessManager pm = ProcessManager.locateProcessManager();
+ pm.sendMessage(getID(), toName, msg);
+ }
+
/**
* Set the process state
*/
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -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.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.Property;
+
+/**
+ * A Property, which is used in the definition of attributes for a Process and common activity attributes
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class PropertyImpl extends SupportingElementImpl implements Property
+{
+ private String name;
+ private Expression expression;
+ private boolean isCorrelation;
+
+ public PropertyImpl(String name, Expression expression)
+ {
+ this.expression = expression;
+ this.name = name;
+ }
+
+ public PropertyImpl(String name, Expression expression, boolean isCorrelation)
+ {
+ this.name = name;
+ this.expression = expression;
+ this.isCorrelation = isCorrelation;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public PropertyType getType()
+ {
+ return PropertyType.String;
+ }
+
+ public Expression getValue()
+ {
+ return expression;
+ }
+
+ public void setExpression(Expression expression)
+ {
+ this.expression = expression;
+ }
+
+ public boolean isCorrelation()
+ {
+ return isCorrelation;
+ }
+
+ public void setCorrelation(boolean isCorrelation)
+ {
+ this.isCorrelation = isCorrelation;
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/PropertyImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -21,13 +21,21 @@
*/
package org.jboss.bpm.model.internal;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.InvalidProcessException;
import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.ProcessTimeoutException;
+import org.jboss.bpm.model.Expression;
import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.ReceiveTask;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.MessageReceiver;
+import org.jboss.bpm.runtime.Token;
-
//$Id$
/**
@@ -36,17 +44,23 @@
* @author thomas.diesler at jboss.com
* @since 08-Jul-2008
*/
-public class ReceiveTaskImpl extends TaskImpl implements ReceiveTask
+public class ReceiveTaskImpl extends TaskImpl implements ReceiveTask, MessageReceiver
{
+ private static final int RECEIVE_TIMEOUT = 5000;
+
+ // provide logging
+ private static final Log log = LogFactory.getLog(ReceiveTaskImpl.class);
+
// A Web service is the default technology
private Implementation implementation = Implementation.WebService;
private Message messageRef;
-
+ private Message receivedMessage;
+
public ReceiveTaskImpl(String name)
{
super(name);
}
-
+
@Override
public TaskType getTaskType()
{
@@ -73,11 +87,76 @@
throw new NotImplementedException();
}
+ public void receiveMessage(Message message)
+ {
+ String msgName = message.getName();
+ if (messageRef.getName().equals(msgName))
+ {
+ for (Property prop : messageRef.getProperties())
+ {
+ String name = prop.getName();
+ if (message.getProperty(name) == null)
+ throw new IllegalArgumentException("Received message does not contain expected property: " + name);
+ }
+ this.receivedMessage = message;
+ }
+ else
+ {
+ log.debug("Ignore unexpected message: " + message);
+ }
+ }
+
@Override
+ public ExecutionHandler getExecutionHandler()
+ {
+ final ReceiveTask task = this;
+ ExecutionHandler handler = executionHandler;
+ if (handler == null)
+ {
+ handler = new ExecutionHandler()
+ {
+ public void execute(Token token)
+ {
+ // Wait for the message to arrive
+ long now = System.currentTimeMillis();
+ long until = now + RECEIVE_TIMEOUT;
+ while (receivedMessage == null && now < until)
+ {
+ try
+ {
+ Thread.currentThread().sleep(500);
+ now = System.currentTimeMillis();
+ }
+ catch (InterruptedException ex)
+ {
+ log.error("ReceiveTask interrupted" + ex.toString());
+ }
+ }
+
+ // Timeout if the message did not arrive
+ if (receivedMessage == null)
+ throw new ProcessTimeoutException("Message receive timeout in: " + task);
+
+ // Copy the expected properties from the
+ // received message to the execution context
+ ExecutionContext exContext = token.getExecutionContext();
+ for (Property prop : messageRef.getProperties())
+ {
+ String key = prop.getName();
+ Expression value = receivedMessage.getProperty(key).getValue();
+ exContext.addAttachment(key, value);
+ }
+ }
+ };
+ }
+ return handler;
+ }
+
+ @Override
protected void initialize(Process proc)
{
super.initialize(proc);
-
+
if (messageRef == null)
throw new InvalidProcessException("A Message for the MessageRef attribute MUST be entered");
}
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -0,0 +1,72 @@
+/*
+ * 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.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.Task;
+import org.jboss.bpm.model.TaskBuilder;
+
+/**
+ * The TaskBuilder can be used to dynamically build {@link Task}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 08-Jul-2008
+ */
+public class TaskBuilderImpl extends ProcessBuilderImpl implements TaskBuilder
+{
+ private MessageImpl message;
+
+ public TaskBuilderImpl(ProcessImpl proc, FlowObjectImpl flowObject)
+ {
+ super(proc, flowObject);
+ }
+
+ public TaskBuilder addMessageRef(String name)
+ {
+ message = new MessageImpl(name);
+ if (flowObject instanceof ReceiveTaskImpl)
+ {
+ ((ReceiveTaskImpl)flowObject).setMessageRef(message);
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot add message to: " + flowObject);
+ }
+ return this;
+ }
+
+ public TaskBuilder addMessageProperty(String name, String value, boolean isCorrelation)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value), isCorrelation);
+ message.addProperty(prop);
+ return this;
+ }
+
+ private Task getTask()
+ {
+ if (flowObject instanceof Task == false)
+ throw new IllegalStateException("Last added flow object is not a Task");
+ return (Task)flowObject;
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -56,9 +56,10 @@
// provide logging
private static final Log log = LogFactory.getLog(TaskImpl.class);
+ protected ExecutionHandler executionHandler;
+
private Flow inFlow;
private Flow outFlow;
- private ExecutionHandler executionHandler;
private FlowHandler flowHandler;
private SignalHandler signalHandler;
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 12:09:19 UTC (rev 1725)
@@ -26,10 +26,16 @@
import java.net.URL;
import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.client.SignalListener;
+import org.jboss.bpm.client.SignalManager;
+import org.jboss.bpm.model.Message;
+import org.jboss.bpm.model.MessageBuilder;
+import org.jboss.bpm.model.MessageBuilderFactory;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.ProcessBuilderFactory;
-import org.jboss.bpm.model.Task;
+import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.model.TaskBuilder;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.test.DefaultEngineTestCase;
@@ -41,6 +47,23 @@
*/
public class AirticketTest extends DefaultEngineTestCase
{
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Add a signal listener
+ SignalManager sm = SignalManager.locateSignalManager();
+ SignalListener sl = new SignalListener()
+ {
+ public void catchSignal(Signal signal)
+ {
+ System.out.println(signal);
+ }
+ };
+ sm.addListener("Airticket", sl);
+ }
+
public void _testProcessStart() throws Exception
{
URL jpdlURL = getResourceURL("samples/airticket/airticket.bpmn");
@@ -56,17 +79,41 @@
public void testDynamicProcess() throws Exception
{
+ ProcessBuilderFactory procFactory = ProcessBuilderFactory.newInstance();
+ MessageBuilderFactory msgFactory = MessageBuilderFactory.newInstance();
+
// Create a Process through the ProcessBuilder
- ProcessBuilderFactory factory = ProcessBuilderFactory.newInstance();
- ProcessBuilder procBuilder = factory.newProcessBuilder();
- Process proc = procBuilder.addProcess(getName()).addStartEvent().addSequenceFlow("ReceiveReq").addTask("ReceiveReq", TaskType.Receive).
- addSequenceFlow("End").addEndEvent("End").getProcess();
+ ProcessBuilder procBuilder = procFactory.newProcessBuilder();
+ procBuilder.addProcess("Airticket").addStartEvent().addSequenceFlow("ReceiveReq");
+
+ TaskBuilder taskBuilder = procBuilder.addTask("ReceiveReq", TaskType.Receive);
+ taskBuilder.addMessageRef("ReqDataMsg").
+ addMessageProperty("Name", null, true).
+ addMessageProperty("From", null, true).
+ addMessageProperty("To", null, true).
+ addMessageProperty("Date", null, true).
+ addMessageProperty("Seats", null, true).
+ addSequenceFlow("End");
+
+ Process proc = procBuilder.addEndEvent("End").getProcess();
// Register the Process with the ProcessManager
ProcessManager pm = ProcessManager.locateProcessManager();
pm.registerProcess(proc);
proc.startProcess();
+
+ MessageBuilder msgBuilder = msgFactory.newMessageBuilder();
+ Message msg = msgBuilder.newMessage("ReqDataMsg").
+ addMessageProperty("Name", "Kermit").
+ addMessageProperty("From", "MUC").
+ addMessageProperty("To", "NYC").
+ addMessageProperty("Date", "25-Jul-2008").
+ addMessageProperty("Seats", "1").
+ getMessage();
+
+ proc.sendMessage("ReceiveReq", msg);
+
proc.waitForEnd();
}
}
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml 2008-07-25 11:20:30 UTC (rev 1724)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/resources/jbpm-beans.xml 2008-07-25 12:09:19 UTC (rev 1725)
@@ -10,8 +10,9 @@
<property name="signalManager"><inject bean="jBPMSignalManager"/></property>
</bean>
- <!-- The ProcessBuilderFactory -->
+ <!-- The Builder Factories -->
<bean name="jBPMProcessBuilderFactory" class="org.jboss.bpm.model.internal.ProcessBuilderFactoryImpl"/>
+ <bean name="jBPMMessageBuilderFactory" class="org.jboss.bpm.model.internal.MessageBuilderFactoryImpl"/>
<!-- The ProcessManager -->
<bean name="jBPMProcessManager" class="org.jboss.bpm.client.internal.ProcessManagerImpl">
More information about the jbpm-commits
mailing list