Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
How to send paramters to actionhandler when using JbpmHandlerProxy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send paramters to actionhandler when using JbpmHandlerProxy

    Before using spring-modules I have this type of code in the processdefinition:
    Code:
    <action name="validate" class="com.handlers.MyActionHandler" config-type="bean">         	
                 <callbackjndiname>PersonCallback</callbackjndiname>
             	   <callbackmethod>validate</callbackmethod>
             	<signalType>1</signalType>
             </action>
    The parameters could be retrieved in the actionhandler.

    Now when I have started to use spring-modules for jbpm I canīt figure out how to add the parameters to get access to them in the actionhandler specified in the targetBean tag.
    I have this code in a processdefinition:
    Code:
    <action name="validate" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy" config-type="bean">
             	 <targetBean>workflowNodeActionHandler</targetBean>
                 <callbackjndiname>PersonCallback</callbackjndiname>
             	   <callbackmethod>validate</callbackmethod>
             	<signalType>1</signalType>
             </action>
    [/CODE]
    But this donīt work because the actionhandler isnīt the action class. Hopefully there is a way to solve it but I havenīt yet figured out how to specify the parameters and to make it possible to get access to them from the real actionhandler.

    Thanks in advance!

    /Henrik


    I have found one solution for my problem but donīt know if it is the best. I inherited the JbpmHandlerProxy and put my extra attributes in that class. Then I can access them in this way from my handler:
    Code:
    MyJbpmHandlerProxy proxy = (MyJbpmHandlerProxy) executionContext.getNode().getAction().getActionDelegation().getInstance();
    proxy.getXXX
    Last edited by 2nice; Apr 26th, 2007, 10:30 AM. Reason: Found a solution

  • #2
    I had the same issue, so thanks for your post. I liked the idea of extending the JbpmHandlerProxy but to make things easier I overrode the execute/assign method from jbpmHandlerProxy. I then set my properties directly on my real handler and then called the handler's assign or execute method.

    Code:
    public class MyAssignment_Default_Proxy extends JbpmHandlerProxy {
    
    	String userName;
    
    	public String getUserName() {
    		return userName;
    	}
    	public void setUserName(String userName) {
    		this.userName = userName;
    	}
    	
    
    	public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
    
                   //get the handler and cast it to my handler
    		MyAssignment_Default handler = (MyAssignment_Default) lookupBean(AssignmentHandler.class);
    		
                    //set the userName property on my handler
    		handler.setUserName(this.userName);
    
                    //fire the assign method on my handler
    		handler.assign(assignable, executionContext);
    	}
    
    }
    Set it in the process definition

    Code:
    ...
          <assignment class="com.foo.MyAssignment_Default_Proxy" config-type="bean">
            <targetBean>myAssignment_Default</targetBean>
            <userName>Buzz Terrier</userName>
          </assignment>
    ...
    Not sure if this is the best way, but it works for me.

    Comment

    Working...
    X