<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: get fieldDeclarations through DelegateExecution in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176237#M129367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure what you mean with this? Can you elaborate?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2015 19:21:03 GMT</pubDate>
    <dc:creator>jbarrez</dc:creator>
    <dc:date>2015-04-28T19:21:03Z</dc:date>
    <item>
      <title>get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176236#M129366</link>
      <description>Hi,Is there any way to get the "List&amp;lt;fieldDeclarations&amp;gt;" of the executing service task (JavaDelegate) through the DelegateExecution instance?Regards, Maarten</description>
      <pubDate>Tue, 28 Apr 2015 13:09:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176236#M129366</guid>
      <dc:creator>boekhold</dc:creator>
      <dc:date>2015-04-28T13:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176237#M129367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure what you mean with this? Can you elaborate?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2015 19:21:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176237#M129367</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2015-04-28T19:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176238#M129368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there any way to get the &amp;lt;code&amp;gt;List&amp;lt;FieldDeclaration&amp;gt;&amp;lt;/code&amp;gt; of the executing service task (JavaDelegate) through the DelegateExecution instance?&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm not sure what you mean with this? Can you elaborate?&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;(original question updated, I was asking about&amp;lt;code&amp;gt;List&amp;lt;FieldDeclaration&amp;gt;&amp;lt;/code&amp;gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wanted to keep the question short and to the point, because the background of this is quite long, and I'm afraid it will open up a can of worms. However I should probably describe it anyways.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We're using Activiti inside an OSGi container, and use &lt;/SPAN&gt;&lt;EM&gt;delegateExpression&lt;/EM&gt;&lt;SPAN&gt;s for Service Tasks (which I believe is the only method supported if you run inside an OSGi container). We now want to use &lt;/SPAN&gt;&lt;EM&gt;Field Injection&lt;/EM&gt;&lt;SPAN&gt; to pass parameters to our custom service tasks. We believe however that the current implementation in Activiti is not thread-safe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The way Activiti works when using &lt;/SPAN&gt;&lt;EM&gt;delegateExpression&lt;/EM&gt;&lt;SPAN&gt; for a service task is that the expression is evaluated inside &amp;lt;code&amp;gt;ServiceTaskDelegateExpressionActivityBehavior&amp;lt;/code&amp;gt; when the activity is being executed. The JavaDelegate returned by the expression evaluation &lt;/SPAN&gt;&lt;EM&gt;is always the same instance&lt;/EM&gt;&lt;SPAN&gt;. Next, Activiti performs Field Injection on that instance (which is effectively a singleton instance).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you reference &lt;/SPAN&gt;&lt;EM&gt;the same&lt;/EM&gt;&lt;SPAN&gt; JavaDelegate from different process models, or from parallel flows inside the same model, there is a risk that a specific execution is getting the expressions from another execution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I'm trying to come up with a way to make this thread safe. The first step is to prevent Activiti from doing the reflection-based field injection. I can do that. I've implemented a &amp;lt;code&amp;gt;CustomBehaviorFactory extends DefaultActivityBehaviorFactory&amp;lt;/code&amp;gt; that overrides the &amp;lt;code&amp;gt;createServiceTaskDelegateExpressionActivityBehavior()&amp;lt;/code&amp;gt; method, and returns a &amp;lt;code&amp;gt;CustomServiceTaskDelegateExpressionActivityBehavior extends ServiceTaskDelegateExpressionActivityBehavior&amp;lt;/code&amp;gt; instance. In my custom activity behavior, I skip the &amp;lt;code&amp;gt;applyFieldDeclarations()&amp;lt;/code&amp;gt; call for JavaDelegate instances.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm now looking at finding another way of getting the &amp;lt;code&amp;gt;List&amp;lt;FieldDeclaration&amp;gt;&amp;lt;/code&amp;gt; into our JavaDelegate in a threadsafe way. The best option seems to be to try to somehow get that list into the DelegateExecution that's passed to &amp;lt;code&amp;gt;JavaDelegate.execute()&amp;lt;/code&amp;gt;. Right now the only option I see is to add each FieldDeclaration to the local variables before the &amp;lt;code&amp;gt;handleInvocation()&amp;lt;/code&amp;gt; call, and remove them again after &amp;lt;code&amp;gt;leave(execution)&amp;lt;/code&amp;gt;. I'm hoping however that there's a better way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maarten&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 11:33:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176238#M129368</guid>
      <dc:creator>boekhold</dc:creator>
      <dc:date>2015-04-29T11:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176239#M129369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You're reasoning is not quite correct: what is injected in the delegate is an instance of an Expression. This is always the same instance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the method itself, the expression is resolved using the execution to resolve (if needed). So this is thread-safe, there is no instance member being used, but rather an Expression that can resolve to different things depending on the context.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 12:24:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176239#M129369</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2015-05-07T12:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176240#M129370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, because you can use the same &amp;lt;code&amp;gt;MyServiceTask implements JavaDelegate&amp;lt;/code&amp;gt; multiple times in different models, or in different places in the same model. Each of those places can have its own set of expressions configured on the class fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At least in our OSGi deployment, each time Activiti calls &amp;lt;code&amp;gt;expression.getValue(execution)&amp;lt;/code&amp;gt; (like in &amp;lt;code&amp;gt;ServiceTaskDelegateExpressionActivityBehavior&amp;lt;/code&amp;gt;, &lt;/SPAN&gt;&lt;EM&gt;that getValue() returns &lt;STRONG&gt;the same&lt;/STRONG&gt; instance of the JavaDelegate&lt;/EM&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;there is no instance member being used&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;Uh, you are injecting instance members…?!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maarten&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 13:05:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176240#M129370</guid>
      <dc:creator>boekhold</dc:creator>
      <dc:date>2015-05-07T13:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: get fieldDeclarations through DelegateExecution</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176241#M129371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&amp;gt; Uh, you are injecting instance members…?!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression, and the expressions are the same. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is by design that Activiti returns the same instance (which you could override if really needed). Not sure what you are looking for looking at the original post and where we are at now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:15:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/get-fielddeclarations-through-delegateexecution/m-p/176241#M129371</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2015-05-18T14:15:55Z</dc:date>
    </item>
  </channel>
</rss>

