AnsweredAssumed Answered

JavaDelegates, custom nodes, configuration and use

Question asked by msandoz on Dec 17, 2011
Latest reply on Dec 19, 2011 by msandoz
I read this:

Since the Java class instance is reused, the injection only happens once, when the serviceTask is called the first time. When the fields are altered by your code, the values won't be re-injected so you should treat them as immutable and don't make any changes to them.

I defined several custom designer nodes, and it seems they create bpml like:

    <serviceTask id="servicetask2" name="Excel" activiti:class="org.nexusbpm.activiti.ExcelNexusJavaDelegation">
        <activiti:field name="skipHeader">
        <activiti:field name="columnLimit">

if I have two such tasks, which I need to behave differently in the flow, does this mean I cannot create a custom node to do so? For example, my two service tasks (both of same class) might each need different column limits.

Also, I was concerned that even when I put a variable into the value in the properties tab, such as ${'hello'} - it still seems to render as a string instead of an expression. If it was an expression, I could change the value of the expression and it would make the first problem I am having easier.

Also, is there any way to configure these tasks (for example with spring) when they are instantiated? I may need complicated objects injected at create time. Right now, I am trying to wrap several of my spring beans in java delegate wrappers. These allow my to keep my code built in a separate module, and just adapt it to interface with activiti. If custom nodes in the editor could generate references to spring beans instead of classes, that would be very useful. Is it planned?

I see in the user guide where this is supported in the xml:

 <serviceTask id="serviceTask" activiti:delegateExpression="${delegateExpressionBean}" />

<serviceTask id="javaService"
             name="My Java Service Task"
             activiti:expression="#{printer.printMessage()}" />

sorry to put so many questions in one post - they are all related i think? :)