Results 1 to 2 of 2

Thread: How to send paramters to actionhandler when using JbpmHandlerProxy

  1. #1
    Join Date
    Oct 2006
    Posts
    23

    Default 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 at 09:30 AM. Reason: Found a solution

  2. #2
    Join Date
    Aug 2005
    Posts
    16

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •