[jbpm-commits] JBoss JBPM SVN: r1901 - in jbossbpm/spec/trunk/modules: api/src/main/java/org/jboss/bpm/runtime and 8 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Aug 15 08:40:20 EDT 2008
Author: thomas.diesler at jboss.com
Date: 2008-08-15 08:40:19 -0400 (Fri, 15 Aug 2008)
New Revision: 1901
Added:
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/DelegatingExecutionContext.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyMarshallerTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyMarshallerTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyTest.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.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/runtime/Attachments.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java
jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessMarshaller.java
jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java
jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBActivity.java
jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBProcess.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/RunnableToken.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.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/SendTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/TokenImpl.java
Log:
Add Activity/Process properties
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -57,4 +57,9 @@
* Add an IORule {@link Expression}
*/
ActivityBuilder addIORule(String body, ExpressionLanguage lang);
+
+ /**
+ * Add an activity property
+ */
+ ActivityBuilder addProperty(String name, String value);
}
\ 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-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -111,6 +111,11 @@
MessageBuilder addMessage(String name);
/**
+ * Add a process property
+ */
+ ProcessBuilder addProperty(String name, String value);
+
+ /**
* Add an {@link ExecutionHandler} with a given Class
*/
ProcessBuilder addExecutionHandler(Class<?> clazz);
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Attachments.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Attachments.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/Attachments.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -43,7 +43,7 @@
<T> T addAttachment(Class<T> clazz, String name, Object value);
/** Add arbitrary attachment with name */
- <T> T addAttachment(String name, Object value);
+ Object addAttachment(String name, Object value);
/** Get an arbitrary attachment */
<T> T getAttachment(Class<T> clazz);
@@ -52,7 +52,7 @@
<T> T getAttachment(Class<T> clazz, String name);
/** Get an arbitrary attachment */
- <T> T getAttachment(String name);
+ Object getAttachment(String name);
/** Remove arbitrary attachments */
<T> T removeAttachment(Class<T> clazz);
@@ -61,7 +61,7 @@
<T> T removeAttachment(Class<T> clazz, String name);
/** Remove arbitrary attachments */
- <T> T removeAttachment(String name);
+ Object removeAttachment(String name);
/**
* A key for attachements
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/runtime/BasicAttachments.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -75,10 +75,9 @@
return (T)attachments.get(new Key(clazz, name));
}
- @SuppressWarnings("unchecked")
- public <T> T getAttachment(String name)
+ public Object getAttachment(String name)
{
- return (T)attachments.get(new Key(null, name));
+ return attachments.get(new Key(null, name));
}
@SuppressWarnings("unchecked")
@@ -93,10 +92,9 @@
return (T)attachments.put(new Key(clazz, name), obj);
}
- @SuppressWarnings("unchecked")
- public <T> T addAttachment(String name, Object obj)
+ public Object addAttachment(String name, Object obj)
{
- return (T)attachments.put(new Key(null, name), obj);
+ return attachments.put(new Key(null, name), obj);
}
@SuppressWarnings("unchecked")
@@ -111,10 +109,9 @@
return (T)attachments.remove(new Key(clazz, name));
}
- @SuppressWarnings("unchecked")
- public <T> T removeAttachment(String name)
+ public Object removeAttachment(String name)
{
- return (T)attachments.remove(new Key(null, name));
+ return attachments.remove(new Key(null, name));
}
public String toString()
Modified: jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessMarshaller.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessMarshaller.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessMarshaller.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -117,6 +117,11 @@
JAXBMessage jaxbMsg = adaptMessage(jaxbProc, msg);
jaxbProc.getMessages().add(jaxbMsg);
}
+ for (Property prop : proc.getProperties())
+ {
+ JAXBProperty jaxbProp = getJaxbProperty(prop);
+ jaxbProc.getProperties().add(jaxbProp);
+ }
for (FlowObject fo : proc.getFlowObjects())
{
@@ -223,6 +228,11 @@
}
jaxb.getOutputSets().add(jaxbSet);
}
+ for (Property prop : task.getProperties())
+ {
+ JAXBProperty jaxbProp = getJaxbProperty(prop);
+ jaxb.getProperties().add(jaxbProp);
+ }
if (task instanceof ReceiveTask)
{
ReceiveTask recTask = (ReceiveTask)task;
@@ -285,15 +295,15 @@
{
JAXBMessageRef jaxbMsgRef = new JAXBMessageRef();
jaxbMsgRef.setNameRef(msgName);
-
+
String fromStr = getParticipant(msgRef.getFromRef());
if (fromStr != null && fromStr.equals(jaxbMsg.getFromRef()) == false)
jaxbMsgRef.setFromRef(fromStr);
-
+
String toStr = getParticipant(msgRef.getToRef());
if (toStr != null && toStr.equals(jaxbMsg.getToRef()) == false)
jaxbMsgRef.setToRef(toStr);
-
+
jaxb.setMessageRef(jaxbMsgRef);
}
else
Modified: jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -108,6 +108,10 @@
MessageBuilder msgBuilder = procBuilder.addMessage(jaxb.getName());
adaptJAXBMessage(msgBuilder, jaxb);
}
+ for (JAXBProperty jaxbProp : jaxbProc.getProperties())
+ {
+ procBuilder.addProperty(jaxbProp.getName(), jaxbProp.getValue());
+ }
// Process FlowObjects
for (JAXBFlowObject jaxb : jaxbProc.getFlowObjects())
@@ -235,6 +239,10 @@
for (JAXBProperty jaxbProp : jaxbSet.getProperties())
taskBuilder.addPropertyOutput(jaxbProp.getName(), jaxbProp.getValue());
}
+ for (JAXBProperty jaxbProp : jaxb.getProperties())
+ {
+ taskBuilder.addProperty(jaxbProp.getName(), jaxbProp.getValue());
+ }
JAXBSupportingElement jaxbSE = jaxb.getMessageRef();
if (jaxbSE instanceof JAXBMessage)
{
Modified: jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBActivity.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBActivity.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBActivity.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -23,7 +23,11 @@
//$Id$
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@@ -39,7 +43,8 @@
public class JAXBActivity extends JAXBFlowObject
{
private String name;
-
+ private List<JAXBProperty> properties = new ArrayList<JAXBProperty>();
+
public String getName()
{
return name;
@@ -50,4 +55,10 @@
{
this.name = name;
}
+
+ @XmlElement(name = "property")
+ public List<JAXBProperty> getProperties()
+ {
+ return properties;
+ }
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBProcess.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBProcess.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/model/JAXBProcess.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -57,6 +57,8 @@
@XmlElement(name = "end", type = JAXBEndEvent.class) })
private List<JAXBFlowObject> flowObjects = new ArrayList<JAXBFlowObject>();
+ private List<JAXBProperty> properties = new ArrayList<JAXBProperty>();
+
public String getName()
{
return name;
@@ -104,4 +106,10 @@
}
return null;
}
+
+ @XmlElement(name = "property")
+ public List<JAXBProperty> getProperties()
+ {
+ return properties;
+ }
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/RunnableToken.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/RunnableToken.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/client/internal/RunnableToken.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -30,12 +30,14 @@
import org.jboss.bpm.model.Process.ProcessStatus;
import org.jboss.bpm.model.internal.FlowObjectImpl;
import org.jboss.bpm.model.internal.ProcessImpl;
+import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.FlowHandler;
import org.jboss.bpm.runtime.HandlerSupport;
import org.jboss.bpm.runtime.RuntimeProcess;
import org.jboss.bpm.runtime.SignalHandler;
import org.jboss.bpm.runtime.TokenExecutor;
import org.jboss.bpm.runtime.Token.TokenStatus;
+import org.jboss.bpm.runtime.internal.DelegatingExecutionContext;
import org.jboss.bpm.runtime.internal.TokenImpl;
/**
@@ -80,11 +82,11 @@
while (procStatus == ProcessStatus.Active && tokStatus == TokenStatus.Started)
{
flow = token.getFlow();
-
+
// Get the target and its handlers
- FlowObjectImpl target = (FlowObjectImpl)flow.getTargetRef();
- SignalHandler sigHandler = getSignalHandler(target);
- FlowHandler flowHandler = getFlowHandler(target);
+ FlowObjectImpl targetFlowObject = (FlowObjectImpl)flow.getTargetRef();
+ SignalHandler sigHandler = getSignalHandler(targetFlowObject);
+ FlowHandler flowHandler = getFlowHandler(targetFlowObject);
// Synchronize execution of the target and the flow handler
synchronized (rtProc)
@@ -93,15 +95,22 @@
{
// Execute the FlowObject
sigHandler.throwEnterSignal();
- target.execute(token);
-
+
+ // Set the current FlowObject in the ExecutionContext
+ ExecutionContext exContext = token.getExecutionContext();
+ DelegatingExecutionContext delCtx = (DelegatingExecutionContext)exContext;
+ delCtx.setCurrFlowObject(targetFlowObject);
+
+ // Execute the target FlowObject
+ targetFlowObject.execute(token);
+
// Transfer the token to the FlowHandler
flowHandler.execute(tokenExecutor, token);
}
- catch(RuntimeException rte)
+ catch (RuntimeException rte)
{
log.error("Process error", rte);
- target.reset();
+ targetFlowObject.reset();
throw rte;
}
finally
@@ -112,11 +121,11 @@
tokStatus = token.getTokenStatus();
procStatus = procImpl.getProcessStatus();
-
+
// Make sure the next flow is different from the previous one
ConnectingObject nextFlow = token.getFlow();
if (tokStatus == TokenStatus.Started && nextFlow == flow)
- throw new IllegalStateException("Flow handler did not move the token: " + target);
+ throw new IllegalStateException("Flow handler did not move the token: " + targetFlowObject);
}
}
catch (RuntimeException rte)
@@ -127,7 +136,7 @@
}
finally
{
-
+
token.setTokenStatus(TokenStatus.Destroyed);
// Notify the ExecutionManager when a token terminates
synchronized (procImpl)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -79,6 +79,13 @@
return this;
}
+ public ActivityBuilder addProperty(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value));
+ getActivity().addProperty(prop);
+ return this;
+ }
+
private ActivityImpl getActivity()
{
if (flowObject instanceof Activity == false)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -210,7 +210,7 @@
for (Property prop : auxSet.getProperties())
{
String name = prop.getName();
- String value = exContext.getAttachment(name);
+ String value = (String)exContext.getAttachment(name);
inputSet.addProperty(new PropertyImpl(name, new ExpressionImpl(value)));
}
break;
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-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -32,6 +32,7 @@
import org.jboss.bpm.model.MessageBuilder;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
+import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.TaskBuilder;
import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
@@ -223,6 +224,13 @@
return msgBuilder;
}
+ public ProcessBuilder addProperty(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value));
+ proc.addProperty(prop);
+ return this;
+ }
+
public ProcessBuilder addExecutionHandler(Class<?> clazz)
{
return addHandler(clazz);
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -111,7 +111,7 @@
for (Property auxProp : messageRef.getProperties())
{
String key = auxProp.getName();
- String value = exContext.getAttachment(key);
+ String value = (String)exContext.getAttachment(key);
if (value == null)
throw new IllegalStateException("Cannot obtain property: " + key);
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/DelegatingExecutionContext.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/DelegatingExecutionContext.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/DelegatingExecutionContext.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -0,0 +1,183 @@
+/*
+ * 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.internal;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.bpm.model.Activity;
+import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.runtime.Attachments;
+import org.jboss.bpm.runtime.BasicAttachments;
+import org.jboss.bpm.runtime.ExecutionContext;
+
+/**
+ * An ExecutionContext that delegates to the current {@link Activity} or {@link Process} for property rerieval.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 15-Aug-2008
+ */
+public class DelegatingExecutionContext implements ExecutionContext
+{
+ private Attachments att;
+ private FlowObject currFlowObject;
+
+ DelegatingExecutionContext(Attachments att)
+ {
+ this.att = new BasicAttachments(att);
+ }
+
+ public FlowObject getCurrFlowObject()
+ {
+ return currFlowObject;
+ }
+
+ public void setCurrFlowObject(FlowObject currFlowObject)
+ {
+ this.currFlowObject = currFlowObject;
+ }
+
+ public Object getAttachment(String name)
+ {
+ Object value = null;
+
+ if (currFlowObject != null)
+ {
+ Process proc = currFlowObject.getProcess();
+ String foName = currFlowObject.getName();
+ String procName = proc.getName();
+
+ String procPrefix = procName + ".";
+ String activityPrefix = procPrefix + foName + ".";
+
+ // Get activity property
+ if (currFlowObject instanceof Activity && name.startsWith(activityPrefix))
+ {
+ Activity activity = (Activity)currFlowObject;
+ String key = name.substring(activityPrefix.length());
+ Property prop = activity.getProperty(key);
+ if (prop != null)
+ {
+ value = prop.getValue().getExpressionBody();
+ }
+ }
+
+ // Get process property
+ else if (name.startsWith(procPrefix))
+ {
+ String key = name.substring(procPrefix.length());
+ Property prop = proc.getProperty(key);
+ if (prop != null)
+ {
+ value = prop.getValue().getExpressionBody();
+ }
+ }
+ }
+
+ // Fallback to execution context
+ if (value == null)
+ {
+ value = att.getAttachment(name);
+ }
+
+ return value;
+ }
+
+ public Collection<Key> getAttachmentKeys()
+ {
+ Collection<Key> keys = new ArrayList<Key>(att.getAttachmentKeys());
+
+ if (currFlowObject != null)
+ {
+ Process proc = currFlowObject.getProcess();
+ String foName = currFlowObject.getName();
+ String procName = proc.getName();
+
+ String procPrefix = procName + ".";
+ String activityPrefix = procPrefix + foName + ".";
+
+ // Add activity property keys
+ if (currFlowObject instanceof Activity)
+ {
+ Activity activity = (Activity)currFlowObject;
+ for (Property prop : activity.getProperties())
+ {
+ Key key = new Key(null, activityPrefix + prop.getName());
+ keys.add(key);
+ }
+ }
+
+ // Add process property keys
+ for (Property prop : proc.getProperties())
+ {
+ Key key = new Key(null, procPrefix + prop.getName());
+ keys.add(key);
+ }
+ }
+
+ return keys;
+ }
+
+ public <T> T getAttachment(Class<T> clazz)
+ {
+ return att.getAttachment(clazz);
+ }
+
+ public <T> T getAttachment(Class<T> clazz, String name)
+ {
+ return att.getAttachment(clazz, name);
+ }
+
+ public <T> T addAttachment(Class<T> clazz, Object value)
+ {
+ return att.addAttachment(clazz, value);
+ }
+
+ public <T> T addAttachment(Class<T> clazz, String name, Object value)
+ {
+ return att.addAttachment(clazz, name, value);
+ }
+
+ public Object addAttachment(String name, Object value)
+ {
+ return att.addAttachment(name, value);
+ }
+
+ public <T> T removeAttachment(Class<T> clazz)
+ {
+ return att.removeAttachment(clazz);
+ }
+
+ public <T> T removeAttachment(Class<T> clazz, String name)
+ {
+ return att.removeAttachment(clazz, name);
+ }
+
+ public Object removeAttachment(String name)
+ {
+ return att.removeAttachment(name);
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/DelegatingExecutionContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/TokenImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/TokenImpl.java 2008-08-15 10:47:27 UTC (rev 1900)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/runtime/internal/TokenImpl.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -28,7 +28,6 @@
import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.runtime.Attachments;
-import org.jboss.bpm.runtime.BasicAttachments;
import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.Token;
import org.jboss.bpm.runtime.Attachments.Key;
@@ -60,7 +59,7 @@
*/
public TokenImpl(Attachments att)
{
- this.context = new InitialContext(att);
+ this.context = new DelegatingExecutionContext(att);
this.id = new UID().toString();
this.status = TokenStatus.Created;
}
@@ -147,12 +146,4 @@
FlowObject fo = (FlowObject)flow.getTargetRef();
return "[fo=" + fo + ",ctx=" + context + "]";
}
-
- static class InitialContext extends BasicAttachments implements ExecutionContext
- {
- InitialContext(Attachments att)
- {
- super(att);
- }
- }
}
\ No newline at end of file
Added: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyMarshallerTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyMarshallerTest.java (rev 0)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyMarshallerTest.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -0,0 +1,57 @@
+/*
+ * 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.cts.activity;
+
+// $Id$
+
+import java.io.StringWriter;
+
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.model.Process;
+
+/**
+ *
+ * An ActivityPropertyTest using the ProcessMarshaller
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Aug-2008
+ */
+public class ActivityPropertyMarshallerTest extends ActivityPropertyTest
+{
+ protected Process getProcess()
+ {
+ Process proc = super.getProcess();
+
+ // Marshall the process to a string
+ StringWriter strwr = new StringWriter();
+ marshallProcess(proc, strwr);
+ String procXML = strwr.toString();
+
+ System.out.println(procXML);
+
+ // Recreate the process from the marshalled process
+ ProcessManager procManager = ProcessManager.locateProcessManager();
+ proc = procManager.createProcess(procXML);
+
+ return proc;
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyMarshallerTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyTest.java (rev 0)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyTest.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -0,0 +1,86 @@
+/*
+ * 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.cts.activity;
+
+// $Id$
+
+import java.util.Collection;
+
+import org.jboss.bpm.model.ActivityBuilder;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.ProcessBuilder;
+import org.jboss.bpm.model.ProcessBuilderFactory;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.Token;
+import org.jboss.bpm.runtime.Attachments.Key;
+import org.jboss.bpm.test.DefaultEngineTestCase;
+
+/**
+ * Modeler-defined Properties MAY be added to an activity. These Properties are "local" to the activity. These
+ * Properties are only for use within the processing of the activity. The fully delineated name of these properties is
+ * "<process name>.<activity name>.<property name>" (e.g., "Add Customer.Review Credit.Status").
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1621
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Aug-2008
+ */
+public class ActivityPropertyTest extends DefaultEngineTestCase
+{
+ public void testActivityProperties() throws Exception
+ {
+ Process proc = getProcess();
+ proc.startProcess();
+ proc.waitForEnd();
+
+ assertEquals("bar", TaskA.attValue);
+
+ assertEquals(1, TaskA.attKeys.size());
+ Key key = TaskA.attKeys.iterator().next();
+ assertEquals("ActivityProperties.TaskA.foo", key.getNamePart());
+ }
+
+ protected Process getProcess()
+ {
+ ProcessBuilder procBuilder = ProcessBuilderFactory.newInstance().newProcessBuilder();
+ procBuilder.addProcess("ActivityProperties").addStartEvent("Start").addSequenceFlow("TaskA");
+ ActivityBuilder activityBuilder = procBuilder.addTask("TaskA").addExecutionHandler(TaskA.class);
+ activityBuilder.addProperty("foo", "bar");
+ procBuilder.addSequenceFlow("End").addEndEvent("End");
+ Process proc = procBuilder.getProcess();
+ return proc;
+ }
+
+ @SuppressWarnings("serial")
+ public static class TaskA implements ExecutionHandler
+ {
+ static Object attValue;
+ static Collection<Key> attKeys;
+ public void execute(Token token)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+ attValue = exContext.getAttachment("ActivityProperties.TaskA.foo");
+ attKeys = exContext.getAttachmentKeys();
+ }
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/activity/ActivityPropertyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyMarshallerTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyMarshallerTest.java (rev 0)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyMarshallerTest.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -0,0 +1,57 @@
+/*
+ * 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.cts.process;
+
+// $Id$
+
+import java.io.StringWriter;
+
+import org.jboss.bpm.client.ProcessManager;
+import org.jboss.bpm.model.Process;
+
+/**
+ *
+ * An ProcessPropertyTest using the ProcessMarshaller
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Aug-2008
+ */
+public class ProcessPropertyMarshallerTest extends ProcessPropertyTest
+{
+ protected Process getProcess()
+ {
+ Process proc = super.getProcess();
+
+ // Marshall the process to a string
+ StringWriter strwr = new StringWriter();
+ marshallProcess(proc, strwr);
+ String procXML = strwr.toString();
+
+ System.out.println(procXML);
+
+ // Recreate the process from the marshalled process
+ ProcessManager procManager = ProcessManager.locateProcessManager();
+ proc = procManager.createProcess(procXML);
+
+ return proc;
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyMarshallerTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyTest.java (rev 0)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyTest.java 2008-08-15 12:40:19 UTC (rev 1901)
@@ -0,0 +1,87 @@
+/*
+ * 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.cts.process;
+
+// $Id$
+
+import java.util.Collection;
+
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.ProcessBuilder;
+import org.jboss.bpm.model.ProcessBuilderFactory;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.Token;
+import org.jboss.bpm.runtime.Attachments.Key;
+import org.jboss.bpm.test.DefaultEngineTestCase;
+
+/**
+ * Modeler-defined Properties MAY be added to a Process. These Properties are "local" to the Process. All Tasks,
+ * Sub-Process objects, and Sub-Processes that are embedded SHALL have access to these Properties. The fully delineated
+ * name of these properties are "<process name>.<property name>" (e.g., "Add Customer.Customer Name"). If a process is
+ * embedded within another Process, then the fully delineated name SHALL also be preceded by the Parent Process name for
+ * as many Parents there are until the top level Process.
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1392
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Aug-2008
+ */
+public class ProcessPropertyTest extends DefaultEngineTestCase
+{
+ public void testProcessProperties() throws Exception
+ {
+ Process proc = getProcess();
+ proc.startProcess();
+ proc.waitForEnd();
+
+ assertEquals("bar", TaskA.attValue);
+
+ assertEquals(1, TaskA.attKeys.size());
+ Key key = TaskA.attKeys.iterator().next();
+ assertEquals("ProcessProperties.foo", key.getNamePart());
+ }
+
+ protected Process getProcess()
+ {
+ ProcessBuilder procBuilder = ProcessBuilderFactory.newInstance().newProcessBuilder();
+ procBuilder.addProcess("ProcessProperties").addStartEvent("Start").addSequenceFlow("TaskA");
+ procBuilder.addProperty("foo", "bar").addTask("TaskA").addExecutionHandler(TaskA.class);
+ procBuilder.addSequenceFlow("End").addEndEvent("End");
+ Process proc = procBuilder.getProcess();
+ return proc;
+ }
+
+ @SuppressWarnings("serial")
+ public static class TaskA implements ExecutionHandler
+ {
+ static Object attValue;
+ static Collection<Key> attKeys;
+
+ public void execute(Token token)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+ attValue = exContext.getAttachment("ProcessProperties.foo");
+ attKeys = exContext.getAttachmentKeys();
+ }
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/cts/process/ProcessPropertyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jbpm-commits
mailing list