I think I've found a bug in the CompositeCommand injection method. The problem is that
findField method is only feeded with the class of the previous command result, and since
it should search into the new Command class for a field suitable to be injected with the
result of the previous command, I think it's wrong (at least it's not injecting).
I've changed it and now seems to work:
### Eclipse Workspace Patch 1.0
| #P jbpm
| Index: jpdl/jar/src/main/java/org/jbpm/command/CompositeCommand.java
| ===================================================================
| RCS file:
/cvsroot/jbpm/jbpm.3/jpdl/jar/src/main/java/org/jbpm/command/CompositeCommand.java,v
| retrieving revision 1.1
| diff -u -r1.1 CompositeCommand.java
| --- jpdl/jar/src/main/java/org/jbpm/command/CompositeCommand.java 23 Aug 2006 15:37:37
-0000 1.1
| +++ jpdl/jar/src/main/java/org/jbpm/command/CompositeCommand.java 11 Oct 2006 15:15:59
-0000
| @@ -5,6 +5,8 @@
| import java.util.Iterator;
| import java.util.List;
|
| +import org.apache.commons.logging.Log;
| +import org.apache.commons.logging.LogFactory;
| import org.jbpm.JbpmContext;
| import org.jbpm.JbpmException;
|
| @@ -37,7 +39,7 @@
| }
|
| protected void tryToInject(Object lastResult, Command command) {
| - Field field = findField(lastResult.getClass());
| + Field field = findField(lastResult.getClass(), command);
| if (field!=null) {
| field.setAccessible(true);
| try {
| @@ -48,10 +50,10 @@
| }
| }
|
| - protected Field findField(Class clazz) {
| + protected Field findField(Class clazz, Command command) {
| Field field = null;
| int i=0;
| - Field[] fields = clazz.getDeclaredFields();
| + Field[] fields = command.getClass().getDeclaredFields();
| while ( (i<fields.length)
| && (field==null)
| ) {
| @@ -63,6 +65,9 @@
| }
| i++;
| }
| + log.debug("Field to inyect for class '"+clazz.getName()+"'
is '"+field+"'");
| return field;
| }
| +
| + private static Log log = LogFactory.getLog(CompositeCommand.class);
| }
|
Also, I've added to the SignalCommand a new field as I commented before, to be able to
send a composite command (NewProcessInstanceCommand,SignalCommand) with the latter using
the ProcessInstance returned by the former:
### Eclipse Workspace Patch 1.0
| #P jbpm
| Index: jpdl/jar/src/main/java/org/jbpm/command/SignalCommand.java
| ===================================================================
| RCS file:
/cvsroot/jbpm/jbpm.3/jpdl/jar/src/main/java/org/jbpm/command/SignalCommand.java,v
| retrieving revision 1.3
| diff -u -r1.3 SignalCommand.java
| --- jpdl/jar/src/main/java/org/jbpm/command/SignalCommand.java 23 Aug 2006 15:37:37
-0000 1.3
| +++ jpdl/jar/src/main/java/org/jbpm/command/SignalCommand.java 11 Oct 2006 15:19:29
-0000
| @@ -24,6 +24,7 @@
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
| import org.jbpm.JbpmContext;
| +import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.graph.exe.Token;
|
| public class SignalCommand implements Command {
| @@ -34,14 +35,23 @@
| String transitionName = null;
|
| Token previousToken = null;
| + ProcessInstance previousProcessInstance = null;
|
| public Object execute(JbpmContext jbpmContext) {
| log.debug("executing "+this);
| - Token token = getToken(jbpmContext);
| - if (transitionName==null) {
| - token.signal();
| + if (previousProcessInstance!=null) {
| + if (transitionName==null) {
| + previousProcessInstance.signal();
| + } else {
| + previousProcessInstance.signal(transitionName);
| + }
| } else {
| - token.signal(transitionName);
| + Token token = getToken(jbpmContext);
| + if (transitionName==null) {
| + token.signal();
| + } else {
| + token.signal(transitionName);
| + }
| }
| return null;
| }
|
It seems to work. But I've seen a log that says the MessageService used is the DB
based one:
2006-10-11 17:01:55,472 DEBUG [org.jbpm.svc.Services] closing service 'message':
org.jbpm.msg.db.DbMessageService@6be4cc
| 2006-10-11 17:01:55,483 DEBUG [org.jbpm.msg.db.DbMessageService] messages were
produced the jobExecutor will be signalled
|
|
I suppose that (once again) is caused by a missconfiguration. How should I configure what
message service implementation should be used?
Regards.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3977593#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...