[jbpm-commits] JBoss JBPM SVN: r6141 - in jbpm4/trunk: modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity and 10 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jan 27 10:37:13 EST 2010
Author: tom.baeyens at jboss.com
Date: 2010-01-27 10:37:12 -0500 (Wed, 27 Jan 2010)
New Revision: 6141
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Address.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/AssignTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Person.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactoryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/el/
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/pom.xml
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/tx/AbstractTransaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/pom.xml
Log:
JBPM-2653 completed expressions resolving updates for CDI/seam integration for assign activity (didn't yet refactor the existing activities)
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -21,8 +21,11 @@
*/
package org.jbpm.jpdl.internal.activity;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
import org.jbpm.api.model.OpenExecution;
-import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -34,35 +37,49 @@
private static final long serialVersionUID = 1L;
- protected String expression;
- protected String language;
- protected String variableName;
- protected Descriptor valueDescriptor;
+ protected ValueExpression fromValueExpression;
+ protected MethodExpression fromMethodExpression;
+ protected Descriptor fromValueDescriptor;
+ protected String toVariableName;
+ protected ValueExpression toValueExpression;
+
void perform(OpenExecution execution) throws Exception {
Object value = null;
- if (expression!=null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- value = scriptManager.evaluateExpression(expression, language);
+ if (fromValueExpression!=null) {
+ ExecutionImpl executionImpl = (ExecutionImpl) execution;
+ value = executionImpl.resolveElValueExpressionGet(fromValueExpression);
- } else if (valueDescriptor!=null) {
- value = WireContext.create(valueDescriptor);
+ } else if (fromMethodExpression!=null) {
+ ExecutionImpl executionImpl = (ExecutionImpl) execution;
+ value = executionImpl.resolveElMethodExpressionInvoke(fromMethodExpression);
+
+ } else if (fromValueDescriptor!=null) {
+ value = WireContext.create(fromValueDescriptor);
}
- execution.setVariable(variableName, value);
+ if (toVariableName!=null) {
+ execution.setVariable(toVariableName, value);
+ } else {
+ ExecutionImpl executionImpl = (ExecutionImpl) execution;
+ executionImpl.resolveElValueExpressionSet(toValueExpression, value);
+ }
}
- public void setExpression(String expression) {
- this.expression = expression;
+ public void setFromValueExpression(ValueExpression fromValueExpression) {
+ this.fromValueExpression = fromValueExpression;
}
- public void setLanguage(String language) {
- this.language = language;
+ public void setFromMethodExpression(MethodExpression methodExpression) {
+ this.fromMethodExpression = methodExpression;
}
- public void setVariableName(String variableName) {
- this.variableName = variableName;
+ public void setToVariableName(String variableName) {
+ this.toVariableName = variableName;
}
- public void setValueDescriptor(Descriptor valueDescriptor) {
- this.valueDescriptor = valueDescriptor;
+ public void setToValueExpression(ValueExpression toValueExpression) {
+ this.toValueExpression = toValueExpression;
}
+ public void setFromValueDescriptor(Descriptor valueDescriptor) {
+ this.fromValueDescriptor = valueDescriptor;
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -24,6 +24,10 @@
import java.util.List;
import java.util.Set;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -36,7 +40,7 @@
* @author Tom Baeyens
*/
public class AssignBinding extends JpdlBinding {
-
+
public AssignBinding() {
super("assign");
}
@@ -44,16 +48,42 @@
public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
AssignActivity assignActivity = new AssignActivity();
- String variableName = XmlUtil.attribute(element, "var", true, parse);
- assignActivity.setVariableName(variableName);
+ String toVar = XmlUtil.attribute(element, "to-var");
+ String toExpr = XmlUtil.attribute(element, "to-expr");
+ if (toVar!=null) {
+ assignActivity.setToVariableName(toVar);
+ } else if (toExpr!=null) {
+ ValueExpression valueExpression = parser.createValueExpression(toExpr);
+ assignActivity.setToValueExpression(valueExpression);
+ }
- String expression = XmlUtil.attribute(element, "expr");
- if (expression!=null) {
- assignActivity.setExpression(expression);
- assignActivity.setLanguage(XmlUtil.attribute(element, "lang"));
+ String exprText = XmlUtil.attribute(element, "expr");
+ String exprType = XmlUtil.attribute(element, "expr-type");
- } else {
-
+ // if there is an expr specified
+ if (exprText!=null) {
+ // by default, expr is interpreted as a value expression
+ if (exprType==null || "value".equals(exprType)) {
+ try {
+ ValueExpression valueExpression = parser.createValueExpression(exprText);
+ assignActivity.setFromValueExpression(valueExpression);
+
+ // if the expr is not a valid value expr...
+ } catch (ELException e) {
+ // ... and the expr-type was not specified
+ if (exprType==null) {
+ // then try to parse it as a method expression
+ exprType = "method";
+ }
+ }
+ }
+
+ if ("method".equals(exprType)) {
+ MethodExpression methodExpression = parser.createMethodExpression(exprText);
+ assignActivity.setFromMethodExpression(methodExpression);
+ }
+
+ } else { // there is no expr specified
Set<String> descriptorTagNames = JpdlParser.wireParser.getBindings().getTagNames(WireParser.CATEGORY_DESCRIPTOR);
Descriptor valueDescriptor = null;
List<Element> assignContentElements = XmlUtil.elements(element);
@@ -62,11 +92,15 @@
Element assignContentElement = assignContentElements.get(i);
String assignContentElementTagName = XmlUtil.getTagLocalName(assignContentElement);
if (descriptorTagNames.contains(assignContentElementTagName)) {
- valueDescriptor = parser.parseDescriptor(element, parse);
+ valueDescriptor = parser.parseDescriptor(assignContentElement, parse);
}
}
-
- assignActivity.setValueDescriptor(valueDescriptor);
+
+ if (valueDescriptor!=null) {
+ assignActivity.setFromValueDescriptor(valueDescriptor);
+ } else {
+ parse.addProblem("no value for assignment specified. 'assign' must have attribute 'expr' or a wire object element.", element);
+ }
}
return assignActivity;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -31,6 +31,11 @@
import java.util.Set;
import java.util.StringTokenizer;
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityBehaviour;
import org.jbpm.api.listener.EventListener;
@@ -39,6 +44,7 @@
import org.jbpm.jpdl.internal.activity.JpdlBinding;
import org.jbpm.jpdl.internal.activity.MailListener;
import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+import org.jbpm.pvm.internal.el.JbpmElFactory;
import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
import org.jbpm.pvm.internal.email.impl.MailTemplate;
import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
@@ -113,6 +119,9 @@
public static final String CATEGORY_ACTIVITY = "activity";
public static final String CATEGORY_EVENT_LISTENER = "eventlistener";
+ protected ExpressionFactory expressionFactory;
+ protected ELContext elContext;
+
public JpdlParser() {
initialize();
parseBindings();
@@ -732,4 +741,22 @@
public Set<String> getActivityTagNames() {
return getBindings().getTagNames(CATEGORY_ACTIVITY);
}
+
+ public ValueExpression createValueExpression(String expressionText) {
+ initializeExpressionLanguageParsing();
+ return expressionFactory.createValueExpression(elContext, expressionText, Object.class);
+ }
+
+ public MethodExpression createMethodExpression(String expressionText) {
+ initializeExpressionLanguageParsing();
+ return expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
+ }
+
+ protected void initializeExpressionLanguageParsing() {
+ if (elContext==null) {
+ JbpmElFactory jbpmElFactory = JbpmElFactory.getJbpmElFactory();
+ expressionFactory = jbpmElFactory.createExpressionFactory();
+ elContext = jbpmElFactory.createElContext();
+ }
+ }
}
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/pom.xml 2010-01-27 15:37:12 UTC (rev 6141)
@@ -65,10 +65,6 @@
</dependency>
<dependency>
<groupId>juel</groupId>
- <artifactId>juel-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>juel</groupId>
<artifactId>juel-engine</artifactId>
</dependency>
<dependency>
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactory.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactory.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -1,35 +0,0 @@
-/*
- * 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.pvm.internal.el;
-
-import javax.el.ELContext;
-
-import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-
-/**
- * @author Tom Baeyens
- */
-public interface JbpmElContextFactory {
-
- ELContext createElContext();
- ELContext createElContext(ScopeInstanceImpl scopeInstance);
-}
\ No newline at end of file
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactoryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactoryImpl.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactoryImpl.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -1,113 +0,0 @@
-/*
- * 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.pvm.internal.el;
-
-import javax.el.ArrayELResolver;
-import javax.el.BeanELResolver;
-import javax.el.CompositeELResolver;
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.ListELResolver;
-import javax.el.MapELResolver;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class JbpmElContextFactoryImpl implements JbpmElContextFactory {
-
- private static Log log = Log.getLog(JbpmElContextFactoryImpl.class.getName());
-
- Class<?> functionClass = JstlFunction.class;
-
- /** create ElContext used during parsing time */
- public ELContext createElContext() {
- return createCompositeResolver(null);
- }
-
- /** create ElContext used during evaluation time related to an execution */
- public ELContext createElContext(ScopeInstanceImpl scopeInstance) {
- return createCompositeResolver(scopeInstance);
- }
-
- protected ELContext createCompositeResolver(ScopeInstanceImpl scopeInstance) {
- CompositeELResolver compositeELResolver = new CompositeELResolver();
-
- if (scopeInstance!=null) {
- compositeELResolver.add(new JbpmConstantsElResolver(scopeInstance));
- compositeELResolver.add(new JbpmVariableElResolver(scopeInstance));
- }
-
- EnvironmentImpl environment = EnvironmentImpl.getCurrent();
- if (environment!=null) {
- compositeELResolver.add(new JbpmEnvironmentElResolver(environment));
- }
-
- addCdiResolver(compositeELResolver);
-
- addBasicResolvers(compositeELResolver);
-
- FunctionMapper functionMapper = createFunctionMapper();
-
- return createElContext(compositeELResolver, functionMapper);
- }
-
- protected void addCdiResolver(CompositeELResolver compositeELResolver) {
- try {
- InitialContext initialContext = new InitialContext();
- Object object = initialContext.lookup("java:comp/BeanManager");
- if (object!=null) {
- BeanManager beanManager = (BeanManager) object;
- ELResolver cdiResolver = beanManager.getELResolver();
- if (cdiResolver!=null) {
- compositeELResolver.add(cdiResolver);
- log.debug("added cdi el resolver");
- }
- }
- } catch (NamingException e) {
- log.debug("no cdi bean manager available in jndi");
- }
- }
-
- protected void addBasicResolvers(CompositeELResolver compositeELResolver) {
- compositeELResolver.add(new BeanELResolver());
- compositeELResolver.add(new MapELResolver());
- compositeELResolver.add(new ListELResolver());
- compositeELResolver.add(new ArrayELResolver());
- }
-
- protected FunctionMapper createFunctionMapper() {
- return new JbpmFunctionMapper(functionClass);
- }
-
- protected JbpmElContext createElContext(CompositeELResolver compositeELResolver, FunctionMapper functionMapper) {
- return new JbpmElContext(compositeELResolver, functionMapper);
- }
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactory.java (from rev 6133, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactory.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactory.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactory.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -0,0 +1,46 @@
+/*
+ * 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.pvm.internal.el;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JbpmElFactory {
+
+ public static JbpmElFactory getJbpmElFactory() {
+ JbpmElFactory contextFactory = EnvironmentImpl.getFromCurrent(JbpmElFactory.class, false);
+ if (contextFactory==null) {
+ contextFactory = new JbpmElFactoryImpl();
+ }
+ return contextFactory;
+ }
+
+ public abstract ELContext createElContext();
+ public abstract ELContext createElContext(ScopeInstanceImpl scopeInstance);
+ public abstract ExpressionFactory createExpressionFactory();
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java (from rev 6133, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElContextFactoryImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -0,0 +1,135 @@
+/*
+ * 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.pvm.internal.el;
+
+import java.util.Properties;
+
+import javax.el.ArrayELResolver;
+import javax.el.BeanELResolver;
+import javax.el.CompositeELResolver;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.FunctionMapper;
+import javax.el.ListELResolver;
+import javax.el.MapELResolver;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JbpmElFactoryImpl extends JbpmElFactory {
+
+ private static Log log = Log.getLog(JbpmElFactoryImpl.class.getName());
+
+ Class<?> functionClass = JstlFunction.class;
+
+ /** create ElContext used during parsing time */
+ public ELContext createElContext() {
+ return createCompositeResolver(null);
+ }
+
+ /** create ElContext used during evaluation time related to an execution */
+ public ELContext createElContext(ScopeInstanceImpl scopeInstance) {
+ return createCompositeResolver(scopeInstance);
+ }
+
+ protected ELContext createCompositeResolver(ScopeInstanceImpl scopeInstance) {
+ CompositeELResolver compositeELResolver = new CompositeELResolver();
+
+ if (scopeInstance!=null) {
+ compositeELResolver.add(new JbpmConstantsElResolver(scopeInstance));
+ compositeELResolver.add(new JbpmVariableElResolver(scopeInstance));
+ }
+
+ EnvironmentImpl environment = EnvironmentImpl.getCurrent();
+ if (environment!=null) {
+ compositeELResolver.add(new JbpmEnvironmentElResolver(environment));
+ }
+
+ addCdiResolver(compositeELResolver);
+
+ addBasicResolvers(compositeELResolver);
+
+ FunctionMapper functionMapper = createFunctionMapper();
+
+ return createElContext(compositeELResolver, functionMapper);
+ }
+
+ protected void addCdiResolver(CompositeELResolver compositeELResolver) {
+ BeanManager beanManager = getBeanManager();
+ if (beanManager!=null) {
+ ELResolver cdiResolver = beanManager.getELResolver();
+ if (cdiResolver!=null) {
+ compositeELResolver.add(cdiResolver);
+ log.debug("added cdi el resolver");
+ }
+ } else {
+ log.debug("no cdi bean manager available in jndi");
+ }
+ }
+
+ protected BeanManager getBeanManager() {
+ try {
+ InitialContext initialContext = new InitialContext();
+ return (BeanManager) initialContext.lookup("java:comp/BeanManager");
+ } catch (NamingException e) {
+ return null;
+ }
+ }
+
+ public ExpressionFactory createExpressionFactory() {
+ // TODO these ExpressionFactory properties could be integrated in the configuration
+ Properties properties = new Properties();
+ properties.setProperty("javax.el.methodInvocations", "true");
+ ExpressionFactory expressionFactory = ExpressionFactory.newInstance(properties);
+
+ BeanManager beanManager = getBeanManager();
+ if (beanManager!=null) {
+ expressionFactory = beanManager.wrapExpressionFactory(expressionFactory);
+ }
+
+ return expressionFactory;
+ }
+
+ protected void addBasicResolvers(CompositeELResolver compositeELResolver) {
+ compositeELResolver.add(new BeanELResolver());
+ compositeELResolver.add(new MapELResolver());
+ compositeELResolver.add(new ListELResolver());
+ compositeELResolver.add(new ArrayELResolver());
+ }
+
+ protected FunctionMapper createFunctionMapper() {
+ return new JbpmFunctionMapper(functionClass);
+ }
+
+ protected JbpmElContext createElContext(CompositeELResolver compositeELResolver, FunctionMapper functionMapper) {
+ return new JbpmElContext(compositeELResolver, functionMapper);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.model;
+import java.io.PrintWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -54,8 +55,8 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.client.ClientProcessInstance;
-import org.jbpm.pvm.internal.el.JbpmElContextFactory;
-import org.jbpm.pvm.internal.el.JbpmElContextFactoryImpl;
+import org.jbpm.pvm.internal.el.JbpmElFactory;
+import org.jbpm.pvm.internal.el.JbpmElFactoryImpl;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.ExecutionContext;
@@ -86,6 +87,8 @@
import org.jbpm.pvm.internal.util.Priority;
import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
+import de.odysseus.el.TreeValueExpression;
+
/**
* @author Tom Baeyens
*/
@@ -689,22 +692,20 @@
public void resolveElValueExpressionSet(ValueExpression valueExpression, Object value) {
initCachedElContext();
+
+ log.debug("expression: "+valueExpression);
+
valueExpression.setValue((ELContext) cachedElContext, value);
}
- public void resolveElMethodExpressionInvoke(MethodExpression methodExpression) {
+ public Object resolveElMethodExpressionInvoke(MethodExpression methodExpression) {
initCachedElContext();
- Object[] params = new Object[]{};
- // TODO figure out how to resolve the params
- methodExpression.invoke((ELContext) cachedElContext, params);
+ return methodExpression.invoke((ELContext) cachedElContext, null);
}
protected void initCachedElContext() {
if (cachedElContext==null) {
- JbpmElContextFactory contextFactory = EnvironmentImpl.getFromCurrent(JbpmElContextFactory.class, false);
- if (contextFactory==null) {
- contextFactory = new JbpmElContextFactoryImpl();
- }
+ JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
cachedElContext = contextFactory.createElContext(this);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/AbstractTransaction.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/AbstractTransaction.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/AbstractTransaction.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -36,9 +36,18 @@
if (deserializedObjects==null) {
deserializedObjects = new ArrayList<DeserializedObject>();
}
+
+ // if this object was registered before...
+ for (DeserializedObject registeredObject: deserializedObjects) {
+ if (registeredObject.deserializedObject==deserializedObject.deserializedObject) {
+ // ...don't add it to deserializedObjects collection
+ return;
+ }
+ }
+
deserializedObjects.add(deserializedObject);
}
-
+
public void flushDeserializedObjects() {
if (deserializedObjects!=null) {
for (DeserializedObject deserializedObject: deserializedObjects) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -54,6 +54,12 @@
oos.writeObject(o);
oos.flush();
bytes = baos.toByteArray();
+
+ Transaction transaction = EnvironmentImpl.getFromCurrent(Transaction.class, false);
+ if (transaction!=null) {
+ transaction.registerDeserializedObject(new DeserializedObject(o, scopeInstance, (BlobVariable) variable));
+ }
+
} catch (IOException e) {
throw new JbpmException("couldn't serialize '"+o+"'", e);
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2010-01-27 15:37:12 UTC (rev 6141)
@@ -19,6 +19,8 @@
</object>
<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
+ <object class="org.jbpm.pvm.internal.el.JbpmElFactoryImpl" />
<types resource="jbpm.variable.types.xml" />
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Address.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Address.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Address.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -0,0 +1,61 @@
+/*
+ * 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.test.activity.assign;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Address implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ String street;
+ String city;
+ String country;
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Address.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/AssignTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/AssignTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/AssignTest.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -0,0 +1,133 @@
+/*
+ * 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.test.activity.assign;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AssignTest extends JbpmTestCase {
+
+ public void testValueExpressionToVar() {
+ deployJpdlXmlString(
+ "<process name='AssignTest'>" +
+ " <start>" +
+ " <transition to='resolve' />" +
+ " </start>" +
+ " <assign name='resolve' expr='#{person.name}' to-var='result'>" +
+ " <transition to='wait' />" +
+ " </assign>" +
+ " <state name='wait' />" +
+ "</process>"
+ );
+
+ Person person = new Person();
+ person.setName("johndoe");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("person", person);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AssignTest", variables);
+ executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals("johndoe", executionService.getVariable(processInstance.getId(), "result"));
+ }
+
+ public void testMethodExpressionToVar() {
+ deployJpdlXmlString(
+ "<process name='AssignTest'>" +
+ " <start>" +
+ " <transition to='resolve' />" +
+ " </start>" +
+ " <assign name='resolve' expr='#{person.hello()}' to-var='result'>" +
+ " <transition to='wait' />" +
+ " </assign>" +
+ " <state name='wait' />" +
+ "</process>"
+ );
+
+ Person person = new Person();
+ person.setName("johndoe");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("person", person);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AssignTest", variables);
+ executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals("goodby", executionService.getVariable(processInstance.getId(), "result"));
+ }
+
+ public void testMethodWithParameterExpressionToVar() {
+ deployJpdlXmlString(
+ "<process name='AssignTest'>" +
+ " <start>" +
+ " <transition to='resolve' />" +
+ " </start>" +
+ " <assign name='resolve' expr=\"#{person.hello('Joe')}\" to-var='result'>" +
+ " <transition to='wait' />" +
+ " </assign>" +
+ " <state name='wait' />" +
+ "</process>"
+ );
+
+ Person person = new Person();
+ person.setName("johndoe");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("person", person);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AssignTest", variables);
+ executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals("Hi, Joe", executionService.getVariable(processInstance.getId(), "result"));
+ }
+
+ public void testWireObjectToExpression() {
+ deployJpdlXmlString(
+ "<process name='AssignTest'>" +
+ " <start>" +
+ " <transition to='resolve' />" +
+ " </start>" +
+ " <assign name='resolve' to-expr='#{person.address.street}'>" +
+ " <string value='gasthuisstraat' />" +
+ " <transition to='wait' />" +
+ " </assign>" +
+ " <state name='wait' />" +
+ "</process>"
+ );
+
+ Person person = new Person();
+ person.setName("johndoe");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("person", person);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AssignTest", variables);
+ executionService.signalExecutionById(processInstance.getId());
+
+ person = (Person) executionService.getVariable(processInstance.getId(), "person");
+ assertEquals("gasthuisstraat", person.getAddress().getStreet());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/AssignTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Person.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Person.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Person.java 2010-01-27 15:37:12 UTC (rev 6141)
@@ -0,0 +1,69 @@
+/*
+ * 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.test.activity.assign;
+
+import java.io.Serializable;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Person implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ String name;
+ Address address = new Address();
+ String[] emails;
+
+ public String hello() {
+ return "goodby";
+ }
+
+ public String hello(String name) {
+ return "Hi, "+name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+
+ public String[] getEmails() {
+ return emails;
+ }
+
+ public void setEmails(String[] emails) {
+ this.emails = emails;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/assign/Person.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2010-01-27 13:52:27 UTC (rev 6140)
+++ jbpm4/trunk/pom.xml 2010-01-27 15:37:12 UTC (rev 6141)
@@ -62,7 +62,8 @@
<jboss.j2ee.version>4.2.2.GA</jboss.j2ee.version>
<jboss.client.version>5.0.1.GA</jboss.client.version>
<jsr233.version>2.0.5</jsr233.version>
- <juel.version>2.1.0</juel.version>
+ <juel.version>2.2.1</juel.version>
+ <juel.engine.version>2.1.0</juel.engine.version>
<junit.version>3.8.2</junit.version>
<log4j.version>1.2.14</log4j.version>
<mail.version>1.4.1</mail.version>
@@ -238,14 +239,13 @@
<version>${juel.version}</version>
</dependency>
<dependency>
+ <!-- The juel engine is the library from scripting.java.sun.com that exposes juel as a jsr233 scripting engine.
+ It's not part of the juel distribution. For some reason i don't recall, we uploaded it as
+ an juel-engine artifact in the group juel. And more problematic, used the juel version (2.1.0) for it.
+ That is not intuitive. -->
<groupId>juel</groupId>
- <artifactId>juel-impl</artifactId>
- <version>${juel.version}</version>
- </dependency>
- <dependency>
- <groupId>juel</groupId>
<artifactId>juel-engine</artifactId>
- <version>${juel.version}</version>
+ <version>${juel.engine.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
More information about the jbpm-commits
mailing list