JBoss JBPM SVN: r6151 - in jbpm3/branches/jbpm-3.2-soa/modules: enterprise/src/main/etc and 3 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-29 23:33:30 -0500 (Fri, 29 Jan 2010)
New Revision: 6151
Removed:
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/command/jms/
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/SaveJobExceptionCommand.java
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/etc/jbpm.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandListenerBean.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
Log:
JBPM-2691: revert command to save job exception. ESB message service will implement its own behavior, cf. SOA-1882
delegate redelivery and exception reporting to the container
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -159,9 +159,9 @@
}
catch (RuntimeException e) {
if (!DbPersistenceService.isLockingException(e)) throw e;
- // if this is a locking exception, keep it quiet
+ // keep locking exception quiet
StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
- .error("failed to acquire lock on jobs " + jobsToLock);
+ .error("failed to acquire lock on jobs " + jobsToLock, e);
acquiredJobs = Collections.EMPTY_LIST;
}
}
@@ -190,9 +190,9 @@
jbpmContext.setRollbackOnly();
if (!DbPersistenceService.isLockingException(e)) throw e;
- // if this is a locking exception, keep it quiet
+ // keep locking exception quiet
StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
- .error("failed to complete " + job);
+ .error("failed to complete " + job, e);
}
catch (Error e) {
jbpmContext.setRollbackOnly();
@@ -289,9 +289,9 @@
}
catch (RuntimeException e) {
if (!DbPersistenceService.isLockingException(e)) throw e;
- // if this is a locking exception, keep it quiet
+ // keep locking exception quiet
StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
- .error("failed to determine next due date");
+ .error("failed to determine next due date", e);
nextDueDate = null;
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -81,7 +81,10 @@
}
catch (RuntimeException e) {
jbpmContext.setRollbackOnly();
- throw e;
+ if (!DbPersistenceService.isLockingException(e)) throw e;
+ // keep locking exception quiet
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
+ .error("could not unlock overdue jobs", e);
}
catch (Error e) {
jbpmContext.setRollbackOnly();
@@ -93,9 +96,9 @@
}
catch (RuntimeException e) {
if (!DbPersistenceService.isLockingException(e)) throw e;
- // if this is a locking exception, keep it quiet
+ // keep locking exception quiet
StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
- .error("could not unlock overdue jobs");
+ .error("could not unlock overdue jobs", e);
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/etc/jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/etc/jbpm.cfg.xml 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/etc/jbpm.cfg.xml 2010-01-30 04:33:30 UTC (rev 6151)
@@ -7,7 +7,6 @@
<service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
<service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
<service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
- <service name="command" factory="org.jbpm.command.jms.JmsCommandServiceFactory" />
</jbpm-context>
<!-- use the context class loader -->
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandListenerBean.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandListenerBean.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandListenerBean.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -44,20 +44,22 @@
import org.jbpm.command.Command;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.persistence.db.DbPersistenceService;
+import org.jbpm.persistence.db.StaleObjectLogConfigurer;
/**
- * This message-driven bean listens for {@link ObjectMessage object messages} containing a command
- * instance. The received commands are executed by the {@link CommandServiceBean command service}
- * bean, using the local interface.
+ * This message-driven bean listens for {@link ObjectMessage object messages}
+ * containing a command instance. The received commands are executed by the
+ * {@link CommandServiceBean command service} bean, using the local interface.
*
- * The body of the message must be a Java object that implements the {@link Command} interface. The
- * message properties, if any, are ignored.
+ * The body of the message must be a Java object that implements the
+ * {@link Command} interface. The message properties, if any, are ignored.
*
* <h3>Environment</h3>
*
* <p>
- * The environment entries and resources available for customization are summarized in the table
- * below.
+ * The environment entries and resources available for customization are
+ * summarized in the table below.
* </p>
*
* <table border="1">
@@ -69,20 +71,22 @@
* <tr>
* <td><code>ejb/LocalCommandServiceBean</code></td>
* <td>EJB Reference</td>
- * <td>Link to the local {@linkplain CommandServiceBean session bean} that executes commands on a
- * separate jBPM context.</td>
+ * <td>Link to the local {@linkplain CommandServiceBean session bean} that
+ * executes commands on a separate jBPM context.</td>
* </tr>
* <tr>
* <td><code>jms/JbpmConnectionFactory</code></td>
* <td>Resource Manager Reference</td>
- * <td>Logical name of the factory that provides JMS connections for producing result messages.
- * Required for command messages that indicate a reply destination.</td>
+ * <td>Logical name of the factory that provides JMS connections for producing
+ * result messages. Required for command messages that indicate a reply
+ * destination.</td>
* </tr>
* <tr>
* <td><code>jms/DeadLetterQueue</code></td>
* <td>Message Destination Reference</td>
- * <td>Messages which do not contain a command are sent to the queue referenced here. Optional; if
- * absent, such messages are rejected, which may cause the container to redeliver.</td>
+ * <td>Messages which do not contain a command are sent to the queue referenced
+ * here. Optional; if absent, such messages are rejected, which may cause the
+ * container to redeliver.</td>
* </tr>
* </table>
*
@@ -96,8 +100,10 @@
MessageDrivenContext messageDrivenContext;
LocalCommandService commandService;
+
+ Destination deadLetterQueue;
+ ConnectionFactory jmsConnectionFactory;
Connection jmsConnection;
- Destination deadLetterQueue;
public void onMessage(Message message) {
try {
@@ -107,17 +113,32 @@
discard(message);
return;
}
- // execute command via local command executor bean
- Object result = commandService.execute(command);
- // send a response back if a "reply to" destination is set
- Destination replyTo = message.getJMSReplyTo();
- if (replyTo != null && (result instanceof Serializable || result == null)) {
- sendResult((Serializable) result, replyTo, message.getJMSMessageID());
+ try {
+ // execute command via local command executor bean
+ Object result = commandService.execute(command);
+ // send a response back if a "reply to" destination is set
+ Destination replyTo = message.getJMSReplyTo();
+ if (replyTo != null
+ && (result instanceof Serializable || result == null)) {
+ sendResult((Serializable) result, replyTo, message.getJMSMessageID());
+ }
}
+ catch (RuntimeException e) {
+ // MDBs are not supposed to throw exceptions
+ messageDrivenContext.setRollbackOnly();
+ // if this is a locking exception, keep it quiet
+ if (DbPersistenceService.isLockingException(e)) {
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog()
+ .error("failed to execute " + command, e);
+ }
+ else {
+ log.error("failed to execute " + command, e);
+ }
+ }
}
catch (JMSException e) {
messageDrivenContext.setRollbackOnly();
- log.error("could not process message " + message, e);
+ log.error("failed to process message " + message, e);
}
}
@@ -143,11 +164,13 @@
if (deadLetterQueue == null) {
// lookup dead letter queue
try {
- Context initial = new InitialContext();
- deadLetterQueue = (Destination) initial.lookup("java:comp/env/jms/DeadLetterQueue");
+ Context jndiContext = new InitialContext();
+ deadLetterQueue =
+ (Destination) jndiContext.lookup("java:comp/env/jms/DeadLetterQueue");
}
catch (NamingException e) {
- log.debug("failed to retrieve dead letter queue, rejecting message: " + message);
+ log.debug("failed to retrieve dead letter queue, rejecting message: "
+ + message);
messageDrivenContext.setRollbackOnly();
return;
}
@@ -162,8 +185,8 @@
}
}
- private void sendResult(Serializable result, Destination destination, String correlationId)
- throws JMSException {
+ private void sendResult(Serializable result, Destination destination,
+ String correlationId) throws JMSException {
log.debug("sending result " + result + " to " + destination);
Session jmsSession = createSession();
try {
@@ -178,20 +201,13 @@
private Session createSession() throws JMSException {
if (jmsConnection == null) {
- // lookup factory and create jms connection
- try {
- Context initial = new InitialContext();
- ConnectionFactory jmsConnectionFactory = (ConnectionFactory) initial.lookup("java:comp/env/jms/JbpmConnectionFactory");
- jmsConnection = jmsConnectionFactory.createConnection();
- }
- catch (NamingException e) {
- throw new EJBException("error retrieving jms connection factory", e);
- }
+ // create jms connection
+ jmsConnection = jmsConnectionFactory.createConnection();
}
/*
- * if the connection supports xa, the session will be transacted, else the session will auto
- * acknowledge; in either case no explicit transaction control must be performed - see ejb 2.1 -
- * 17.3.5
+ * if the connection supports xa, the session will be transacted, else the
+ * session will auto acknowledge; in either case no explicit transaction
+ * control must be performed - see ejb 2.1 - 17.3.5
*/
return jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
@@ -210,6 +226,7 @@
}
jmsConnection = null;
}
+ jmsConnectionFactory = null;
deadLetterQueue = null;
commandService = null;
messageDrivenContext = null;
@@ -217,9 +234,14 @@
public void ejbCreate() {
try {
- Context initial = new InitialContext();
- LocalCommandServiceHome commandServiceHome = (LocalCommandServiceHome) initial.lookup("java:comp/env/ejb/LocalCommandServiceBean");
+ Context jndiContext = new InitialContext();
+
+ LocalCommandServiceHome commandServiceHome =
+ (LocalCommandServiceHome) jndiContext.lookup("java:comp/env/ejb/LocalCommandServiceBean");
commandService = commandServiceHome.create();
+
+ jmsConnectionFactory =
+ (ConnectionFactory) jndiContext.lookup("java:comp/env/jms/JbpmConnectionFactory");
}
catch (NamingException e) {
throw new EJBException("error retrieving command service home", e);
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/CommandServiceBean.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -93,7 +93,8 @@
* <td>The message service sends job messages to the queue referenced here. To
* ensure this is the same queue from which the {@linkplain JobListenerBean job
* listener bean} receives messages, the <code>message-destination-link
- * </code> points to a common logical destination, <code>JobQueue</code>.</td>
+ * </code> points to a common logical
+ * destination, <code>JobQueue</code>.</td>
* </tr>
* </table>
*
@@ -141,16 +142,16 @@
}
public Object execute(Command command) {
- Object result = null;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
log.debug("executing " + command);
- result = command.execute(jbpmContext);
+ Object result = command.execute(jbpmContext);
// check whether command requested a rollback
TxService txService = jbpmContext.getServices().getTxService();
if (txService.isRollbackOnly()) {
sessionContext.setRollbackOnly();
}
+ return result;
}
catch (RuntimeException e) {
throw e;
@@ -161,7 +162,6 @@
finally {
jbpmContext.close();
}
- return result;
}
public void setSessionContext(SessionContext sessionContext) {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -23,7 +23,6 @@
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
-import org.jbpm.command.CommandService;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Job;
@@ -68,22 +67,9 @@
private static void executeJob(Job job, JbpmContext jbpmContext)
throws Exception {
- try {
- if (job.execute(jbpmContext)) {
- jbpmContext.getJobSession().deleteJob(job);
- }
+ if (job.execute(jbpmContext)) {
+ jbpmContext.getJobSession().deleteJob(job);
}
- catch (Exception e) {
- jbpmContext.setRollbackOnly();
- saveJobException(job, jbpmContext, e);
- }
}
- private static void saveJobException(Job job, JbpmContext jbpmContext,
- Exception exception) {
- CommandService commandService =
- (CommandService) jbpmContext.getServices().getService("command");
- commandService.execute(new SaveJobExceptionCommand(job.getId(), exception));
- }
-
}
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/SaveJobExceptionCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/SaveJobExceptionCommand.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/SaveJobExceptionCommand.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -1,66 +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.ejb.impl;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.jbpm.JbpmContext;
-import org.jbpm.command.Command;
-import org.jbpm.command.CommandService;
-import org.jbpm.db.JobSession;
-import org.jbpm.job.Job;
-
-/**
- * @author Alejandro Guizar
- */
-public class SaveJobExceptionCommand implements Command {
-
- private final long jobId;
- private final Exception exception;
-
- private static final long serialVersionUID = 1L;
-
- public SaveJobExceptionCommand(long jobId, Exception exception) {
- this.jobId = jobId;
- this.exception = exception;
- }
-
- public Object execute(JbpmContext jbpmContext) throws Exception {
- JobSession jobSession = jbpmContext.getJobSession();
- Job job = jobSession.loadJob(jobId);
-
- StringWriter out = new StringWriter();
- exception.printStackTrace(new PrintWriter(out));
- job.setException(out.toString());
-
- int retries = job.getRetries();
- if (retries > 0) {
- job.setRetries(retries - 1);
- CommandService commandService = (CommandService) jbpmContext.getServices()
- .getService("command");
- commandService.execute(new ExecuteJobCommand(jobId));
- }
- return job;
- }
-
-}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2010-01-29 20:40:00 UTC (rev 6150)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/test/java/org/jbpm/enterprise/jta/JtaDbPersistenceTest.java 2010-01-30 04:33:30 UTC (rev 6151)
@@ -44,23 +44,23 @@
}
protected CommandService createCommandService() throws Exception {
- return getName().indexOf("CMT") != -1 ? super.createCommandService() : new CommandServiceImpl(
+ return getName().indexOf("Container") != -1 ? super.createCommandService() : new CommandServiceImpl(
JbpmConfiguration.getInstance());
}
- public void testCMTSuccess() throws Exception {
+ public void testContainerTxSuccess() throws Exception {
playTransaction(false);
}
- public void testCMTFailure() throws Exception {
+ public void testContainerTxFailure() throws Exception {
playTransaction(true);
}
- public void testBMTSuccess() throws Exception {
+ public void testUserTxSuccess() throws Exception {
playTransaction(false);
}
- public void testBMTFailure() throws Exception {
+ public void testUserTxFailure() throws Exception {
playTransaction(true);
}
14 years, 3 months
JBoss JBPM SVN: r6150 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/parser and 13 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-29 15:40:00 -0500 (Fri, 29 Jan 2010)
New Revision: 6150
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java
Removed:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
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/activity/DecisionBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
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/VariableDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
Log:
JBPM-2653 refactoring existing scriptmanager expression evaluation to uel expression evaluation
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -4,6 +4,7 @@
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
@@ -66,15 +67,13 @@
if (rae != null) {
String formalExpression = XmlUtil.element(rae, "formalExpression", true, parse).getTextContent().trim();
String lang = XmlUtil.attribute(rae, "language", false, parse);
+ Expression expression = Expression.create(formalExpression, lang);
if (PERFORMER.equals(type) || HUMAN_PERFORMER.equals(type)) {
- taskDefinition.setAssigneeExpression(formalExpression);
- taskDefinition.setAssigneeExpressionLanguage(lang);
+ taskDefinition.setAssigneeExpression(expression);
} else if (POTENTIAL_OWNER.equals(type) && "user".equals(scope)) { // default is group
- taskDefinition.setCandidateUsersExpression(formalExpression);
- taskDefinition.setCandidateUsersExpressionLanguage(lang);
+ taskDefinition.setCandidateUsersExpression(expression);
} else {
- taskDefinition.setCandidateGroupsExpression(formalExpression);
- taskDefinition.setCandidateGroupsExpressionLanguage(lang);
+ taskDefinition.setCandidateGroupsExpression(expression);
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -1,13 +1,11 @@
package org.jbpm.bpmn.flownodes;
import org.jbpm.bpmn.common.Resource;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
public class ActivityResource {
String id;
Resource resourceRef;
- ExpressionEvaluatorDescriptor resourceAssignmentExpression;
public String getId() {
return id;
@@ -24,14 +22,4 @@
public void setResourceRef(Resource resourceRef) {
this.resourceRef = resourceRef;
}
-
-
- public ExpressionEvaluatorDescriptor getResourceAssignmentExpression() {
- return resourceAssignmentExpression;
- }
-
- public void setResourceAssignmentExpression(ExpressionEvaluatorDescriptor resourceAssignmentExpression) {
- this.resourceAssignmentExpression = resourceAssignmentExpression;
- }
-
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -26,8 +26,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
@@ -43,8 +43,7 @@
private static final long serialVersionUID = 1L;
- protected String targetExpression;
- protected String targetLanguage;
+ protected Expression targetExpression;
protected Object target;
protected String methodName;
@@ -61,8 +60,7 @@
invocationTarget = target;
} else if (targetExpression!=null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- invocationTarget = scriptManager.evaluateExpression(targetExpression, targetLanguage);
+ invocationTarget = targetExpression.evaluate(execution);
} else {
throw new JbpmException("no target specified");
@@ -108,10 +106,7 @@
public void setInvokeOperation(InvokeOperation invokeOperation) {
this.invokeOperation = invokeOperation;
}
- public void setTargetExpression(String expression) {
+ public void setTargetExpression(Expression expression) {
this.targetExpression = expression;
}
- public void setTargetLanguage(String language) {
- this.targetLanguage = language;
- }
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -24,9 +24,8 @@
import java.util.Map;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.bpmn.parser.ExpressionEvaluator;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
@@ -35,7 +34,6 @@
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.wire.WireContext;
/**
* @author Tom Baeyens
@@ -60,11 +58,10 @@
task.setProcessInstance(execution.getProcessInstance());
task.setSignalling(true);
- if (taskDefinition.getAssigneeExpression() != null) {
- ExpressionEvaluatorDescriptor eed = new ExpressionEvaluatorDescriptor(taskDefinition.getAssigneeExpression(), taskDefinition
- .getAssigneeExpressionLanguage());
- ExpressionEvaluator ee = (ExpressionEvaluator) WireContext.create(eed);
- task.setAssignee((String) ee.evaluateExpression(execution));
+ Expression assigneeExpression = taskDefinition.getAssigneeExpression();
+ if (assigneeExpression != null) {
+ Object assignee = assigneeExpression.evaluate(execution);
+ task.setAssignee((assignee!=null ? assignee.toString() : null));
}
// initialize the name
@@ -74,7 +71,12 @@
task.setName(execution.getActivityName());
}
- task.setDescription(taskDefinition.getDescription());
+ Expression descriptionExpression = taskDefinition.getDescription();
+ if (descriptionExpression!=null) {
+ String description = (String) descriptionExpression.evaluate(task);
+ task.setDescription(description);
+ }
+
task.setPriority(taskDefinition.getPriority());
task.setFormResourceName(taskDefinition.getFormResourceName());
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -1,57 +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.bpmn.parser;
-
-import org.jbpm.api.model.OpenExecution;
-import org.jbpm.pvm.internal.model.Condition;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * @author Tom Baeyens
- */
-public class ExpressionEvaluator implements Condition {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluator(String name, String expr, String lang) {
- this.name = name;
- this.expr = expr;
- this.lang = lang;
- }
-
- public boolean evaluate(OpenExecution execution) {
- return (Boolean) evaluateExpression(execution);
- }
-
- public Object evaluateExpression(OpenExecution execution) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- return scriptManager.evaluateExpression(expr, lang);
- }
-
- public String getName() {
- return name;
- }
-}
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -1,52 +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.bpmn.parser;
-
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
-
-
-/**
- * @author Tom Baeyens
- *
- * @deprecated to be replaced by {@link UserCodeReference} see also package org.jbpm.pvm.internal.wire.usercode
- */
-public class ExpressionEvaluatorDescriptor extends AbstractDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluatorDescriptor() {
- }
-
- public ExpressionEvaluatorDescriptor(String expr, String lang) {
- this.expr = expr;
- this.lang = lang;
- }
-
- public Object construct(WireContext wireContext) {
- return new ExpressionEvaluator(getName(), expr, lang);
- }
-
-}
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-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -21,12 +21,10 @@
*/
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.el.Expression;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.el.UelValueExpression;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -42,7 +40,7 @@
protected Descriptor fromValueDescriptor;
protected String toVariableName;
- protected Expression toExpression;
+ protected UelValueExpression toExpression;
void perform(OpenExecution execution) throws Exception {
Object value = null;
@@ -51,7 +49,7 @@
value = fromExpression.evaluate(execution);
} else if (fromValueDescriptor!=null) {
- value = WireContext.create(fromValueDescriptor);
+ value = WireContext.create(fromValueDescriptor, (ScopeInstanceImpl) execution);
}
if (toVariableName!=null) {
@@ -70,7 +68,7 @@
public void setFromExpression(Expression fromExpression) {
this.fromExpression = fromExpression;
}
- public void setToExpression(Expression toExpression) {
+ public void setToExpression(UelValueExpression toExpression) {
this.toExpression = toExpression;
}
}
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-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -26,6 +26,7 @@
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.el.UelValueExpression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -50,8 +51,8 @@
if (toVar!=null) {
assignActivity.setToVariableName(toVar);
} else if (toExpr!=null) {
- Expression expression = new Expression(toExpr, Expression.TYPE_VALUE);
- assignActivity.setToExpression(expression);
+ Expression expression = Expression.create(toExpr, Expression.LANGUAGE_UEL_VALUE);
+ assignActivity.setToExpression((UelValueExpression) expression);
}
String exprText = XmlUtil.attribute(element, "expr");
@@ -59,7 +60,7 @@
// if there is an expr specified
if (exprText!=null) {
- Expression expression = new Expression(exprText, exprType);
+ Expression expression = Expression.create(exprText, exprType);
assignActivity.setFromExpression(expression);
} else { // there is no expr specified
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -24,6 +24,7 @@
import java.util.List;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExpressionCondition;
import org.jbpm.pvm.internal.model.TransitionImpl;
@@ -46,9 +47,10 @@
public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
if (element.hasAttribute("expr")) {
DecisionExpressionActivity decisionExpressionActivity = new DecisionExpressionActivity();
- String expr = element.getAttribute("expr");
- decisionExpressionActivity.setExpression(expr);
- decisionExpressionActivity.setLanguage(XmlUtil.attribute(element, "lang"));
+ String expressionText = element.getAttribute("expr");
+ String language = XmlUtil.attribute(element, "lang");
+ Expression expression = Expression.create(expressionText, language);
+ decisionExpressionActivity.setExpression(expression);
return decisionExpressionActivity;
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -25,8 +25,8 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.api.model.Transition;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
* @author Tom Baeyens
@@ -35,8 +35,7 @@
private static final long serialVersionUID = 1L;
- protected String expression;
- protected String language;
+ protected Expression expression;
public void execute(ActivityExecution execution) {
execute((ExecutionImpl) execution);
@@ -46,8 +45,7 @@
Activity activity = execution.getActivity();
String transitionName = null;
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- Object result = scriptManager.evaluateExpression(expression, language);
+ Object result = expression.evaluate(execution);
if ( (result!=null)
&& (! (result instanceof String))
) {
@@ -65,10 +63,7 @@
execution.take(transition);
}
- public void setExpression(String expr) {
- this.expression = expr;
+ public void setExpression(Expression expression) {
+ this.expression = expression;
}
- public void setLanguage(String lang) {
- this.language = lang;
- }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -27,6 +27,7 @@
import org.jbpm.api.model.OpenExecution;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
@@ -58,7 +59,7 @@
if (parametersDescriptor!=null) {
for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
String parameterName = valueDescriptor.getName();
- Object value = WireContext.create(valueDescriptor);
+ Object value = WireContext.create(valueDescriptor, (ScopeInstanceImpl) execution);
applyParameter(q, parameterName, value);
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -53,6 +53,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -69,8 +71,8 @@
private static final long serialVersionUID = 1L;
protected String type = null;
- protected String textExpression = null;
- protected String objectExpression = null;
+ protected Expression textExpression = null;
+ protected Expression objectExpression = null;
protected MapDescriptor mapDescriptor = null;
protected String connectionFactoryName = null;
protected String destinationName = null;
@@ -89,12 +91,12 @@
if (destination instanceof Queue) {
log.debug("destination '"+destinationName+"' is a Queue: using xa queue jms apis");
XAQueueConnectionFactory xaQueueConnectionFactory = (XAQueueConnectionFactory) connectionFactory;
- sendToQueueXA((Queue) destination, xaQueueConnectionFactory);
+ sendToQueueXA((Queue) destination, xaQueueConnectionFactory, (ExecutionImpl) execution);
} else if (destination instanceof Topic) {
log.debug("destination '"+destinationName+"' is a Topic: using xa topic jms apis");
XATopicConnectionFactory xaTopicConnectionFactory = (XATopicConnectionFactory) connectionFactory;
- sendToTopicXA((Topic) destination, xaTopicConnectionFactory);
+ sendToTopicXA((Topic) destination, xaTopicConnectionFactory, (ExecutionImpl) execution);
} else {
throw new JbpmException("invalid destination type for '"+destinationName+"': "+destination.getClass().getName());
@@ -105,12 +107,12 @@
if (destination instanceof Queue) {
log.debug("destination '"+destinationName+"' is a Queue: using non-xa queue jms apis");
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) connectionFactory;
- sendToQueue((Queue) destination, queueConnectionFactory);
+ sendToQueue((Queue) destination, queueConnectionFactory, (ExecutionImpl) execution);
} else if (destination instanceof Topic) {
log.debug("destination '"+destinationName+"' is a Topic: using non-xa topic jms apis");
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) connectionFactory;
- sendToTopic((Topic) destination, topicConnectionFactory);
+ sendToTopic((Topic) destination, topicConnectionFactory, (ExecutionImpl) execution);
} else {
throw new JbpmException("invalid destination type for '"+destinationName+"': "+destination.getClass().getName());
@@ -127,7 +129,7 @@
}
}
- protected void sendToQueueXA(Queue queue, XAQueueConnectionFactory xaQueueConnectionFactory) throws Exception {
+ protected void sendToQueueXA(Queue queue, XAQueueConnectionFactory xaQueueConnectionFactory, ExecutionImpl execution) throws Exception {
XAQueueConnection xaQueueConnection = null;
XAQueueSession xaQueueSession = null;
MessageProducer messageProducer = null;
@@ -136,7 +138,7 @@
xaQueueConnection = xaQueueConnectionFactory.createXAQueueConnection();
xaQueueSession = xaQueueConnection.createXAQueueSession();
messageProducer = xaQueueSession.createProducer(queue);
- Message message = createMessage(xaQueueSession);
+ Message message = createMessage(xaQueueSession, execution);
messageProducer.send(message);
} finally {
@@ -158,7 +160,7 @@
}
}
- protected void sendToTopicXA(Topic topic, XATopicConnectionFactory xaTopicConnectionFactory) throws Exception {
+ protected void sendToTopicXA(Topic topic, XATopicConnectionFactory xaTopicConnectionFactory, ExecutionImpl execution) throws Exception {
XATopicConnection xaTopicConnection = null;
XATopicSession xaTopicSession = null;
MessageProducer messageProducer = null;
@@ -167,7 +169,7 @@
xaTopicConnection = xaTopicConnectionFactory.createXATopicConnection();
xaTopicSession = xaTopicConnection.createXATopicSession();
messageProducer = xaTopicSession.createProducer(topic);
- Message message = createMessage(xaTopicSession);
+ Message message = createMessage(xaTopicSession, execution);
messageProducer.send(message);
} finally {
@@ -189,7 +191,7 @@
}
}
- protected void sendToQueue(Queue queue, QueueConnectionFactory queueConnectionFactory) throws Exception {
+ protected void sendToQueue(Queue queue, QueueConnectionFactory queueConnectionFactory, ExecutionImpl execution) throws Exception {
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
@@ -198,7 +200,7 @@
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(transacted, acknowledgeMode);
queueSender = queueSession.createSender(queue);
- Message message = createMessage(queueSession);
+ Message message = createMessage(queueSession, execution);
queueSender.send(message);
if (transacted) {
queueSession.commit();
@@ -223,7 +225,7 @@
}
}
- protected void sendToTopic(Topic topic, TopicConnectionFactory topicConnectionFactory) throws Exception {
+ protected void sendToTopic(Topic topic, TopicConnectionFactory topicConnectionFactory, ExecutionImpl execution) throws Exception {
TopicConnection topicConnection = null;
TopicSession topicSession = null;
TopicPublisher topicPublisher = null;
@@ -232,7 +234,7 @@
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(transacted, acknowledgeMode);
topicPublisher = topicSession.createPublisher(topic);
- Message message = createMessage(topicSession);
+ Message message = createMessage(topicSession, execution);
topicPublisher.send(message);
if (transacted) {
topicSession.commit();
@@ -257,18 +259,18 @@
}
}
- protected Message createMessage(Session session) throws Exception {
+ protected Message createMessage(Session session, ExecutionImpl execution) throws Exception {
if ("text".equals(type)) {
- return createTextMessage(session);
+ return createTextMessage(session, execution);
} else if ("object".equals(type)) {
- return createObjectMessage(session);
+ return createObjectMessage(session, execution);
} else if ("map".equals(type)) {
- return createMapMessage(session);
+ return createMapMessage(session, execution);
}
throw new JbpmException("no type configured in jms activity");
}
- private MapMessage createMapMessage(Session session) throws Exception {
+ private MapMessage createMapMessage(Session session, ExecutionImpl execution) throws Exception {
MapMessage result = session.createMapMessage();
if (mapDescriptor != null) {
List<Descriptor> keyDescriptors = mapDescriptor.getKeyDescriptors();
@@ -282,16 +284,16 @@
return result;
}
- private TextMessage createTextMessage(Session session) throws Exception {
- Object value = ScriptManager.getScriptManager().evaluateExpression(textExpression, null);
+ private TextMessage createTextMessage(Session session, ExecutionImpl execution) throws Exception {
+ Object value = textExpression.evaluate(execution);
if (value!=null) {
return session.createTextMessage(value.toString());
}
throw new JbpmException("null value for expression '"+textExpression+"' in jms activity");
}
- private ObjectMessage createObjectMessage(Session session) throws Exception {
- Object object = ScriptManager.getScriptManager().evaluateExpression(objectExpression, null);
+ private ObjectMessage createObjectMessage(Session session, ExecutionImpl execution) throws Exception {
+ Object object = objectExpression.evaluate(execution);
if ( (object!=null)
&& !(object instanceof Serializable)
) {
@@ -303,11 +305,11 @@
public void setType(String type) {
this.type = type;
}
- public void setText(String text) {
- this.textExpression = text;
+ public void setTextExpression(Expression textExpression) {
+ this.textExpression = textExpression;
}
- public void setExpression(String expression) {
- this.objectExpression = expression;
+ public void setObjectExpression(Expression objectExpression) {
+ this.objectExpression = objectExpression;
}
public void setMapDescriptor(MapDescriptor mapDescriptor) {
this.mapDescriptor = mapDescriptor;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -24,6 +24,7 @@
import javax.jms.Session;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
@@ -78,15 +79,18 @@
Element textElement = XmlUtil.element(element, "text", false, parse);
if (textElement != null) {
- String text = XmlUtil.getContentText(textElement);
+ String expressionText = XmlUtil.getContentText(textElement);
jmsActivity.setType("text");
- jmsActivity.setText(text);
+ Expression expression = Expression.create(expressionText, Expression.LANGUAGE_UEL);
+ jmsActivity.setTextExpression(expression);
}
Element objectElement = XmlUtil.element(element, "object", false, parse);
if (objectElement != null) {
jmsActivity.setType("object");
- jmsActivity.setExpression(XmlUtil.attribute(objectElement, "expr"));
+ String expressionText = XmlUtil.attribute(objectElement, "expr");
+ Expression expression = Expression.create(expressionText, Expression.LANGUAGE_UEL);
+ jmsActivity.setObjectExpression(expression);
}
Element mapElement = XmlUtil.element(element, "map", false, parse);
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -24,6 +24,7 @@
import java.util.List;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -54,8 +55,8 @@
if (factExpr!=null) {
String factLang = XmlUtil.attribute(factElement, "lang");
- rulesFact.setExpression(factExpr);
- rulesFact.setLanguage(factLang);
+ Expression expression = Expression.create(factExpr, factLang);
+ rulesFact.setExpression(expression);
} else {
parse.addProblem("'fact' element inside 'rules' activity requires attribute 'var' or 'expr'", element);
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -24,7 +24,7 @@
import java.io.Serializable;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.el.Expression;
/**
* @author Tom Baeyens
@@ -34,7 +34,7 @@
private static final long serialVersionUID = 1L;
protected String variableName;
- protected String expression;
+ protected Expression expression;
protected String language;
public String getVariableName() {
@@ -45,11 +45,11 @@
this.variableName = variableName;
}
- public String getExpression() {
+ public Expression getExpression() {
return expression;
}
- public void setExpression(String expression) {
+ public void setExpression(Expression expression) {
this.expression = expression;
}
@@ -66,7 +66,7 @@
return execution.getVariable(variableName);
} else if (expression!=null) {
- return ScriptManager.getScriptManager().evaluateExpression(expression, language);
+ return expression.evaluate(execution);
}
return null;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -27,12 +27,12 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.ExecutionContext;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
-import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
@@ -51,7 +51,7 @@
protected List<SubProcessInParameterImpl> inParameters;
protected List<SubProcessOutParameterImpl> outParameters;
- protected String outcomeExpression;
+ protected Expression outcomeExpression;
protected Map<Object, String> outcomeVariableMappings;
public void execute(ActivityExecution execution) {
@@ -122,8 +122,7 @@
String subProcessActivityName = subProcessInstance.getActivityName();
if (outcomeExpression!=null) {
- ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
- Object value = scriptManager.evaluateExpression(outcomeExpression, null);
+ Object value = outcomeExpression.evaluate(executionImpl);
// if the value is a String and matches the name of an outgoing transition
if ( (value instanceof String)
&& (activity.hasOutgoingTransition(((String) value)))
@@ -169,7 +168,7 @@
public void setSubProcessId(String subProcessId) {
this.subProcessId = subProcessId;
}
- public void setOutcomeExpression(String outcomeExpression) {
+ public void setOutcomeExpression(Expression outcomeExpression) {
this.outcomeExpression = outcomeExpression;
}
public List<SubProcessInParameterImpl> getInParameters() {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -27,6 +27,7 @@
import java.util.Map;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -102,8 +103,10 @@
Map<Object, String> outcomeVariableMappings = new HashMap<Object, String>();
- String outcomeExpression = XmlUtil.attribute(element, "outcome");
- if (outcomeExpression!=null) {
+ String outcomeExpressionText = XmlUtil.attribute(element, "outcome");
+ String outcomeLanguage = XmlUtil.attribute(element, "outcome-lang");
+ if (outcomeExpressionText!=null) {
+ Expression outcomeExpression = Expression.create(outcomeExpressionText, outcomeLanguage);
subProcessActivity.setOutcomeExpression(outcomeExpression);
for (Element transitionElement: XmlUtil.elements(element, "transition")) {
@@ -133,15 +136,12 @@
String name = XmlUtil.attribute(element, "subvar");
parameter.setSubVariableName(name);
- String expr = XmlUtil.attribute(element, "expr");
- if (expr!=null) {
- parameter.setExpression(expr);
+ String expressionText = XmlUtil.attribute(element, "expr");
+ String language = XmlUtil.attribute(element, "expr-lang");
+ if (expressionText!=null) {
+ Expression expression = Expression.create(expressionText, language);
+ parameter.setExpression(expression);
}
-
- String language = XmlUtil.attribute(element, "lang");
- if (language!=null) {
- parameter.setLanguage(language);
- }
String variable = XmlUtil.attribute(element, "var");
if (variable!=null) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -22,7 +22,6 @@
package org.jbpm.jpdl.internal.activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
@@ -37,8 +36,7 @@
if (variableName!=null) {
value = superExecution.getVariable(variableName);
} else {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- value = scriptManager.evaluateExpression(expression, language);
+ value = expression.evaluateInScope(superExecution);
}
subProcessInstance.setVariable(subVariableName, value);
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -23,7 +23,6 @@
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
@@ -39,8 +38,7 @@
if (variableName!=null) {
value = subProcessInstance.getVariable(subVariableName);
} else {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- value = scriptManager.evaluateExpression(expression, language);
+ value = expression.evaluateInScope(subProcessInstance);
}
superExecution.setVariable(variableName, value);
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -23,7 +23,9 @@
import java.io.Serializable;
+import org.jbpm.pvm.internal.el.Expression;
+
/**
* @author Tom Baeyens
*/
@@ -33,8 +35,7 @@
protected String subVariableName;
protected String variableName;
- protected String expression;
- protected String language;
+ protected Expression expression;
public String getVariableName() {
return variableName;
@@ -42,18 +43,12 @@
public void setVariableName(String variable) {
this.variableName = variable;
}
- public String getExpression() {
+ public Expression getExpression() {
return expression;
}
- public void setExpression(String expression) {
+ public void setExpression(Expression expression) {
this.expression = expression;
}
- public String getLanguage() {
- return language;
- }
- public void setLanguage(String language) {
- this.language = language;
- }
public String getSubVariableName() {
return subVariableName;
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -28,6 +28,7 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Transition;
import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
@@ -71,12 +72,9 @@
task.setName(execution.getActivityName());
}
- String description = taskDefinition.getDescription();
- if (description != null) {
- if (description.contains("#{")) {
- Object result = ScriptManager.getScriptManager().evaluateExpression(description, null);
- description = result instanceof String ? (String) result : result.toString();
- }
+ Expression descriptionExpression = taskDefinition.getDescription();
+ if (descriptionExpression != null) {
+ String description = (String) descriptionExpression.evaluate(task);
task.setDescription(description);
}
task.setPriority(taskDefinition.getPriority());
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-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -57,8 +57,6 @@
import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableOutDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableOutDefinitionSet;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
@@ -494,8 +492,9 @@
public void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
Element descriptionElement = XmlUtil.element(element, "description");
if (descriptionElement!=null) {
- String description = XmlUtil.getContentText(descriptionElement);
- assignableDefinition.setDescription(description);
+ String descriptionText = XmlUtil.getContentText(descriptionElement);
+ Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL);
+ assignableDefinition.setDescription(descriptionExpression);
}
Element assignmentHandlerElement = XmlUtil.element(element, "assignment-handler");
@@ -504,23 +503,26 @@
assignableDefinition.setAssignmentHandlerReference(assignmentHandlerReference);
}
- String assigneeExpression = XmlUtil.attribute(element, "assignee");
- assignableDefinition.setAssigneeExpression(assigneeExpression);
+ String assigneeExpressionText = XmlUtil.attribute(element, "assignee");
+ if (assigneeExpressionText!=null) {
+ String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
+ Expression assigneeExpression = Expression.create(assigneeExpressionText, assigneeExpressionLanguage);
+ assignableDefinition.setAssigneeExpression(assigneeExpression);
+ }
- String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
- assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
-
- String candidateUsersExpression = XmlUtil.attribute(element, "candidate-users");
- assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
-
- String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
- assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
-
- String candidateGroupsExpression = XmlUtil.attribute(element, "candidate-groups");
- assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
-
- String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
- assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
+ String candidateUsersExpressionText = XmlUtil.attribute(element, "candidate-users");
+ if (candidateUsersExpressionText!=null) {
+ String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
+ Expression candidateUsersExpression = Expression.create(candidateUsersExpressionText, candidateUsersExpressionLanguage);
+ assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
+ }
+
+ String candidateGroupsExpressionText = XmlUtil.attribute(element, "candidate-groups");
+ if (candidateGroupsExpressionText!=null) {
+ String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
+ Expression candidateGroupsExpression = Expression.create(candidateGroupsExpressionText, candidateGroupsExpressionLanguage);
+ assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
+ }
}
public TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
@@ -594,7 +596,7 @@
String initExpr = XmlUtil.attribute(variableElement, "init-expr");
String initExprType = XmlUtil.attribute(variableElement, "init-expr-type");
if (initExpr!=null) {
- Expression initExpression = new Expression(initExpr, initExprType);
+ Expression initExpression = Expression.create(initExpr, initExprType);
variableDefinition.setInitExpression(initExpression);
sources++;
}
@@ -695,7 +697,7 @@
ObjectDescriptor objectDescriptor = parseObjectDescriptor(element, parse);
userCodeReference.setDescriptor(objectDescriptor);
- if (objectDescriptor.getExpr()!=null) {
+ if (objectDescriptor.getExpression()!=null) {
// expressions are not cached by default
userCodeReference.setCached(false);
}
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -4,6 +4,8 @@
import org.jbpm.api.model.Activity;
import org.jbpm.jpdl.internal.activity.TaskActivity;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.el.StaticTextExpression;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
@@ -31,7 +33,8 @@
TaskDefinitionImpl taskDefinition = taskActivity.getTaskDefinition();
// check for properties not previously parsed
- assertEquals("first task", taskDefinition.getDescription());
+ StaticTextExpression descriptionExpression = (StaticTextExpression) taskDefinition.getDescription();
+ assertEquals("first task", descriptionExpression.getText());
assertEquals(3, taskDefinition.getPriority());
assertEquals("aForm", taskDefinition.getFormResourceName());
assertEquals("1 day", taskDefinition.getDueDateDescription());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -55,7 +55,7 @@
}
public VariableBuilder initialExpression(String initialExpression) {
- variableDefinition.setInitExpression(new Expression(initialExpression, null));
+ variableDefinition.setInitExpression(Expression.create(initialExpression, null));
return this;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -35,53 +35,60 @@
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-/**
+/** handles all expression resolving
+ *
* @author Tom Baeyens
*/
-public class Expression implements Serializable {
+public abstract class Expression implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String TYPE_METHOD = "method";
- public static final String TYPE_VALUE = "value";
+ public static final String LANGUAGE_UEL = "uel";
+ public static final String LANGUAGE_UEL_METHOD = "uel-method";
+ public static final String LANGUAGE_UEL_VALUE = "uel-value";
private static ExpressionFactory expressionFactory = null;
private static ELContext elContext = null;
- protected ValueExpression valueExpression;
- protected MethodExpression methodExpression;
-
- // paring ///////////////////////////////////////////////////////////////////
-
- public Expression(String expressionText, String exprType) {
+ public static Expression create(String expressionText, String language) {
// if there is an expr specified
if (expressionText==null) {
throw new JbpmException("expressionText is null");
}
+
+ if (language==null || language.startsWith(LANGUAGE_UEL)) {
+ if (expressionText.indexOf('{')==-1) {
+ return new StaticTextExpression(expressionText);
+ }
+ initExpressionObjects();
- initExpressionObjects();
-
- // by default, expr is interpreted as a value expression
- if (exprType==null || TYPE_VALUE.equals(exprType)) {
- try {
- valueExpression = expressionFactory.createValueExpression(elContext, expressionText, Object.class);
-
- // 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 = TYPE_METHOD;
- }
+ // by default, expr is interpreted as a value expression
+ if (language==null || LANGUAGE_UEL_VALUE.equals(language)) {
+ try {
+ ValueExpression valueExpression = expressionFactory.createValueExpression(elContext, expressionText, Object.class);
+
+ return new UelValueExpression(valueExpression);
+
+ // if the expr is not a valid value expr...
+ } catch (ELException e) {
+ // ... and the expr-type was not specified
+ if (language==null) {
+ // then try to parse it as a method expression
+ language = LANGUAGE_UEL_METHOD;
+ }
+ }
}
- }
- if (TYPE_METHOD.equals(exprType)) {
- methodExpression = expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
- }
+ if (LANGUAGE_UEL_METHOD.equals(language)) {
+ MethodExpression methodExpression = expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
+ return new UelMethodExpression(methodExpression);
+ }
+
+ }
+ return new ScriptExpression(expressionText, language);
}
- protected synchronized void initExpressionObjects() {
+ protected static synchronized void initExpressionObjects() {
if (elContext==null) {
JbpmElFactory jbpmElFactory = JbpmElFactory.getJbpmElFactory();
expressionFactory = jbpmElFactory.createExpressionFactory();
@@ -92,49 +99,23 @@
// runtime evaluation ///////////////////////////////////////////////////////
public Object evaluate(Execution execution) {
- return evaluate((ScopeInstanceImpl)execution);
+ return evaluateInScope((ScopeInstanceImpl)execution);
}
public Object evaluate(Task task) {
- return evaluate((ScopeInstanceImpl)task);
+ return evaluateInScope((ScopeInstanceImpl)task);
}
- protected Object evaluate(ScopeInstanceImpl scopeInstance) {
- ELContext elContext = getElContext(scopeInstance);
+ public abstract Object evaluateInScope(ScopeInstanceImpl scopeInstance);
- Object result = null;
- if (valueExpression!=null) {
- result = valueExpression.getValue(elContext);
-
- } else if (methodExpression!=null) {
- result = methodExpression.invoke((ELContext) elContext, null);
- }
-
- return result;
- }
-
- public void setValue(Task task, Object value) {
- setValue((ScopeInstanceImpl)task, value);
- }
-
- public void setValue(Execution execution, Object value) {
- setValue((ScopeInstanceImpl)execution, value);
- }
-
- public void setValue(ScopeInstanceImpl scopeInstance, Object value) {
- if (valueExpression==null) {
- throw new JbpmException("no value expression configured");
- }
- ELContext elContext = getElContext(scopeInstance);
- valueExpression.setValue(elContext, value);
- }
-
protected ELContext getElContext(ScopeInstanceImpl scopeInstance) {
ELContext elContext = (ELContext) (scopeInstance!=null ? scopeInstance.getElContext() : null);
if (elContext==null) {
JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
elContext = contextFactory.createElContext(scopeInstance);
- scopeInstance.setElContext(elContext);
+ if (scopeInstance!=null) {
+ scopeInstance.setElContext(elContext);
+ }
}
return elContext;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -119,10 +119,10 @@
}
protected void addBasicResolvers(CompositeELResolver compositeELResolver) {
- compositeELResolver.add(new BeanELResolver());
compositeELResolver.add(new MapELResolver());
compositeELResolver.add(new ListELResolver());
compositeELResolver.add(new ArrayELResolver());
+ compositeELResolver.add(new BeanELResolver());
}
protected FunctionMapper createFunctionMapper() {
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java (from rev 6149, jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -0,0 +1,47 @@
+/*
+ * 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 org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expressionText;
+ protected String language;
+
+ public ScriptExpression(String expressionText, String language) {
+ this.expressionText = expressionText;
+ this.language = language;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
+ return scriptManager.evaluateExpression(expressionText, language);
+ }
+}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java (from rev 6149, jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -0,0 +1,47 @@
+/*
+ * 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 org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StaticTextExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ String text;
+
+ public StaticTextExpression(String text) {
+ this.text = text;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ return text;
+ }
+
+ public String getText() {
+ return text;
+ }
+}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java (from rev 6149, jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -0,0 +1,47 @@
+/*
+ * 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.MethodExpression;
+
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UelMethodExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected MethodExpression methodExpression;
+
+ public UelMethodExpression(MethodExpression methodExpression) {
+ this.methodExpression = methodExpression;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = getElContext(scopeInstance);
+ return methodExpression.invoke((ELContext) elContext, null);
+ }
+}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java (from rev 6149, jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -0,0 +1,67 @@
+/*
+ * 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.ValueExpression;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UelValueExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected ValueExpression valueExpression;
+
+ public UelValueExpression(ValueExpression valueExpression) {
+ this.valueExpression = valueExpression;
+ if (valueExpression==null) {
+ throw new JbpmException("no value expression configured");
+ }
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = getElContext(scopeInstance);
+ return valueExpression.getValue(elContext);
+ }
+
+ public void setValue(Task task, Object value) {
+ setValue((ScopeInstanceImpl)task, value);
+ }
+
+ public void setValue(Execution execution, Object value) {
+ setValue((ScopeInstanceImpl)execution, value);
+ }
+
+ public void setValue(ScopeInstanceImpl scopeInstance, Object value) {
+ ELContext elContext = getElContext(scopeInstance);
+ valueExpression.setValue(elContext, value);
+ }
+
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -360,7 +360,7 @@
return activityBehaviour;
}
if (activityBehaviourDescriptor!=null) {
- ActivityBehaviour createdBehaviour = (ActivityBehaviour) ReflectUtil.instantiateUserCode(activityBehaviourDescriptor, processDefinition);
+ ActivityBehaviour createdBehaviour = (ActivityBehaviour) ReflectUtil.instantiateUserCode(activityBehaviourDescriptor, processDefinition, null);
if (!isActivityBehaviourStateful) {
activityBehaviour = createdBehaviour;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -60,7 +60,7 @@
return eventListener;
}
if (eventListenerDescriptor!=null) {
- EventListener createdEventListener = (EventListener) ReflectUtil.instantiateUserCode(eventListenerDescriptor, processDefinition);
+ EventListener createdEventListener = (EventListener) ReflectUtil.instantiateUserCode(eventListenerDescriptor, processDefinition, null);
if (!isEventListenerStateful) {
eventListener = createdEventListener;
}
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-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -49,6 +49,7 @@
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.Expression;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.ExecutionContext;
@@ -758,20 +759,18 @@
* SwimlaneDefinitionImpl is base class for TaskDefinitionImpl.
* Both Task and Swimlane implement Assignable. */
public void initializeAssignments(AssignableDefinitionImpl assignableDefinition, Assignable assignable) {
- String assigneeExpression = assignableDefinition.getAssigneeExpression();
+ Expression assigneeExpression = assignableDefinition.getAssigneeExpression();
if (assigneeExpression!=null) {
- String assignee = resolveAssignmentExpression(assigneeExpression,
- assignableDefinition.getAssigneeExpressionLanguage());
+ String assignee = (String) assigneeExpression.evaluate(this);
assignable.setAssignee(assignee);
if (log.isTraceEnabled()) log.trace("task "+name+" assigned to "+assignee+" using expression "+assigneeExpression);
}
- String candidateUsersExpression = assignableDefinition.getCandidateUsersExpression();
+ Expression candidateUsersExpression = assignableDefinition.getCandidateUsersExpression();
if (candidateUsersExpression!=null) {
- String candidateUsers =
- resolveAssignmentExpression(candidateUsersExpression,
- assignableDefinition.getCandidateUsersExpressionLanguage());
+ String candidateUsers = (String) candidateUsersExpression.evaluate(this);
+
StringTokenizer tokenizer = new StringTokenizer(candidateUsers, ",");
while (tokenizer.hasMoreTokens()) {
String candidateUser = tokenizer.nextToken().trim();
@@ -779,11 +778,9 @@
}
}
- String candidateGroupsExpression = assignableDefinition.getCandidateGroupsExpression();
+ Expression candidateGroupsExpression = assignableDefinition.getCandidateGroupsExpression();
if (candidateGroupsExpression!=null) {
- String candidateGroups =
- resolveAssignmentExpression(candidateGroupsExpression,
- assignableDefinition.getCandidateGroupsExpressionLanguage());
+ String candidateGroups = (String) candidateGroupsExpression.evaluate(this);
StringTokenizer tokenizer = new StringTokenizer(candidateGroups, ",");
while (tokenizer.hasMoreTokens()) {
String candidateGroup = tokenizer.nextToken();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -49,10 +49,10 @@
public Object getInitValue(ExecutionImpl execution) {
if (initDescriptor!=null) {
- return WireContext.create(initDescriptor);
+ return WireContext.create(initDescriptor, execution);
}
if (initExpression!=null) {
- return initExpression.evaluate(execution);
+ return initExpression.evaluateInScope(execution);
}
return null;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -31,6 +31,7 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -83,9 +84,6 @@
return defaultScriptManager;
}
- /** {@link #evaluate(String, Execution, String) evaluates} the expression
- * with the given language or with the defaultExpressionLanguage if the
- * given language is null. */
public Object evaluateExpression(String expression, String language) {
return evaluate(expression, (language!=null ? language : defaultExpressionLanguage));
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.task;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
@@ -33,14 +34,11 @@
private static final long serialVersionUID = 1L;
protected String name;
- protected String description;
+ protected Expression description;
- protected String assigneeExpression;
- protected String assigneeExpressionLanguage;
- protected String candidateUsersExpression;
- protected String candidateUsersExpressionLanguage;
- protected String candidateGroupsExpression;
- protected String candidateGroupsExpressionLanguage;
+ protected Expression assigneeExpression;
+ protected Expression candidateUsersExpression;
+ protected Expression candidateGroupsExpression;
protected UserCodeReference assignmentHandlerReference;
// equals ///////////////////////////////////////////////////////////////////
@@ -52,7 +50,7 @@
// getters and setters //////////////////////////////////////////////////////
- public String getAssigneeExpression() {
+ public Expression getAssigneeExpression() {
return assigneeExpression;
}
public String getName() {
@@ -61,13 +59,13 @@
public void setName(String name) {
this.name = name;
}
- public String getDescription() {
+ public Expression getDescription() {
return description;
}
- public void setDescription(String description) {
+ public void setDescription(Expression description) {
this.description = description;
}
- public void setAssigneeExpression(String assigneeExpression) {
+ public void setAssigneeExpression(Expression assigneeExpression) {
this.assigneeExpression = assigneeExpression;
}
public UserCodeReference getAssignmentHandlerReference() {
@@ -76,35 +74,16 @@
public void setAssignmentHandlerReference(UserCodeReference assignmentHandlerReference) {
this.assignmentHandlerReference = assignmentHandlerReference;
}
- public String getAssigneeExpressionLanguage() {
- return assigneeExpressionLanguage;
- }
- public void setAssigneeExpressionLanguage(String assigneeExpressionLanguage) {
- this.assigneeExpressionLanguage = assigneeExpressionLanguage;
- }
- public String getCandidateUsersExpression() {
+ public Expression getCandidateUsersExpression() {
return candidateUsersExpression;
}
- public void setCandidateUsersExpression(String candidateUsersExpression) {
+ public void setCandidateUsersExpression(Expression candidateUsersExpression) {
this.candidateUsersExpression = candidateUsersExpression;
}
- public String getCandidateUsersExpressionLanguage() {
- return candidateUsersExpressionLanguage;
- }
- public void setCandidateUsersExpressionLanguage(String candidateUsersExpressionLanguage) {
- this.candidateUsersExpressionLanguage = candidateUsersExpressionLanguage;
- }
- public String getCandidateGroupsExpression() {
+ public Expression getCandidateGroupsExpression() {
return candidateGroupsExpression;
}
- public void setCandidateGroupsExpression(String candidateGroupsExpression) {
+ public void setCandidateGroupsExpression(Expression candidateGroupsExpression) {
this.candidateGroupsExpression = candidateGroupsExpression;
}
- public String getCandidateGroupsExpressionLanguage() {
- return candidateGroupsExpressionLanguage;
- }
- public void setCandidateGroupsExpressionLanguage(String candidateGroupsExpressionLanguage) {
- this.candidateGroupsExpressionLanguage = candidateGroupsExpressionLanguage;
- }
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -11,6 +11,7 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.repository.DeploymentClassLoader;
import org.jbpm.pvm.internal.repository.RepositoryCache;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -304,10 +305,10 @@
}
}
- public static Object instantiateUserCode(Descriptor descriptor, ProcessDefinitionImpl processDefinition) {
+ public static Object instantiateUserCode(Descriptor descriptor, ProcessDefinitionImpl processDefinition, ScopeInstanceImpl scopeInstance) {
ClassLoader classLoader = ReflectUtil.installDeploymentClassLoader(processDefinition);
try {
- return WireContext.create(descriptor);
+ return WireContext.create(descriptor, scopeInstance);
} finally {
ReflectUtil.uninstallDeploymentClassLoader(classLoader);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -34,6 +34,7 @@
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
import org.jbpm.pvm.internal.util.Closable;
import org.jbpm.pvm.internal.util.DefaultObservable;
@@ -218,6 +219,10 @@
/** exceptions throw by descriptor invocations */
Map<String, Exception> exceptions = null;
+ /** scopeInstance is optional (can be null) and point to an execution or a task.
+ * In case a descriptor tries to resolve a name that is not found in this context,
+ * the search is continued in the execution or task */
+ ScopeInstanceImpl scopeInstance = null;
public WireContext() {
}
@@ -251,7 +256,13 @@
create();
}
}
-
+
+ public static Object create(Descriptor descriptor, ScopeInstanceImpl scopeInstance) {
+ WireContext wireContext = new WireContext();
+ wireContext.setScopeInstance(scopeInstance);
+ return wireContext.create(descriptor, false);
+ }
+
/** convenience method that wires the object for a given descriptor. */
public static Object create(Descriptor descriptor) {
WireContext wireContext = new WireContext();
@@ -417,6 +428,13 @@
return create(objectName, isDelayable);
}
+ // if the objectName is found in the execution or task
+ if (scopeInstance!=null) {
+ if (scopeInstance.hasVariable(objectName)) {
+ return scopeInstance.getVariable(objectName);
+ }
+ }
+
// then check if we can find it in the environment (if one is available)
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment!=null) {
@@ -717,4 +735,10 @@
public void setWireDefinition(WireDefinition wireDefinition) {
this.wireDefinition = wireDefinition;
}
+ public ScopeInstanceImpl getScopeInstance() {
+ return scopeInstance;
+ }
+ public void setScopeInstance(ScopeInstanceImpl scopeInstance) {
+ this.scopeInstance = scopeInstance;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Set;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
@@ -107,9 +108,8 @@
descriptor.setFactoryDescriptor(factoryDescriptor);
} else if (expr!=null) {
- descriptor.setExpr(expr);
- String lang = XmlUtil.attribute(element, "lang");
- descriptor.setLang(lang);
+ String exprType = XmlUtil.attribute(element, "expr-type");
+ descriptor.setExpression(Expression.create(expr, exprType));
} else {
parse.addProblem("element 'object' must have one of {attribute 'class', attribute 'expr', attribute 'factory' or element 'factory'}: "+XmlUtil.toString(element), element);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -10,8 +10,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.JbpmClassNotFoundException;
@@ -96,10 +96,8 @@
* */
String factoryObjectName = null;
- protected String expr;
+ protected Expression expression;
- protected String lang;
-
/** specifies the object on which to invoke the method.
* Either className, objectName or a descriptor has to be specified. */
protected Descriptor factoryDescriptor = null;
@@ -175,9 +173,8 @@
if (object==null) {
throw new WireException("created factory object is null, can't invoke method '"+methodName+"' on it");
}
- } else if (expr!=null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- object = scriptManager.evaluateExpression(expr, lang);
+ } else if (expression!=null) {
+ object = expression.evaluateInScope(wireContext.getScopeInstance());
}
if (methodName!=null) {
@@ -447,16 +444,10 @@
public void setAutoWireEnabled(boolean isAutoWireEnabled) {
this.isAutoWireEnabled = isAutoWireEnabled;
}
- public String getExpr() {
- return expr;
+ public Expression getExpression() {
+ return expression;
}
- public void setExpr(String expr) {
- this.expr = expr;
+ public void setExpression(Expression expr) {
+ this.expression = expr;
}
- public String getLang() {
- return lang;
- }
- public void setLang(String lang) {
- this.lang = lang;
- }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java 2010-01-29 15:52:11 UTC (rev 6149)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java 2010-01-29 20:40:00 UTC (rev 6150)
@@ -27,6 +27,7 @@
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -60,7 +61,7 @@
processDefinition = getProcessDefinition(execution);
}
- Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition);
+ Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition, (ScopeInstanceImpl) execution);
if (isCached) {
cachedObject = usedObject;
}
14 years, 3 months
JBoss JBPM SVN: r6149 - in jbpm4/branches/tbaeyens/modules: bpmn/src/main/java/org/jbpm/bpmn/parser and 13 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-29 10:52:11 -0500 (Fri, 29 Jan 2010)
New Revision: 6149
Added:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java
Removed:
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
Modified:
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
Log:
expression refactorings
Modified: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -3,6 +3,7 @@
import java.util.List;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
@@ -67,15 +68,13 @@
if (rae != null) {
String formalExpression = XmlUtil.element(rae, "formalExpression", true, parse).getTextContent().trim();
String lang = XmlUtil.attribute(rae, "language", false, parse);
+ Expression expression = Expression.create(formalExpression, lang);
if (PERFORMER.equals(type) || HUMAN_PERFORMER.equals(type)) {
- taskDefinition.setAssigneeExpression(formalExpression);
- taskDefinition.setAssigneeExpressionLanguage(lang);
+ taskDefinition.setAssigneeExpression(expression);
} else if (POTENTIAL_OWNER.equals(type) && "user".equals(scope)) { // default is group
- taskDefinition.setCandidateUsersExpression(formalExpression);
- taskDefinition.setCandidateUsersExpressionLanguage(lang);
+ taskDefinition.setCandidateUsersExpression(expression);
} else {
- taskDefinition.setCandidateGroupsExpression(formalExpression);
- taskDefinition.setCandidateGroupsExpressionLanguage(lang);
+ taskDefinition.setCandidateGroupsExpression(expression);
}
}
Modified: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -1,13 +1,11 @@
package org.jbpm.bpmn.flownodes;
import org.jbpm.bpmn.common.Resource;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
public class ActivityResource {
String id;
Resource resourceRef;
- ExpressionEvaluatorDescriptor resourceAssignmentExpression;
public String getId() {
return id;
@@ -24,14 +22,4 @@
public void setResourceRef(Resource resourceRef) {
this.resourceRef = resourceRef;
}
-
-
- public ExpressionEvaluatorDescriptor getResourceAssignmentExpression() {
- return resourceAssignmentExpression;
- }
-
- public void setResourceAssignmentExpression(ExpressionEvaluatorDescriptor resourceAssignmentExpression) {
- this.resourceAssignmentExpression = resourceAssignmentExpression;
- }
-
}
Modified: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -26,8 +26,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
@@ -43,8 +43,7 @@
private static final long serialVersionUID = 1L;
- protected String targetExpression;
- protected String targetLanguage;
+ protected Expression targetExpression;
protected Object target;
protected String methodName;
@@ -61,8 +60,7 @@
invocationTarget = target;
} else if (targetExpression!=null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- invocationTarget = scriptManager.evaluateExpression(targetExpression, targetLanguage);
+ invocationTarget = targetExpression.evaluate(execution);
} else {
throw new JbpmException("no target specified");
@@ -108,10 +106,7 @@
public void setInvokeOperation(InvokeOperation invokeOperation) {
this.invokeOperation = invokeOperation;
}
- public void setTargetExpression(String expression) {
+ public void setTargetExpression(Expression expression) {
this.targetExpression = expression;
}
- public void setTargetLanguage(String language) {
- this.targetLanguage = language;
- }
}
Modified: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -24,9 +24,8 @@
import java.util.Map;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.bpmn.parser.ExpressionEvaluator;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
@@ -35,7 +34,6 @@
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.wire.WireContext;
/**
* @author Tom Baeyens
@@ -60,11 +58,10 @@
task.setProcessInstance(execution.getProcessInstance());
task.setSignalling(true);
- if (taskDefinition.getAssigneeExpression() != null) {
- ExpressionEvaluatorDescriptor eed = new ExpressionEvaluatorDescriptor(taskDefinition.getAssigneeExpression(), taskDefinition
- .getAssigneeExpressionLanguage());
- ExpressionEvaluator ee = (ExpressionEvaluator) WireContext.create(eed);
- task.setAssignee((String) ee.evaluateExpression(execution));
+ Expression assigneeExpression = taskDefinition.getAssigneeExpression();
+ if (assigneeExpression != null) {
+ Object assignee = assigneeExpression.evaluate(execution);
+ task.setAssignee((assignee!=null ? assignee.toString() : null));
}
// initialize the name
@@ -74,7 +71,12 @@
task.setName(execution.getActivityName());
}
- task.setDescription(taskDefinition.getDescription());
+ Expression descriptionExpression = taskDefinition.getDescription();
+ if (descriptionExpression!=null) {
+ String description = (String) descriptionExpression.evaluate(task);
+ task.setDescription(description);
+ }
+
task.setPriority(taskDefinition.getPriority());
task.setFormResourceName(taskDefinition.getFormResourceName());
Deleted: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -1,57 +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.bpmn.parser;
-
-import org.jbpm.api.model.OpenExecution;
-import org.jbpm.pvm.internal.model.Condition;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * @author Tom Baeyens
- */
-public class ExpressionEvaluator implements Condition {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluator(String name, String expr, String lang) {
- this.name = name;
- this.expr = expr;
- this.lang = lang;
- }
-
- public boolean evaluate(OpenExecution execution) {
- return (Boolean) evaluateExpression(execution);
- }
-
- public Object evaluateExpression(OpenExecution execution) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- return scriptManager.evaluateExpression(expr, lang);
- }
-
- public String getName() {
- return name;
- }
-}
Deleted: jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -1,52 +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.bpmn.parser;
-
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
-
-
-/**
- * @author Tom Baeyens
- *
- * @deprecated to be replaced by {@link UserCodeReference} see also package org.jbpm.pvm.internal.wire.usercode
- */
-public class ExpressionEvaluatorDescriptor extends AbstractDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluatorDescriptor() {
- }
-
- public ExpressionEvaluatorDescriptor(String expr, String lang) {
- this.expr = expr;
- this.lang = lang;
- }
-
- public Object construct(WireContext wireContext) {
- return new ExpressionEvaluator(getName(), expr, lang);
- }
-
-}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -21,12 +21,10 @@
*/
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.el.Expression;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.el.UelValueExpression;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -42,7 +40,7 @@
protected Descriptor fromValueDescriptor;
protected String toVariableName;
- protected Expression toExpression;
+ protected UelValueExpression toExpression;
void perform(OpenExecution execution) throws Exception {
Object value = null;
@@ -51,7 +49,7 @@
value = fromExpression.evaluate(execution);
} else if (fromValueDescriptor!=null) {
- value = WireContext.create(fromValueDescriptor);
+ value = WireContext.create(fromValueDescriptor, (ScopeInstanceImpl) execution);
}
if (toVariableName!=null) {
@@ -70,7 +68,7 @@
public void setFromExpression(Expression fromExpression) {
this.fromExpression = fromExpression;
}
- public void setToExpression(Expression toExpression) {
+ public void setToExpression(UelValueExpression toExpression) {
this.toExpression = toExpression;
}
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -26,6 +26,7 @@
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.el.UelValueExpression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -50,8 +51,8 @@
if (toVar!=null) {
assignActivity.setToVariableName(toVar);
} else if (toExpr!=null) {
- Expression expression = new Expression(toExpr, Expression.TYPE_VALUE);
- assignActivity.setToExpression(expression);
+ Expression expression = Expression.create(toExpr, Expression.LANGUAGE_UEL_VALUE);
+ assignActivity.setToExpression((UelValueExpression) expression);
}
String exprText = XmlUtil.attribute(element, "expr");
@@ -59,7 +60,7 @@
// if there is an expr specified
if (exprText!=null) {
- Expression expression = new Expression(exprText, exprType);
+ Expression expression = Expression.create(exprText, exprType);
assignActivity.setFromExpression(expression);
} else { // there is no expr specified
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -24,6 +24,7 @@
import java.util.List;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExpressionCondition;
import org.jbpm.pvm.internal.model.TransitionImpl;
@@ -46,9 +47,10 @@
public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
if (element.hasAttribute("expr")) {
DecisionExpressionActivity decisionExpressionActivity = new DecisionExpressionActivity();
- String expr = element.getAttribute("expr");
- decisionExpressionActivity.setExpression(expr);
- decisionExpressionActivity.setLanguage(XmlUtil.attribute(element, "lang"));
+ String expressionText = element.getAttribute("expr");
+ String language = XmlUtil.attribute(element, "lang");
+ Expression expression = Expression.create(expressionText, language);
+ decisionExpressionActivity.setExpression(expression);
return decisionExpressionActivity;
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -25,8 +25,8 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.api.model.Transition;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
* @author Tom Baeyens
@@ -35,8 +35,7 @@
private static final long serialVersionUID = 1L;
- protected String expression;
- protected String language;
+ protected Expression expression;
public void execute(ActivityExecution execution) {
execute((ExecutionImpl) execution);
@@ -46,8 +45,7 @@
Activity activity = execution.getActivity();
String transitionName = null;
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- Object result = scriptManager.evaluateExpression(expression, language);
+ Object result = expression.evaluate(execution);
if ( (result!=null)
&& (! (result instanceof String))
) {
@@ -65,10 +63,7 @@
execution.take(transition);
}
- public void setExpression(String expr) {
- this.expression = expr;
+ public void setExpression(Expression expression) {
+ this.expression = expression;
}
- public void setLanguage(String lang) {
- this.language = lang;
- }
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/HqlActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -27,6 +27,7 @@
import org.jbpm.api.model.OpenExecution;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
@@ -58,7 +59,7 @@
if (parametersDescriptor!=null) {
for (Descriptor valueDescriptor: parametersDescriptor.getValueDescriptors()) {
String parameterName = valueDescriptor.getName();
- Object value = WireContext.create(valueDescriptor);
+ Object value = WireContext.create(valueDescriptor, (ScopeInstanceImpl) execution);
applyParameter(q, parameterName, value);
}
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -53,6 +53,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -69,8 +71,8 @@
private static final long serialVersionUID = 1L;
protected String type = null;
- protected String textExpression = null;
- protected String objectExpression = null;
+ protected Expression textExpression = null;
+ protected Expression objectExpression = null;
protected MapDescriptor mapDescriptor = null;
protected String connectionFactoryName = null;
protected String destinationName = null;
@@ -89,12 +91,12 @@
if (destination instanceof Queue) {
log.debug("destination '"+destinationName+"' is a Queue: using xa queue jms apis");
XAQueueConnectionFactory xaQueueConnectionFactory = (XAQueueConnectionFactory) connectionFactory;
- sendToQueueXA((Queue) destination, xaQueueConnectionFactory);
+ sendToQueueXA((Queue) destination, xaQueueConnectionFactory, (ExecutionImpl) execution);
} else if (destination instanceof Topic) {
log.debug("destination '"+destinationName+"' is a Topic: using xa topic jms apis");
XATopicConnectionFactory xaTopicConnectionFactory = (XATopicConnectionFactory) connectionFactory;
- sendToTopicXA((Topic) destination, xaTopicConnectionFactory);
+ sendToTopicXA((Topic) destination, xaTopicConnectionFactory, (ExecutionImpl) execution);
} else {
throw new JbpmException("invalid destination type for '"+destinationName+"': "+destination.getClass().getName());
@@ -105,12 +107,12 @@
if (destination instanceof Queue) {
log.debug("destination '"+destinationName+"' is a Queue: using non-xa queue jms apis");
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) connectionFactory;
- sendToQueue((Queue) destination, queueConnectionFactory);
+ sendToQueue((Queue) destination, queueConnectionFactory, (ExecutionImpl) execution);
} else if (destination instanceof Topic) {
log.debug("destination '"+destinationName+"' is a Topic: using non-xa topic jms apis");
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) connectionFactory;
- sendToTopic((Topic) destination, topicConnectionFactory);
+ sendToTopic((Topic) destination, topicConnectionFactory, (ExecutionImpl) execution);
} else {
throw new JbpmException("invalid destination type for '"+destinationName+"': "+destination.getClass().getName());
@@ -127,7 +129,7 @@
}
}
- protected void sendToQueueXA(Queue queue, XAQueueConnectionFactory xaQueueConnectionFactory) throws Exception {
+ protected void sendToQueueXA(Queue queue, XAQueueConnectionFactory xaQueueConnectionFactory, ExecutionImpl execution) throws Exception {
XAQueueConnection xaQueueConnection = null;
XAQueueSession xaQueueSession = null;
MessageProducer messageProducer = null;
@@ -136,7 +138,7 @@
xaQueueConnection = xaQueueConnectionFactory.createXAQueueConnection();
xaQueueSession = xaQueueConnection.createXAQueueSession();
messageProducer = xaQueueSession.createProducer(queue);
- Message message = createMessage(xaQueueSession);
+ Message message = createMessage(xaQueueSession, execution);
messageProducer.send(message);
} finally {
@@ -158,7 +160,7 @@
}
}
- protected void sendToTopicXA(Topic topic, XATopicConnectionFactory xaTopicConnectionFactory) throws Exception {
+ protected void sendToTopicXA(Topic topic, XATopicConnectionFactory xaTopicConnectionFactory, ExecutionImpl execution) throws Exception {
XATopicConnection xaTopicConnection = null;
XATopicSession xaTopicSession = null;
MessageProducer messageProducer = null;
@@ -167,7 +169,7 @@
xaTopicConnection = xaTopicConnectionFactory.createXATopicConnection();
xaTopicSession = xaTopicConnection.createXATopicSession();
messageProducer = xaTopicSession.createProducer(topic);
- Message message = createMessage(xaTopicSession);
+ Message message = createMessage(xaTopicSession, execution);
messageProducer.send(message);
} finally {
@@ -189,7 +191,7 @@
}
}
- protected void sendToQueue(Queue queue, QueueConnectionFactory queueConnectionFactory) throws Exception {
+ protected void sendToQueue(Queue queue, QueueConnectionFactory queueConnectionFactory, ExecutionImpl execution) throws Exception {
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
@@ -198,7 +200,7 @@
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(transacted, acknowledgeMode);
queueSender = queueSession.createSender(queue);
- Message message = createMessage(queueSession);
+ Message message = createMessage(queueSession, execution);
queueSender.send(message);
if (transacted) {
queueSession.commit();
@@ -223,7 +225,7 @@
}
}
- protected void sendToTopic(Topic topic, TopicConnectionFactory topicConnectionFactory) throws Exception {
+ protected void sendToTopic(Topic topic, TopicConnectionFactory topicConnectionFactory, ExecutionImpl execution) throws Exception {
TopicConnection topicConnection = null;
TopicSession topicSession = null;
TopicPublisher topicPublisher = null;
@@ -232,7 +234,7 @@
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(transacted, acknowledgeMode);
topicPublisher = topicSession.createPublisher(topic);
- Message message = createMessage(topicSession);
+ Message message = createMessage(topicSession, execution);
topicPublisher.send(message);
if (transacted) {
topicSession.commit();
@@ -257,18 +259,18 @@
}
}
- protected Message createMessage(Session session) throws Exception {
+ protected Message createMessage(Session session, ExecutionImpl execution) throws Exception {
if ("text".equals(type)) {
- return createTextMessage(session);
+ return createTextMessage(session, execution);
} else if ("object".equals(type)) {
- return createObjectMessage(session);
+ return createObjectMessage(session, execution);
} else if ("map".equals(type)) {
- return createMapMessage(session);
+ return createMapMessage(session, execution);
}
throw new JbpmException("no type configured in jms activity");
}
- private MapMessage createMapMessage(Session session) throws Exception {
+ private MapMessage createMapMessage(Session session, ExecutionImpl execution) throws Exception {
MapMessage result = session.createMapMessage();
if (mapDescriptor != null) {
List<Descriptor> keyDescriptors = mapDescriptor.getKeyDescriptors();
@@ -282,16 +284,16 @@
return result;
}
- private TextMessage createTextMessage(Session session) throws Exception {
- Object value = ScriptManager.getScriptManager().evaluateExpression(textExpression, null);
+ private TextMessage createTextMessage(Session session, ExecutionImpl execution) throws Exception {
+ Object value = textExpression.evaluate(execution);
if (value!=null) {
return session.createTextMessage(value.toString());
}
throw new JbpmException("null value for expression '"+textExpression+"' in jms activity");
}
- private ObjectMessage createObjectMessage(Session session) throws Exception {
- Object object = ScriptManager.getScriptManager().evaluateExpression(objectExpression, null);
+ private ObjectMessage createObjectMessage(Session session, ExecutionImpl execution) throws Exception {
+ Object object = objectExpression.evaluate(execution);
if ( (object!=null)
&& !(object instanceof Serializable)
) {
@@ -303,11 +305,11 @@
public void setType(String type) {
this.type = type;
}
- public void setText(String text) {
- this.textExpression = text;
+ public void setTextExpression(Expression textExpression) {
+ this.textExpression = textExpression;
}
- public void setExpression(String expression) {
- this.objectExpression = expression;
+ public void setObjectExpression(Expression objectExpression) {
+ this.objectExpression = objectExpression;
}
public void setMapDescriptor(MapDescriptor mapDescriptor) {
this.mapDescriptor = mapDescriptor;
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -24,6 +24,7 @@
import javax.jms.Session;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
@@ -78,15 +79,18 @@
Element textElement = XmlUtil.element(element, "text", false, parse);
if (textElement != null) {
- String text = XmlUtil.getContentText(textElement);
+ String expressionText = XmlUtil.getContentText(textElement);
jmsActivity.setType("text");
- jmsActivity.setText(text);
+ Expression expression = Expression.create(expressionText, Expression.LANGUAGE_UEL);
+ jmsActivity.setTextExpression(expression);
}
Element objectElement = XmlUtil.element(element, "object", false, parse);
if (objectElement != null) {
jmsActivity.setType("object");
- jmsActivity.setExpression(XmlUtil.attribute(objectElement, "expr"));
+ String expressionText = XmlUtil.attribute(objectElement, "expr");
+ Expression expression = Expression.create(expressionText, Expression.LANGUAGE_UEL);
+ jmsActivity.setObjectExpression(expression);
}
Element mapElement = XmlUtil.element(element, "map", false, parse);
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -24,6 +24,7 @@
import java.util.List;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -54,8 +55,8 @@
if (factExpr!=null) {
String factLang = XmlUtil.attribute(factElement, "lang");
- rulesFact.setExpression(factExpr);
- rulesFact.setLanguage(factLang);
+ Expression expression = Expression.create(factExpr, factLang);
+ rulesFact.setExpression(expression);
} else {
parse.addProblem("'fact' element inside 'rules' activity requires attribute 'var' or 'expr'", element);
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesFact.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -24,7 +24,7 @@
import java.io.Serializable;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.el.Expression;
/**
* @author Tom Baeyens
@@ -34,7 +34,7 @@
private static final long serialVersionUID = 1L;
protected String variableName;
- protected String expression;
+ protected Expression expression;
protected String language;
public String getVariableName() {
@@ -45,11 +45,11 @@
this.variableName = variableName;
}
- public String getExpression() {
+ public Expression getExpression() {
return expression;
}
- public void setExpression(String expression) {
+ public void setExpression(Expression expression) {
this.expression = expression;
}
@@ -66,7 +66,7 @@
return execution.getVariable(variableName);
} else if (expression!=null) {
- return ScriptManager.getScriptManager().evaluateExpression(expression, language);
+ return expression.evaluate(execution);
}
return null;
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -27,12 +27,12 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.ExecutionContext;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
-import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
@@ -51,7 +51,7 @@
protected List<SubProcessInParameterImpl> inParameters;
protected List<SubProcessOutParameterImpl> outParameters;
- protected String outcomeExpression;
+ protected Expression outcomeExpression;
protected Map<Object, String> outcomeVariableMappings;
public void execute(ActivityExecution execution) {
@@ -122,8 +122,7 @@
String subProcessActivityName = subProcessInstance.getActivityName();
if (outcomeExpression!=null) {
- ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
- Object value = scriptManager.evaluateExpression(outcomeExpression, null);
+ Object value = outcomeExpression.evaluate(executionImpl);
// if the value is a String and matches the name of an outgoing transition
if ( (value instanceof String)
&& (activity.hasOutgoingTransition(((String) value)))
@@ -169,7 +168,7 @@
public void setSubProcessId(String subProcessId) {
this.subProcessId = subProcessId;
}
- public void setOutcomeExpression(String outcomeExpression) {
+ public void setOutcomeExpression(Expression outcomeExpression) {
this.outcomeExpression = outcomeExpression;
}
public List<SubProcessInParameterImpl> getInParameters() {
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -27,6 +27,7 @@
import java.util.Map;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -102,8 +103,10 @@
Map<Object, String> outcomeVariableMappings = new HashMap<Object, String>();
- String outcomeExpression = XmlUtil.attribute(element, "outcome");
- if (outcomeExpression!=null) {
+ String outcomeExpressionText = XmlUtil.attribute(element, "outcome");
+ String outcomeLanguage = XmlUtil.attribute(element, "outcome-lang");
+ if (outcomeExpressionText!=null) {
+ Expression outcomeExpression = Expression.create(outcomeExpressionText, outcomeLanguage);
subProcessActivity.setOutcomeExpression(outcomeExpression);
for (Element transitionElement: XmlUtil.elements(element, "transition")) {
@@ -133,15 +136,12 @@
String name = XmlUtil.attribute(element, "subvar");
parameter.setSubVariableName(name);
- String expr = XmlUtil.attribute(element, "expr");
- if (expr!=null) {
- parameter.setExpression(expr);
+ String expressionText = XmlUtil.attribute(element, "expr");
+ String language = XmlUtil.attribute(element, "expr-lang");
+ if (expressionText!=null) {
+ Expression expression = Expression.create(expressionText, language);
+ parameter.setExpression(expression);
}
-
- String language = XmlUtil.attribute(element, "lang");
- if (language!=null) {
- parameter.setLanguage(language);
- }
String variable = XmlUtil.attribute(element, "var");
if (variable!=null) {
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessInParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -22,7 +22,6 @@
package org.jbpm.jpdl.internal.activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
@@ -37,8 +36,7 @@
if (variableName!=null) {
value = superExecution.getVariable(variableName);
} else {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- value = scriptManager.evaluateExpression(expression, language);
+ value = expression.evaluateInScope(superExecution);
}
subProcessInstance.setVariable(subVariableName, value);
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessOutParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -23,7 +23,6 @@
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
/**
@@ -39,8 +38,7 @@
if (variableName!=null) {
value = subProcessInstance.getVariable(subVariableName);
} else {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- value = scriptManager.evaluateExpression(expression, language);
+ value = expression.evaluateInScope(subProcessInstance);
}
superExecution.setVariable(variableName, value);
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessParameterImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -23,7 +23,9 @@
import java.io.Serializable;
+import org.jbpm.pvm.internal.el.Expression;
+
/**
* @author Tom Baeyens
*/
@@ -33,8 +35,7 @@
protected String subVariableName;
protected String variableName;
- protected String expression;
- protected String language;
+ protected Expression expression;
public String getVariableName() {
return variableName;
@@ -42,18 +43,12 @@
public void setVariableName(String variable) {
this.variableName = variable;
}
- public String getExpression() {
+ public Expression getExpression() {
return expression;
}
- public void setExpression(String expression) {
+ public void setExpression(Expression expression) {
this.expression = expression;
}
- public String getLanguage() {
- return language;
- }
- public void setLanguage(String language) {
- this.language = language;
- }
public String getSubVariableName() {
return subVariableName;
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -28,6 +28,7 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Transition;
import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
@@ -71,12 +72,9 @@
task.setName(execution.getActivityName());
}
- String description = taskDefinition.getDescription();
- if (description != null) {
- if (description.contains("#{")) {
- Object result = ScriptManager.getScriptManager().evaluateExpression(description, null);
- description = result instanceof String ? (String) result : result.toString();
- }
+ Expression descriptionExpression = taskDefinition.getDescription();
+ if (descriptionExpression != null) {
+ String description = (String) descriptionExpression.evaluate(task);
task.setDescription(description);
}
task.setPriority(taskDefinition.getPriority());
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -57,8 +57,6 @@
import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableOutDefinitionImpl;
-import org.jbpm.pvm.internal.model.VariableOutDefinitionSet;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
@@ -494,8 +492,9 @@
public void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
Element descriptionElement = XmlUtil.element(element, "description");
if (descriptionElement!=null) {
- String description = XmlUtil.getContentText(descriptionElement);
- assignableDefinition.setDescription(description);
+ String descriptionText = XmlUtil.getContentText(descriptionElement);
+ Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL);
+ assignableDefinition.setDescription(descriptionExpression);
}
Element assignmentHandlerElement = XmlUtil.element(element, "assignment-handler");
@@ -504,23 +503,26 @@
assignableDefinition.setAssignmentHandlerReference(assignmentHandlerReference);
}
- String assigneeExpression = XmlUtil.attribute(element, "assignee");
- assignableDefinition.setAssigneeExpression(assigneeExpression);
+ String assigneeExpressionText = XmlUtil.attribute(element, "assignee");
+ if (assigneeExpressionText!=null) {
+ String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
+ Expression assigneeExpression = Expression.create(assigneeExpressionText, assigneeExpressionLanguage);
+ assignableDefinition.setAssigneeExpression(assigneeExpression);
+ }
- String assigneeExpressionLanguage = XmlUtil.attribute(element, "assignee-lang");
- assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
-
- String candidateUsersExpression = XmlUtil.attribute(element, "candidate-users");
- assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
-
- String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
- assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
-
- String candidateGroupsExpression = XmlUtil.attribute(element, "candidate-groups");
- assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
-
- String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
- assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
+ String candidateUsersExpressionText = XmlUtil.attribute(element, "candidate-users");
+ if (candidateUsersExpressionText!=null) {
+ String candidateUsersExpressionLanguage = XmlUtil.attribute(element, "candidate-users-lang");
+ Expression candidateUsersExpression = Expression.create(candidateUsersExpressionText, candidateUsersExpressionLanguage);
+ assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
+ }
+
+ String candidateGroupsExpressionText = XmlUtil.attribute(element, "candidate-groups");
+ if (candidateGroupsExpressionText!=null) {
+ String candidateGroupsExpressionLanguage = XmlUtil.attribute(element, "candidate-groups-lang");
+ Expression candidateGroupsExpression = Expression.create(candidateGroupsExpressionText, candidateGroupsExpressionLanguage);
+ assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
+ }
}
public TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
@@ -594,7 +596,7 @@
String initExpr = XmlUtil.attribute(variableElement, "init-expr");
String initExprType = XmlUtil.attribute(variableElement, "init-expr-type");
if (initExpr!=null) {
- Expression initExpression = new Expression(initExpr, initExprType);
+ Expression initExpression = Expression.create(initExpr, initExprType);
variableDefinition.setInitExpression(initExpression);
sources++;
}
@@ -695,7 +697,7 @@
ObjectDescriptor objectDescriptor = parseObjectDescriptor(element, parse);
userCodeReference.setDescriptor(objectDescriptor);
- if (objectDescriptor.getExpr()!=null) {
+ if (objectDescriptor.getExpression()!=null) {
// expressions are not cached by default
userCodeReference.setCached(false);
}
Modified: jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -4,6 +4,8 @@
import org.jbpm.api.model.Activity;
import org.jbpm.jpdl.internal.activity.TaskActivity;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.el.Expression;
+import org.jbpm.pvm.internal.el.StaticTextExpression;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
@@ -31,7 +33,8 @@
TaskDefinitionImpl taskDefinition = taskActivity.getTaskDefinition();
// check for properties not previously parsed
- assertEquals("first task", taskDefinition.getDescription());
+ StaticTextExpression descriptionExpression = (StaticTextExpression) taskDefinition.getDescription();
+ assertEquals("first task", descriptionExpression.getText());
assertEquals(3, taskDefinition.getPriority());
assertEquals("aForm", taskDefinition.getFormResourceName());
assertEquals("1 day", taskDefinition.getDueDateDescription());
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -55,7 +55,7 @@
}
public VariableBuilder initialExpression(String initialExpression) {
- variableDefinition.setInitExpression(new Expression(initialExpression, null));
+ variableDefinition.setInitExpression(Expression.create(initialExpression, null));
return this;
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -35,53 +35,60 @@
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-/**
+/** handles all expression resolving
+ *
* @author Tom Baeyens
*/
-public class Expression implements Serializable {
+public abstract class Expression implements Serializable {
private static final long serialVersionUID = 1L;
- public static final String TYPE_METHOD = "method";
- public static final String TYPE_VALUE = "value";
+ public static final String LANGUAGE_UEL = "uel";
+ public static final String LANGUAGE_UEL_METHOD = "uel-method";
+ public static final String LANGUAGE_UEL_VALUE = "uel-value";
private static ExpressionFactory expressionFactory = null;
private static ELContext elContext = null;
- protected ValueExpression valueExpression;
- protected MethodExpression methodExpression;
-
- // paring ///////////////////////////////////////////////////////////////////
-
- public Expression(String expressionText, String exprType) {
+ public static Expression create(String expressionText, String language) {
// if there is an expr specified
if (expressionText==null) {
throw new JbpmException("expressionText is null");
}
+
+ if (language==null || language.startsWith(LANGUAGE_UEL)) {
+ if (expressionText.indexOf('{')==-1) {
+ return new StaticTextExpression(expressionText);
+ }
+ initExpressionObjects();
- initExpressionObjects();
-
- // by default, expr is interpreted as a value expression
- if (exprType==null || TYPE_VALUE.equals(exprType)) {
- try {
- valueExpression = expressionFactory.createValueExpression(elContext, expressionText, Object.class);
-
- // 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 = TYPE_METHOD;
- }
+ // by default, expr is interpreted as a value expression
+ if (language==null || LANGUAGE_UEL_VALUE.equals(language)) {
+ try {
+ ValueExpression valueExpression = expressionFactory.createValueExpression(elContext, expressionText, Object.class);
+
+ return new UelValueExpression(valueExpression);
+
+ // if the expr is not a valid value expr...
+ } catch (ELException e) {
+ // ... and the expr-type was not specified
+ if (language==null) {
+ // then try to parse it as a method expression
+ language = LANGUAGE_UEL_METHOD;
+ }
+ }
}
- }
- if (TYPE_METHOD.equals(exprType)) {
- methodExpression = expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
- }
+ if (LANGUAGE_UEL_METHOD.equals(language)) {
+ MethodExpression methodExpression = expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
+ return new UelMethodExpression(methodExpression);
+ }
+
+ }
+ return new ScriptExpression(expressionText, language);
}
- protected synchronized void initExpressionObjects() {
+ protected static synchronized void initExpressionObjects() {
if (elContext==null) {
JbpmElFactory jbpmElFactory = JbpmElFactory.getJbpmElFactory();
expressionFactory = jbpmElFactory.createExpressionFactory();
@@ -92,49 +99,23 @@
// runtime evaluation ///////////////////////////////////////////////////////
public Object evaluate(Execution execution) {
- return evaluate((ScopeInstanceImpl)execution);
+ return evaluateInScope((ScopeInstanceImpl)execution);
}
public Object evaluate(Task task) {
- return evaluate((ScopeInstanceImpl)task);
+ return evaluateInScope((ScopeInstanceImpl)task);
}
- protected Object evaluate(ScopeInstanceImpl scopeInstance) {
- ELContext elContext = getElContext(scopeInstance);
+ public abstract Object evaluateInScope(ScopeInstanceImpl scopeInstance);
- Object result = null;
- if (valueExpression!=null) {
- result = valueExpression.getValue(elContext);
-
- } else if (methodExpression!=null) {
- result = methodExpression.invoke((ELContext) elContext, null);
- }
-
- return result;
- }
-
- public void setValue(Task task, Object value) {
- setValue((ScopeInstanceImpl)task, value);
- }
-
- public void setValue(Execution execution, Object value) {
- setValue((ScopeInstanceImpl)execution, value);
- }
-
- public void setValue(ScopeInstanceImpl scopeInstance, Object value) {
- if (valueExpression==null) {
- throw new JbpmException("no value expression configured");
- }
- ELContext elContext = getElContext(scopeInstance);
- valueExpression.setValue(elContext, value);
- }
-
protected ELContext getElContext(ScopeInstanceImpl scopeInstance) {
ELContext elContext = (ELContext) (scopeInstance!=null ? scopeInstance.getElContext() : null);
if (elContext==null) {
JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
elContext = contextFactory.createElContext(scopeInstance);
- scopeInstance.setElContext(elContext);
+ if (scopeInstance!=null) {
+ scopeInstance.setElContext(elContext);
+ }
}
return elContext;
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/JbpmElFactoryImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -119,10 +119,10 @@
}
protected void addBasicResolvers(CompositeELResolver compositeELResolver) {
- compositeELResolver.add(new BeanELResolver());
compositeELResolver.add(new MapELResolver());
compositeELResolver.add(new ListELResolver());
compositeELResolver.add(new ArrayELResolver());
+ compositeELResolver.add(new BeanELResolver());
}
protected FunctionMapper createFunctionMapper() {
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -0,0 +1,47 @@
+/*
+ * 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 org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ScriptExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expressionText;
+ protected String language;
+
+ public ScriptExpression(String expressionText, String language) {
+ this.expressionText = expressionText;
+ this.language = language;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
+ return scriptManager.evaluateExpression(expressionText, language);
+ }
+}
Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/ScriptExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -0,0 +1,47 @@
+/*
+ * 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 org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StaticTextExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ String text;
+
+ public StaticTextExpression(String text) {
+ this.text = text;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ return text;
+ }
+
+ public String getText() {
+ return text;
+ }
+}
Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/StaticTextExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -0,0 +1,47 @@
+/*
+ * 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.MethodExpression;
+
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UelMethodExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected MethodExpression methodExpression;
+
+ public UelMethodExpression(MethodExpression methodExpression) {
+ this.methodExpression = methodExpression;
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = getElContext(scopeInstance);
+ return methodExpression.invoke((ELContext) elContext, null);
+ }
+}
Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelMethodExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java (rev 0)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -0,0 +1,67 @@
+/*
+ * 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.ValueExpression;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UelValueExpression extends Expression {
+
+ private static final long serialVersionUID = 1L;
+
+ protected ValueExpression valueExpression;
+
+ public UelValueExpression(ValueExpression valueExpression) {
+ this.valueExpression = valueExpression;
+ if (valueExpression==null) {
+ throw new JbpmException("no value expression configured");
+ }
+ }
+
+ public Object evaluateInScope(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = getElContext(scopeInstance);
+ return valueExpression.getValue(elContext);
+ }
+
+ public void setValue(Task task, Object value) {
+ setValue((ScopeInstanceImpl)task, value);
+ }
+
+ public void setValue(Execution execution, Object value) {
+ setValue((ScopeInstanceImpl)execution, value);
+ }
+
+ public void setValue(ScopeInstanceImpl scopeInstance, Object value) {
+ ELContext elContext = getElContext(scopeInstance);
+ valueExpression.setValue(elContext, value);
+ }
+
+}
Property changes on: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/UelValueExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -360,7 +360,7 @@
return activityBehaviour;
}
if (activityBehaviourDescriptor!=null) {
- ActivityBehaviour createdBehaviour = (ActivityBehaviour) ReflectUtil.instantiateUserCode(activityBehaviourDescriptor, processDefinition);
+ ActivityBehaviour createdBehaviour = (ActivityBehaviour) ReflectUtil.instantiateUserCode(activityBehaviourDescriptor, processDefinition, null);
if (!isActivityBehaviourStateful) {
activityBehaviour = createdBehaviour;
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -60,7 +60,7 @@
return eventListener;
}
if (eventListenerDescriptor!=null) {
- EventListener createdEventListener = (EventListener) ReflectUtil.instantiateUserCode(eventListenerDescriptor, processDefinition);
+ EventListener createdEventListener = (EventListener) ReflectUtil.instantiateUserCode(eventListenerDescriptor, processDefinition, null);
if (!isEventListenerStateful) {
eventListener = createdEventListener;
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -49,6 +49,7 @@
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.Expression;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.ExecutionContext;
@@ -758,20 +759,18 @@
* SwimlaneDefinitionImpl is base class for TaskDefinitionImpl.
* Both Task and Swimlane implement Assignable. */
public void initializeAssignments(AssignableDefinitionImpl assignableDefinition, Assignable assignable) {
- String assigneeExpression = assignableDefinition.getAssigneeExpression();
+ Expression assigneeExpression = assignableDefinition.getAssigneeExpression();
if (assigneeExpression!=null) {
- String assignee = resolveAssignmentExpression(assigneeExpression,
- assignableDefinition.getAssigneeExpressionLanguage());
+ String assignee = (String) assigneeExpression.evaluate(this);
assignable.setAssignee(assignee);
if (log.isTraceEnabled()) log.trace("task "+name+" assigned to "+assignee+" using expression "+assigneeExpression);
}
- String candidateUsersExpression = assignableDefinition.getCandidateUsersExpression();
+ Expression candidateUsersExpression = assignableDefinition.getCandidateUsersExpression();
if (candidateUsersExpression!=null) {
- String candidateUsers =
- resolveAssignmentExpression(candidateUsersExpression,
- assignableDefinition.getCandidateUsersExpressionLanguage());
+ String candidateUsers = (String) candidateUsersExpression.evaluate(this);
+
StringTokenizer tokenizer = new StringTokenizer(candidateUsers, ",");
while (tokenizer.hasMoreTokens()) {
String candidateUser = tokenizer.nextToken().trim();
@@ -779,11 +778,9 @@
}
}
- String candidateGroupsExpression = assignableDefinition.getCandidateGroupsExpression();
+ Expression candidateGroupsExpression = assignableDefinition.getCandidateGroupsExpression();
if (candidateGroupsExpression!=null) {
- String candidateGroups =
- resolveAssignmentExpression(candidateGroupsExpression,
- assignableDefinition.getCandidateGroupsExpressionLanguage());
+ String candidateGroups = (String) candidateGroupsExpression.evaluate(this);
StringTokenizer tokenizer = new StringTokenizer(candidateGroups, ",");
while (tokenizer.hasMoreTokens()) {
String candidateGroup = tokenizer.nextToken();
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -49,10 +49,10 @@
public Object getInitValue(ExecutionImpl execution) {
if (initDescriptor!=null) {
- return WireContext.create(initDescriptor);
+ return WireContext.create(initDescriptor, execution);
}
if (initExpression!=null) {
- return initExpression.evaluate(execution);
+ return initExpression.evaluateInScope(execution);
}
return null;
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/script/ScriptManager.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -31,6 +31,7 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -83,9 +84,6 @@
return defaultScriptManager;
}
- /** {@link #evaluate(String, Execution, String) evaluates} the expression
- * with the given language or with the defaultExpressionLanguage if the
- * given language is null. */
public Object evaluateExpression(String expression, String language) {
return evaluate(expression, (language!=null ? language : defaultExpressionLanguage));
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.task;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
@@ -33,14 +34,11 @@
private static final long serialVersionUID = 1L;
protected String name;
- protected String description;
+ protected Expression description;
- protected String assigneeExpression;
- protected String assigneeExpressionLanguage;
- protected String candidateUsersExpression;
- protected String candidateUsersExpressionLanguage;
- protected String candidateGroupsExpression;
- protected String candidateGroupsExpressionLanguage;
+ protected Expression assigneeExpression;
+ protected Expression candidateUsersExpression;
+ protected Expression candidateGroupsExpression;
protected UserCodeReference assignmentHandlerReference;
// equals ///////////////////////////////////////////////////////////////////
@@ -52,7 +50,7 @@
// getters and setters //////////////////////////////////////////////////////
- public String getAssigneeExpression() {
+ public Expression getAssigneeExpression() {
return assigneeExpression;
}
public String getName() {
@@ -61,13 +59,13 @@
public void setName(String name) {
this.name = name;
}
- public String getDescription() {
+ public Expression getDescription() {
return description;
}
- public void setDescription(String description) {
+ public void setDescription(Expression description) {
this.description = description;
}
- public void setAssigneeExpression(String assigneeExpression) {
+ public void setAssigneeExpression(Expression assigneeExpression) {
this.assigneeExpression = assigneeExpression;
}
public UserCodeReference getAssignmentHandlerReference() {
@@ -76,35 +74,16 @@
public void setAssignmentHandlerReference(UserCodeReference assignmentHandlerReference) {
this.assignmentHandlerReference = assignmentHandlerReference;
}
- public String getAssigneeExpressionLanguage() {
- return assigneeExpressionLanguage;
- }
- public void setAssigneeExpressionLanguage(String assigneeExpressionLanguage) {
- this.assigneeExpressionLanguage = assigneeExpressionLanguage;
- }
- public String getCandidateUsersExpression() {
+ public Expression getCandidateUsersExpression() {
return candidateUsersExpression;
}
- public void setCandidateUsersExpression(String candidateUsersExpression) {
+ public void setCandidateUsersExpression(Expression candidateUsersExpression) {
this.candidateUsersExpression = candidateUsersExpression;
}
- public String getCandidateUsersExpressionLanguage() {
- return candidateUsersExpressionLanguage;
- }
- public void setCandidateUsersExpressionLanguage(String candidateUsersExpressionLanguage) {
- this.candidateUsersExpressionLanguage = candidateUsersExpressionLanguage;
- }
- public String getCandidateGroupsExpression() {
+ public Expression getCandidateGroupsExpression() {
return candidateGroupsExpression;
}
- public void setCandidateGroupsExpression(String candidateGroupsExpression) {
+ public void setCandidateGroupsExpression(Expression candidateGroupsExpression) {
this.candidateGroupsExpression = candidateGroupsExpression;
}
- public String getCandidateGroupsExpressionLanguage() {
- return candidateGroupsExpressionLanguage;
- }
- public void setCandidateGroupsExpressionLanguage(String candidateGroupsExpressionLanguage) {
- this.candidateGroupsExpressionLanguage = candidateGroupsExpressionLanguage;
- }
-
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/ReflectUtil.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -11,6 +11,7 @@
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.repository.DeploymentClassLoader;
import org.jbpm.pvm.internal.repository.RepositoryCache;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -304,10 +305,10 @@
}
}
- public static Object instantiateUserCode(Descriptor descriptor, ProcessDefinitionImpl processDefinition) {
+ public static Object instantiateUserCode(Descriptor descriptor, ProcessDefinitionImpl processDefinition, ScopeInstanceImpl scopeInstance) {
ClassLoader classLoader = ReflectUtil.installDeploymentClassLoader(processDefinition);
try {
- return WireContext.create(descriptor);
+ return WireContext.create(descriptor, scopeInstance);
} finally {
ReflectUtil.uninstallDeploymentClassLoader(classLoader);
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -34,6 +34,7 @@
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
import org.jbpm.pvm.internal.util.Closable;
import org.jbpm.pvm.internal.util.DefaultObservable;
@@ -218,6 +219,10 @@
/** exceptions throw by descriptor invocations */
Map<String, Exception> exceptions = null;
+ /** scopeInstance is optional (can be null) and point to an execution or a task.
+ * In case a descriptor tries to resolve a name that is not found in this context,
+ * the search is continued in the execution or task */
+ ScopeInstanceImpl scopeInstance = null;
public WireContext() {
}
@@ -251,7 +256,13 @@
create();
}
}
-
+
+ public static Object create(Descriptor descriptor, ScopeInstanceImpl scopeInstance) {
+ WireContext wireContext = new WireContext();
+ wireContext.setScopeInstance(scopeInstance);
+ return wireContext.create(descriptor, false);
+ }
+
/** convenience method that wires the object for a given descriptor. */
public static Object create(Descriptor descriptor) {
WireContext wireContext = new WireContext();
@@ -417,6 +428,13 @@
return create(objectName, isDelayable);
}
+ // if the objectName is found in the execution or task
+ if (scopeInstance!=null) {
+ if (scopeInstance.hasVariable(objectName)) {
+ return scopeInstance.getVariable(objectName);
+ }
+ }
+
// then check if we can find it in the environment (if one is available)
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment!=null) {
@@ -717,4 +735,10 @@
public void setWireDefinition(WireDefinition wireDefinition) {
this.wireDefinition = wireDefinition;
}
+ public ScopeInstanceImpl getScopeInstance() {
+ return scopeInstance;
+ }
+ public void setScopeInstance(ScopeInstanceImpl scopeInstance) {
+ this.scopeInstance = scopeInstance;
+ }
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Set;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
@@ -107,9 +108,8 @@
descriptor.setFactoryDescriptor(factoryDescriptor);
} else if (expr!=null) {
- descriptor.setExpr(expr);
- String lang = XmlUtil.attribute(element, "lang");
- descriptor.setLang(lang);
+ String exprType = XmlUtil.attribute(element, "expr-type");
+ descriptor.setExpression(Expression.create(expr, exprType));
} else {
parse.addProblem("element 'object' must have one of {attribute 'class', attribute 'expr', attribute 'factory' or element 'factory'}: "+XmlUtil.toString(element), element);
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ObjectDescriptor.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -10,8 +10,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.JbpmClassNotFoundException;
@@ -96,10 +96,8 @@
* */
String factoryObjectName = null;
- protected String expr;
+ protected Expression expression;
- protected String lang;
-
/** specifies the object on which to invoke the method.
* Either className, objectName or a descriptor has to be specified. */
protected Descriptor factoryDescriptor = null;
@@ -175,9 +173,8 @@
if (object==null) {
throw new WireException("created factory object is null, can't invoke method '"+methodName+"' on it");
}
- } else if (expr!=null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- object = scriptManager.evaluateExpression(expr, lang);
+ } else if (expression!=null) {
+ object = expression.evaluateInScope(wireContext.getScopeInstance());
}
if (methodName!=null) {
@@ -447,16 +444,10 @@
public void setAutoWireEnabled(boolean isAutoWireEnabled) {
this.isAutoWireEnabled = isAutoWireEnabled;
}
- public String getExpr() {
- return expr;
+ public Expression getExpression() {
+ return expression;
}
- public void setExpr(String expr) {
- this.expr = expr;
+ public void setExpression(Expression expr) {
+ this.expression = expr;
}
- public String getLang() {
- return lang;
- }
- public void setLang(String lang) {
- this.lang = lang;
- }
}
Modified: jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
===================================================================
--- jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java 2010-01-29 12:00:59 UTC (rev 6148)
+++ jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java 2010-01-29 15:52:11 UTC (rev 6149)
@@ -27,6 +27,7 @@
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -60,7 +61,7 @@
processDefinition = getProcessDefinition(execution);
}
- Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition);
+ Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition, (ScopeInstanceImpl) execution);
if (isCached) {
cachedObject = usedObject;
}
14 years, 3 months
JBoss JBPM SVN: r6148 - jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-29 07:00:59 -0500 (Fri, 29 Jan 2010)
New Revision: 6148
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessBinding.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
Log:
Began work on SubProcess + small refactoring for all activities
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -69,8 +69,6 @@
resetMemberFields();
- super.parse(element, parse);
-
id = element.getAttribute("id");
name = element.getAttribute("name");
@@ -111,7 +109,6 @@
outgoing = 0;
outSequenceFlows = new ArrayList<Element>();
valid = true;
- default_ = null;
}
protected boolean validGatewayDirection(Parse parse, String elementName, Element element) {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -3,10 +3,10 @@
import java.util.List;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -26,9 +26,8 @@
public AbstractTaskBinding(String tagName) {
super(tagName);
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
ManualTaskActivity manualTaskActivity = new ManualTaskActivity();
manualTaskActivity.setDefault(getDefault());
return manualTaskActivity;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -29,6 +29,7 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.api.model.Transition;
import org.jbpm.internal.log.Log;
@@ -56,6 +57,12 @@
protected String default_;
protected List<ActivityResource> activityResources = new ArrayList<ActivityResource>();
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execute((ExecutionImpl) execution);
+ }
+
+ public abstract void execute(ExecutionImpl executionImpl);
/**
* In BPMN multiple outgoing sequence flows behave like a fork.
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnAutomaticActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -1,6 +1,5 @@
package org.jbpm.bpmn.flownodes;
-import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.listener.EventListener;
import org.jbpm.api.listener.EventListenerExecution;
import org.jbpm.api.model.OpenExecution;
@@ -10,9 +9,8 @@
public abstract class BpmnAutomaticActivity extends BpmnActivity implements EventListener {
private static final long serialVersionUID = 1L;
-
- public void execute(ActivityExecution execution) throws Exception {
- ExecutionImpl executionImpl = (ExecutionImpl)execution;
+
+ public void execute(ExecutionImpl executionImpl) {
perform(executionImpl);
executionImpl.historyAutomatic();
}
@@ -21,5 +19,6 @@
perform(execution);
}
- abstract void perform(OpenExecution execution) throws Exception;
+ abstract void perform(OpenExecution execution);
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -25,6 +25,7 @@
import org.jbpm.pvm.internal.util.TagBinding;
import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
public abstract class BpmnBinding extends TagBinding {
@@ -36,13 +37,16 @@
public BpmnBinding(String tagName) {
super(tagName, "http://schema.omg.org/spec/BPMN/2.0", null);
}
-
- public void parse(Element element, Parse parse) {
+
+ public Object parse(Element element, Parse parse, Parser parser) {
this.default_ = null;
if (element.hasAttribute("default")) {
default_ = element.getAttribute("default");
}
+ return parse(element, parse, (BpmnParser) parser);
}
+
+ public abstract Object parse(Element element, Parse parse, BpmnParser bpmnParser);
public String getDefault() {
return default_;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,9 +21,9 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -39,17 +39,18 @@
protected EndEventBinding(String tag) {
super(tag);
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- EndActivity endActivity = new EndActivity();
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
+EndActivity endActivity = new EndActivity();
Element terminateEventDefinition = XmlUtil.element(element, "terminateEventDefinition");
if (terminateEventDefinition != null) {
- endActivity.setEndProcessInstance(true);
+ endActivity.setEndProcessInstance(true);
} else {
- endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
+ endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
}
return endActivity;
}
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,22 +21,22 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
* @author Tom Baeyens
* @author Ronald van Kuijk (kukeltje)
- *
+ * @author Joram Barrez
*/
public class ExclusiveGatewayBinding extends AbstractGatewayBinding {
public ExclusiveGatewayBinding() {
super("exclusiveGateway");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
super.parse(element, parse);
validateConditionOnAllSequenceFlow(parse, element);
@@ -50,4 +50,5 @@
return exclusiveGatewayActivity;
}
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,8 +21,8 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -33,8 +33,8 @@
public InclusiveGatewayBinding() {
super("inclusiveGateway");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
super.parse(element, parse);
validateConditionOnAllSequenceFlow(parse, element);
@@ -45,7 +45,7 @@
InclusiveGatewayActivity inclusiveGatewayActivity = new InclusiveGatewayActivity();
inclusiveGatewayActivity.setDefault(default_);
inclusiveGatewayActivity.setGatewayDirection(gatewayDirection);
- return inclusiveGatewayActivity;
+ return inclusiveGatewayActivity;
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -27,7 +27,6 @@
import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -38,13 +37,12 @@
public IntermediateCatchEventBinding() {
super("intermediateCatchEvent");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
-
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
String id = XmlUtil.attribute(element, "id");
Element eventDefinition = XmlUtil.element(element);
if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
- return createIntermediateTimerCatchEvent(id, eventDefinition, (BpmnParser) parser, parse);
+ return createIntermediateTimerCatchEvent(id, eventDefinition, bpmnParser, parse);
} else {
parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -51,7 +51,7 @@
protected String variableName;
protected InvokeOperation invokeOperation;
- public void perform(OpenExecution execution) throws Exception {
+ public void perform(OpenExecution execution) {
Object invocationTarget = null;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -1,6 +1,6 @@
package org.jbpm.bpmn.flownodes;
-import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
/**
* Manual activities in BPMN are ignored by the Process Engine.
@@ -12,6 +12,6 @@
private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) {
+ public void execute(ExecutionImpl executionImpl) {
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,8 +21,8 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -33,9 +33,8 @@
public ManualTaskBinding() {
super("manualTask");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
ManualTaskActivity manualTaskActivity = new ManualTaskActivity();
manualTaskActivity.setDefault(getDefault());
return manualTaskActivity;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,8 +21,8 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -37,9 +37,8 @@
public ParallelGatewayBinding() {
super("parallelGateway");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
-
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
super.parse(element, parse);
if (!valid) {
@@ -50,4 +49,5 @@
parallelGatewayActivity.setGatewayDirection(gatewayDirection);
return parallelGatewayActivity;
}
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,8 +21,8 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -31,9 +31,8 @@
public ReceiveBinding() {
super("receiveTask");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
ReceiveActivity receiveActivity = new ReceiveActivity();
receiveActivity.setDefault(getDefault());
return receiveActivity;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -34,7 +34,7 @@
private String script;
- public void perform(OpenExecution execution) throws Exception {
+ public void perform(OpenExecution execution) {
try {
ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -21,9 +21,9 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -33,10 +33,8 @@
public ScriptTaskBinding() {
super("scriptTask");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
-
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
String scriptLanguage = XmlUtil.attribute(element, "scriptLanguage");
String script = XmlUtil.element(element, "script").getTextContent();
@@ -47,4 +45,5 @@
return scriptTaskActivity;
}
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -24,13 +24,13 @@
import java.util.List;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.descriptor.ArgDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.operation.InvokeOperation;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
public class ServiceTaskBinding extends BpmnBinding {
@@ -40,18 +40,17 @@
public ServiceTaskBinding() {
super(TAG);
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
JavaServiceTaskActivity javaActivity = new JavaServiceTaskActivity();
-
+
BpmnProcessDefinition bpmnProcessDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
// Operation parsing
String operationRef = XmlUtil.attribute(element, "operationRef", true, parse, null);
Element operationElement = bpmnProcessDefinition.getOperations().get(operationRef);
if (operationElement == null) {
- parse.addProblem("No operation found for operationRef " + operationRef, operationElement);
+ parse.addProblem("No operation found for operationRef " + operationRef, operationElement);
}
// Interface parsing
@@ -98,4 +97,5 @@
return javaActivity;
}
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -33,7 +33,6 @@
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -45,8 +44,8 @@
public StartEventBinding() {
super("startEvent");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
ActivityImpl startActivity = parse.contextStackFind(ActivityImpl.class);
BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
@@ -60,7 +59,7 @@
String id = XmlUtil.attribute(element, "id", true, parse);
Element eventDefinition = XmlUtil.element(element);
if (eventDefinition != null && "timerEventDefinition".equals(eventDefinition.getNodeName())) {
- return createTimerStartEvent(processDefinition, eventDefinition, id, (BpmnParser) parser, parse);
+ return createTimerStartEvent(processDefinition, eventDefinition, id, bpmnParser, parse);
} else if (eventDefinition != null){
parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
}
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessActivity.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessActivity.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.api.model.Activity;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class SubProcessActivity extends BpmnActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionImpl executionImpl) {
+ }
+
+ /**
+ * The start activities of a sub-process are either none start events or
+ * activities without incoming sequence flow.
+ */
+ protected List<Activity> findStartActivities(ExecutionImpl execution) {
+ List<Activity> startActivities = new ArrayList<Activity>();
+
+ for (Activity nestedActivity : execution.getActivity().getActivities()) {
+ if ( (nestedActivity.getIncomingTransitions()==null)
+ || (nestedActivity.getIncomingTransitions().isEmpty())) {
+ startActivities.add(nestedActivity);
+ }
+ }
+
+ return startActivities;
+ }
+
+}
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessBinding.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/SubProcessBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+/**
+ * @author Joram Barrez
+ */
+public class SubProcessBinding extends BpmnBinding {
+
+ protected static final String TAG_NAME = "subProcess";
+
+ public SubProcessBinding(String tagName) {
+ super(TAG_NAME);
+ }
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
+ SubProcessActivity subProcessActivity = new SubProcessActivity();
+
+ ActivityImpl activity = parse.contextStackFind(ActivityImpl.class);
+ bpmnParser.parseActivities(element, parse, activity);
+
+ // TODO only none start event is allowed!
+
+ subProcessActivity.setDefault(getDefault());
+ return subProcessActivity;
+ }
+
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -25,7 +25,6 @@
import org.jbpm.pvm.internal.model.ScopeElementImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -36,13 +35,11 @@
public TaskBinding() {
super("task");
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
-
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
TaskActivity taskActivity = new TaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = ((BpmnParser)parser).parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = bpmnParser.parseTaskDefinition(element, parse, scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
taskActivity.setDefault(getDefault());
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2010-01-28 16:22:07 UTC (rev 6147)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2010-01-29 12:00:59 UTC (rev 6148)
@@ -26,7 +26,6 @@
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
/**
@@ -40,13 +39,12 @@
public UserTaskBinding() {
super(TAG);
}
-
- public Object parse(Element element, Parse parse, Parser parser) {
- super.parse(element, parse);
+
+ public Object parse(Element element, Parse parse, BpmnParser bpmnParser) {
UserTaskActivity taskActivity = new UserTaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = ((BpmnParser) parser).parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = bpmnParser.parseTaskDefinition(element, parse, scopeElement);
addActivityResources(taskDefinition, taskActivity, element, parse);
14 years, 3 months
JBoss JBPM SVN: r6147 - jbpm4/branches.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-28 11:22:07 -0500 (Thu, 28 Jan 2010)
New Revision: 6147
Added:
jbpm4/branches/tbaeyens/
Log:
creating personal tbaeyens branch
Copied: jbpm4/branches/tbaeyens (from rev 6146, jbpm4/trunk)
14 years, 3 months
JBoss JBPM SVN: r6146 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/internal/xml and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-28 11:19:56 -0500 (Thu, 28 Jan 2010)
New Revision: 6146
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
Log:
various fixes
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java 2010-01-28 13:51:51 UTC (rev 6145)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java 2010-01-28 16:19:56 UTC (rev 6146)
@@ -23,7 +23,6 @@
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.usercode.UserCodeActivityBehaviour;
import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
import org.jbpm.pvm.internal.xml.Parse;
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-28 13:51:51 UTC (rev 6145)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-28 16:19:56 UTC (rev 6146)
@@ -614,24 +614,6 @@
}
}
- public VariableOutDefinitionSet parseVariableOutDefinitionSet(Element element, Parse parse) {
- VariableOutDefinitionSet variableOutDefinitionSet = new VariableOutDefinitionSet();
-
- for (Element inElement: XmlUtil.elements(element, "out-variable")) {
- VariableOutDefinitionImpl variableOutDefinition = variableOutDefinitionSet.createVariableOutDefinition();
-
- String name = XmlUtil.attribute(inElement, "name", true, parse);
- variableOutDefinition.setName(name);
-
- String expression = XmlUtil.attribute(inElement, "init");
- if (expression!=null) {
- variableOutDefinition.setExpression(expression);
- }
- }
-
- return variableOutDefinitionSet;
- }
-
public void parseMailEvent(Element element, Parse parse,
ObservableElementImpl observableElement, String eventName) {
// obtain assign event
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-28 13:51:51 UTC (rev 6145)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-28 16:19:56 UTC (rev 6146)
@@ -32,7 +32,6 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
@@ -93,15 +92,27 @@
// runtime evaluation ///////////////////////////////////////////////////////
public Object evaluate(Execution execution) {
- ELContext elContext = getElContext((ExecutionImpl) execution);
- return getResult(elContext);
+ return evaluate((ScopeInstanceImpl)execution);
}
public Object evaluate(Task task) {
- ELContext elContext = getElContext((ExecutionImpl) task);
- return getResult(elContext);
+ return evaluate((ScopeInstanceImpl)task);
}
+
+ protected Object evaluate(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = getElContext(scopeInstance);
+ Object result = null;
+ if (valueExpression!=null) {
+ result = valueExpression.getValue(elContext);
+
+ } else if (methodExpression!=null) {
+ result = methodExpression.invoke((ELContext) elContext, null);
+ }
+
+ return result;
+ }
+
public void setValue(Task task, Object value) {
setValue((ScopeInstanceImpl)task, value);
}
@@ -119,7 +130,7 @@
}
protected ELContext getElContext(ScopeInstanceImpl scopeInstance) {
- ELContext elContext = (ELContext) scopeInstance.getElContext();
+ ELContext elContext = (ELContext) (scopeInstance!=null ? scopeInstance.getElContext() : null);
if (elContext==null) {
JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
elContext = contextFactory.createElContext(scopeInstance);
@@ -127,16 +138,4 @@
}
return elContext;
}
-
- protected Object getResult(ELContext elContext) {
- Object result = null;
- if (valueExpression!=null) {
- result = valueExpression.getValue(elContext);
-
- } else if (methodExpression!=null) {
- result = methodExpression.invoke((ELContext) elContext, null);
- }
-
- return result;
- }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java 2010-01-28 13:51:51 UTC (rev 6145)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java 2010-01-28 16:19:56 UTC (rev 6146)
@@ -88,7 +88,7 @@
eventListenerIndex++;
execution.setEventListenerIndex(eventListenerIndex);
}
-
+
// if there are more listeners in this event
if ( (eventListenerReferences!=null)
&& (eventListenerIndex < eventListenerReferences.size())
14 years, 3 months
JBoss JBPM SVN: r6145 - projects/jsf-console/tags.
by do-not-reply@jboss.org
Author: jcoleman(a)redhat.com
Date: 2010-01-28 08:51:51 -0500 (Thu, 28 Jan 2010)
New Revision: 6145
Added:
projects/jsf-console/tags/jsf-console-3.3.1.SP1/
Log:
Create 3.3.1.SP1 tag from 3.3.1.SP branch
Copied: projects/jsf-console/tags/jsf-console-3.3.1.SP1 (from rev 6144, projects/jsf-console/branches/jsf-console-3.3.1.SP)
14 years, 3 months
JBoss JBPM SVN: r6144 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/builder and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-28 04:50:19 -0500 (Thu, 28 Jan 2010)
New Revision: 6144
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
Log:
JBPM-2776 finished variable declarations
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-28 09:13:45 UTC (rev 6143)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-28 09:50:19 UTC (rev 6144)
@@ -39,6 +39,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.Expression;
import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
import org.jbpm.pvm.internal.email.impl.MailTemplate;
import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
@@ -241,6 +242,9 @@
}
}
+ // variable declarations
+ parseVariableDefinitions(documentElement, parse, processDefinition);
+
// on events
parseOnEvents(documentElement, parse, processDefinition);
@@ -298,6 +302,7 @@
activity.setType(activityBinding.getTagName());
activityBinding.parseName(nestedElement, activity, parse);
parseTransitions(nestedElement, activity, parse);
+ parseVariableDefinitions(nestedElement, parse, activity);
Element descriptionElement = XmlUtil.element(documentElement, "description");
if (descriptionElement!=null) {
@@ -572,41 +577,41 @@
return taskDefinition;
}
- public List<VariableDefinitionImpl> parseVariableDefinitions(Element element, Parse parse, boolean initRequired) {
+ public void parseVariableDefinitions(Element element, Parse parse, ScopeElementImpl scopeElement) {
List<VariableDefinitionImpl> variableDefinitions = new ArrayList<VariableDefinitionImpl>();
- for (Element inElement: XmlUtil.elements(element, "variable")) {
- VariableDefinitionImpl variableDefinition = new VariableDefinitionImpl();
+ for (Element variableElement: XmlUtil.elements(element, "variable")) {
+ VariableDefinitionImpl variableDefinition = scopeElement.createVariableDefinition();
- String name = XmlUtil.attribute(inElement, "name", true, parse);
+ String name = XmlUtil.attribute(variableElement, "name", true, parse);
variableDefinition.setName(name);
+ String type = XmlUtil.attribute(variableElement, "type", true, parse);
+ variableDefinition.setTypeName(type);
+
int sources = 0;
- String initExpr = XmlUtil.attribute(inElement, "init");
+ String initExpr = XmlUtil.attribute(variableElement, "init-expr");
+ String initExprType = XmlUtil.attribute(variableElement, "init-expr-type");
if (initExpr!=null) {
- variableDefinition.setInitExpression(initExpr);
+ Expression initExpression = new Expression(initExpr, initExprType);
+ variableDefinition.setInitExpression(initExpression);
sources++;
}
- Element valueElement = XmlUtil.element(inElement);
- if (valueElement!=null) {
- Descriptor initValueDescriptor = (Descriptor) WireParser.getInstance().parseElement(valueElement, parse);
+ Element initDescriptorElement = XmlUtil.element(variableElement);
+ if (initDescriptorElement!=null) {
+ Descriptor initValueDescriptor = (Descriptor) wireParser.parseElement(initDescriptorElement, parse);
variableDefinition.setInitDescriptor(initValueDescriptor);
sources++;
}
- if (initRequired && sources==0) {
- parse.addProblem("no init specified", inElement);
- }
if (sources>1) {
- parse.addProblem("init attribute and init element are mutually exclusive on element variable", inElement);
+ parse.addProblem("init attribute and init element are mutually exclusive on element variable", variableElement);
}
variableDefinitions.add(variableDefinition);
}
-
- return variableDefinitions;
}
public VariableOutDefinitionSet parseVariableOutDefinitionSet(Element element, Parse parse) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-28 09:13:45 UTC (rev 6143)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/VariableBuilder.java 2010-01-28 09:50:19 UTC (rev 6144)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.builder;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -54,7 +55,7 @@
}
public VariableBuilder initialExpression(String initialExpression) {
- variableDefinition.setInitExpression(initialExpression);
+ variableDefinition.setInitExpression(new Expression(initialExpression, null));
return this;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-28 09:13:45 UTC (rev 6143)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/VariableDefinitionImpl.java 2010-01-28 09:50:19 UTC (rev 6144)
@@ -23,8 +23,7 @@
import java.io.Serializable;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -45,8 +44,7 @@
protected String typeName;
protected boolean isHistoryEnabled;
- protected String initExpression;
- protected String initLanguage;
+ protected Expression initExpression;
protected Descriptor initDescriptor;
public Object getInitValue(ExecutionImpl execution) {
@@ -54,8 +52,7 @@
return WireContext.create(initDescriptor);
}
if (initExpression!=null) {
- ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
- return scriptManager.evaluateExpression(initExpression, initLanguage);
+ return initExpression.evaluate(execution);
}
return null;
}
@@ -66,10 +63,10 @@
public void setName(String name) {
this.name = name;
}
- public String getInitExpression() {
+ public Expression getInitExpression() {
return initExpression;
}
- public void setInitExpression(String initExpression) {
+ public void setInitExpression(Expression initExpression) {
this.initExpression = initExpression;
}
public Descriptor getInitDescriptor() {
@@ -84,12 +81,6 @@
public void setTypeName(String typeName) {
this.typeName = typeName;
}
- public String getInitLanguage() {
- return initLanguage;
- }
- public void setInitLanguage(String initLanguage) {
- this.initLanguage = initLanguage;
- }
public boolean isHistoryEnabled() {
return isHistoryEnabled;
}
14 years, 3 months
JBoss JBPM SVN: r6143 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/internal/xml and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-28 04:13:45 -0500 (Thu, 28 Jan 2010)
New Revision: 6143
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
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/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
Log:
JBPM-2653 refactoring: grouped all expression related operations in Expression class. this should also ensure there is only a library dependancy on the javax.el apis if expressions are actually used
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-28 08:51:56 UTC (rev 6142)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignActivity.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -25,6 +25,7 @@
import javax.el.ValueExpression;
import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -37,24 +38,18 @@
private static final long serialVersionUID = 1L;
- protected ValueExpression fromValueExpression;
- protected MethodExpression fromMethodExpression;
+ protected Expression fromExpression;
protected Descriptor fromValueDescriptor;
protected String toVariableName;
- protected ValueExpression toValueExpression;
+ protected Expression toExpression;
void perform(OpenExecution execution) throws Exception {
Object value = null;
- if (fromValueExpression!=null) {
- ExecutionImpl executionImpl = (ExecutionImpl) execution;
- value = executionImpl.resolveElValueExpressionGet(fromValueExpression);
+ if (fromExpression!=null) {
+ value = fromExpression.evaluate(execution);
- } else if (fromMethodExpression!=null) {
- ExecutionImpl executionImpl = (ExecutionImpl) execution;
- value = executionImpl.resolveElMethodExpressionInvoke(fromMethodExpression);
-
} else if (fromValueDescriptor!=null) {
value = WireContext.create(fromValueDescriptor);
}
@@ -62,24 +57,20 @@
if (toVariableName!=null) {
execution.setVariable(toVariableName, value);
} else {
- ExecutionImpl executionImpl = (ExecutionImpl) execution;
- executionImpl.resolveElValueExpressionSet(toValueExpression, value);
+ toExpression.setValue(execution, value);
}
}
- public void setFromValueExpression(ValueExpression fromValueExpression) {
- this.fromValueExpression = fromValueExpression;
- }
- public void setFromMethodExpression(MethodExpression methodExpression) {
- this.fromMethodExpression = methodExpression;
- }
public void setToVariableName(String variableName) {
this.toVariableName = variableName;
}
- public void setToValueExpression(ValueExpression toValueExpression) {
- this.toValueExpression = toValueExpression;
- }
public void setFromValueDescriptor(Descriptor valueDescriptor) {
this.fromValueDescriptor = valueDescriptor;
}
+ public void setFromExpression(Expression fromExpression) {
+ this.fromExpression = fromExpression;
+ }
+ public void setToExpression(Expression toExpression) {
+ this.toExpression = toExpression;
+ }
}
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-28 08:51:56 UTC (rev 6142)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/AssignBinding.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -24,11 +24,8 @@
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.el.Expression;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -53,8 +50,8 @@
if (toVar!=null) {
assignActivity.setToVariableName(toVar);
} else if (toExpr!=null) {
- ValueExpression valueExpression = parser.createValueExpression(toExpr);
- assignActivity.setToValueExpression(valueExpression);
+ Expression expression = new Expression(toExpr, Expression.TYPE_VALUE);
+ assignActivity.setToExpression(expression);
}
String exprText = XmlUtil.attribute(element, "expr");
@@ -62,27 +59,9 @@
// 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";
- }
- }
- }
+ Expression expression = new Expression(exprText, exprType);
+ assignActivity.setFromExpression(expression);
- 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;
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-28 08:51:56 UTC (rev 6142)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -31,11 +31,6 @@
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;
@@ -44,7 +39,6 @@
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;
@@ -119,9 +113,6 @@
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();
@@ -741,22 +732,4 @@
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();
- }
- }
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -0,0 +1,142 @@
+/*
+ * 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.io.Serializable;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Expression implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String TYPE_METHOD = "method";
+ public static final String TYPE_VALUE = "value";
+
+ private static ExpressionFactory expressionFactory = null;
+ private static ELContext elContext = null;
+
+ protected ValueExpression valueExpression;
+ protected MethodExpression methodExpression;
+
+ // paring ///////////////////////////////////////////////////////////////////
+
+ public Expression(String expressionText, String exprType) {
+ // if there is an expr specified
+ if (expressionText==null) {
+ throw new JbpmException("expressionText is null");
+ }
+
+ initExpressionObjects();
+
+ // by default, expr is interpreted as a value expression
+ if (exprType==null || TYPE_VALUE.equals(exprType)) {
+ try {
+ valueExpression = expressionFactory.createValueExpression(elContext, expressionText, Object.class);
+
+ // 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 = TYPE_METHOD;
+ }
+ }
+ }
+
+ if (TYPE_METHOD.equals(exprType)) {
+ methodExpression = expressionFactory.createMethodExpression(elContext, expressionText, null, new Class<?>[]{});
+ }
+ }
+
+ protected synchronized void initExpressionObjects() {
+ if (elContext==null) {
+ JbpmElFactory jbpmElFactory = JbpmElFactory.getJbpmElFactory();
+ expressionFactory = jbpmElFactory.createExpressionFactory();
+ elContext = jbpmElFactory.createElContext();
+ }
+ }
+
+ // runtime evaluation ///////////////////////////////////////////////////////
+
+ public Object evaluate(Execution execution) {
+ ELContext elContext = getElContext((ExecutionImpl) execution);
+ return getResult(elContext);
+ }
+
+ public Object evaluate(Task task) {
+ ELContext elContext = getElContext((ExecutionImpl) task);
+ return getResult(elContext);
+ }
+
+ public void setValue(Task task, Object value) {
+ setValue((ScopeInstanceImpl)task, value);
+ }
+
+ public void setValue(Execution execution, Object value) {
+ setValue((ScopeInstanceImpl)execution, value);
+ }
+
+ public void setValue(ScopeInstanceImpl scopeInstance, Object value) {
+ if (valueExpression==null) {
+ throw new JbpmException("no value expression configured");
+ }
+ ELContext elContext = getElContext(scopeInstance);
+ valueExpression.setValue(elContext, value);
+ }
+
+ protected ELContext getElContext(ScopeInstanceImpl scopeInstance) {
+ ELContext elContext = (ELContext) scopeInstance.getElContext();
+ if (elContext==null) {
+ JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
+ elContext = contextFactory.createElContext(scopeInstance);
+ scopeInstance.setElContext(elContext);
+ }
+ return elContext;
+ }
+
+ protected Object getResult(ELContext elContext) {
+ Object result = null;
+ if (valueExpression!=null) {
+ result = valueExpression.getValue(elContext);
+
+ } else if (methodExpression!=null) {
+ result = methodExpression.invoke((ELContext) elContext, null);
+ }
+
+ return result;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.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-28 08:51:56 UTC (rev 6142)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.model;
-import java.io.PrintWriter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -35,11 +34,6 @@
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.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
@@ -55,8 +49,6 @@
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.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;
@@ -87,8 +79,6 @@
import org.jbpm.pvm.internal.util.Priority;
import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
-import de.odysseus.el.TreeValueExpression;
-
/**
* @author Tom Baeyens
*/
@@ -167,8 +157,6 @@
protected int eventListenerIndex;
protected ObservableElementImpl eventSource;
-
- protected Object cachedElContext = null;
// cached named executions //////////////////////////////////////////////////
@@ -685,31 +673,6 @@
}
}
- public Object resolveElValueExpressionGet(ValueExpression valueExpression) {
- initCachedElContext();
- return valueExpression.getValue((ELContext) cachedElContext);
- }
-
- public void resolveElValueExpressionSet(ValueExpression valueExpression, Object value) {
- initCachedElContext();
-
- log.debug("expression: "+valueExpression);
-
- valueExpression.setValue((ELContext) cachedElContext, value);
- }
-
- public Object resolveElMethodExpressionInvoke(MethodExpression methodExpression) {
- initCachedElContext();
- return methodExpression.invoke((ELContext) cachedElContext, null);
- }
-
- protected void initCachedElContext() {
- if (cachedElContext==null) {
- JbpmElFactory contextFactory = JbpmElFactory.getJbpmElFactory();
- cachedElContext = contextFactory.createElContext(this);
- }
- }
-
/**
* Important: Only use this if resolving an expression on another execution then the current execution
*
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-28 08:51:56 UTC (rev 6142)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-28 09:13:45 UTC (rev 6143)
@@ -65,7 +65,10 @@
protected String state;
protected String suspendHistoryState;
-
+
+ /** {@link Expression}s can cache the elContext for this execution here */
+ transient protected Object elContext = null;
+
// variables ////////////////////////////////////////////////////////////////
protected void initializeVariables(ScopeElementImpl scope, ExecutionImpl outerExecution) {
@@ -404,4 +407,10 @@
public long getDbid() {
return dbid;
}
+ public Object getElContext() {
+ return elContext;
+ }
+ public void setElContext(Object elContext) {
+ this.elContext = elContext;
+ }
}
14 years, 3 months
JBoss JBPM SVN: r6142 - jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-28 03:51:56 -0500 (Thu, 28 Jan 2010)
New Revision: 6142
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
Log:
JBPM-2047: make PersistenceServiceDbTest use a pristine, unshared JbpmConfiguration instance to prevent other tests from affecting it
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2010-01-27 15:37:12 UTC (rev 6141)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/persistence/db/PersistenceServiceDbTest.java 2010-01-28 08:51:56 UTC (rev 6142)
@@ -39,8 +39,20 @@
public class PersistenceServiceDbTest extends AbstractJbpmTestCase {
+ private JbpmConfiguration jbpmConfiguration;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // pristine, unshared configuration object
+ jbpmConfiguration = JbpmConfiguration.parseInputStream(null);
+ }
+
+ protected void tearDown() throws Exception {
+ jbpmConfiguration.close();
+ super.tearDown();
+ }
+
public void testDefaults() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceServiceFactory persistenceServiceFactory = null;
@@ -109,7 +121,6 @@
}
public void testRollbackWithoutSessionCreation() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService persistenceService = null;
@@ -125,7 +136,6 @@
}
public void testRollback() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService persistenceService = null;
@@ -145,7 +155,6 @@
}
public void testUserSuppliedConnection() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService persistenceService = null;
@@ -176,7 +185,6 @@
}
public void testUserSuppliedConnectionWithRollback() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService persistenceService = null;
@@ -209,7 +217,6 @@
}
public void testUserSuppliedSession() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService persistenceService = null;
@@ -236,7 +243,6 @@
}
public void testUserSuppliedSessionWithRollback() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
@@ -261,7 +267,6 @@
}
public void testTransferResponsibility() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
DbPersistenceService dbPersistenceService = null;
14 years, 3 months