<?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: Dynamic JavaDelegates in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156659#M110892</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, we have &lt;/SPAN&gt;&lt;EM&gt;something&lt;/EM&gt;&lt;SPAN&gt; that looks like a solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that adding the &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/8763#comment-8763" rel="nofollow noopener noreferrer"&gt;pgadecki's change&lt;/A&gt;&lt;SPAN&gt; to our &lt;/SPAN&gt;&lt;EM&gt;"Forced &amp;lt;code&amp;gt;ClassDelegate.execute(ActivityExecution)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ClassDelegate.signal(ActivityExecution)&amp;lt;/code&amp;gt; to always call &amp;lt;code&amp;gt;getActivityBehaviorInstance(execution)&amp;lt;/code&amp;gt;"&lt;/EM&gt;&lt;SPAN&gt; we got something that satisfies our needs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We tested each change separately and any of them alone does not work for us.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Now the question is: Are these changes critical to the work of the Activiti Engine?&lt;/STRONG&gt;&lt;SPAN&gt; Subquestions:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;What is the reason the variable &amp;lt;code&amp;gt;activityBehaviorInstance&amp;lt;/code&amp;gt; to be global in &amp;lt;code&amp;gt;ClassDelegate&amp;lt;/class&amp;gt;? It is shared only between &amp;lt;code&amp;gt;execute&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;signal&amp;lt;/code&amp;gt; methods. AFAIR there is no activity to be simultaneously executable and signallable but the implementation provides some kind of a hidden cache. Nevertheless, once the code is written in this manner probably I'm missing something …;&lt;/LI&gt;&lt;LI&gt;Why it is so critical to use &amp;lt;code&amp;gt;clazz = Class.forName(className, true, classLoader)&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;ReflectUtilloadClass(String)&amp;lt;/code&amp;gt; in the case a (custom) ClassLoader is available?&lt;/LI&gt;&lt;BR /&gt;P.S. Here are the changes in &amp;lt;code&amp;gt;ReflectUtil&amp;lt;/code&amp;gt;:&lt;BR /&gt;&amp;lt;code&amp;gt;&amp;nbsp; public static Class&amp;lt;?&amp;gt; loadClass(String className) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Class&amp;lt;?&amp;gt; clazz = null;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ClassLoader classLoader = getCustomClassLoader();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; // First exception in chain of classloaders will be used as cause when no class is found in any of them&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Throwable throwable = null;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; if(classLoader != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG.trace("Trying to load class with custom classloader: {}", className);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clazz = Class.forName(className, true, classLoader);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clazz = classLoader.loadClass( className );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch(Throwable t) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throwable = t;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;BR /&gt;&amp;lt;/code&amp;gt;and &amp;lt;code&amp;gt;ClassDelegate&amp;lt;/code&amp;gt;:&lt;BR /&gt;&amp;lt;code&amp;gt;&amp;nbsp; // Activity Behavior&lt;BR /&gt;&amp;nbsp; public void execute(ActivityExecution execution) throws Exception {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance == null) {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance.execute(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (BpmnError error) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorPropagation.propagateError(error, execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; // Signallable activity behavior&lt;BR /&gt;&amp;nbsp; public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance == null) {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance instanceof SignallableActivityBehavior) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new ActivitiException("signal() can only be called on a " + SignallableActivityBehavior.class.getName() + " instance");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&amp;lt;/code&amp;gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Nov 2013 12:39:46 GMT</pubDate>
    <dc:creator>mmaker1234</dc:creator>
    <dc:date>2013-11-07T12:39:46Z</dc:date>
    <item>
      <title>Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156655#M110888</link>
      <description>Hello Activiti developers, community,We have a requirement to provide the ability to load new and update workflow process definitions and their corresponding JavaDelegates during the application run. And before you to send me to the forum search let me note that I already read the following&lt;IMG id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;eployin</description>
      <pubDate>Wed, 06 Nov 2013 14:09:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156655#M110888</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-06T14:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156656#M110889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Monique, have you looked the OSGI approach? It's described in chapter 9 from the book Activiti in Action. I do not use it, personally, but it seems to be a good fit in your scenario.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm interested in this subject, so I'll keep an eye in this post. Hopefully someone with more experience will post a more appropriate answer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:15:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156656#M110889</guid>
      <dc:creator>felipe1</dc:creator>
      <dc:date>2013-11-06T14:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156657#M110890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;May I ask which application server you are using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We are thinking about providing more support around this for JBoss 7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Right now the best approach would be to use EJB's for you service logic. Then you can invoke that EJB from the Java delegate. If you keep the interface flexible you should be able to replace the EJB component with a new version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 14:53:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156657#M110890</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2013-11-06T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156658#M110891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tijs,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About the beginning of my original post I already stated that: &lt;/SPAN&gt;&lt;EM&gt;"Our environment is the following: &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enterprise application (EAR) running in &lt;STRONG&gt;WebLogic application server&lt;/STRONG&gt;;"&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To be honest I do not catch with your idea with the "adapter" JavaDelegate. My concern is that I can not make the JavaDelegate flexible enough: what would happen if I need to add another field (delegate parameter) in the process definition? Then I would need (again) to refresh the JavaDelegate class in run time. Or there is other way to get the fields from within the JavaDelegate in order to provide them to the EJB? Nevertheless I suppose that the call to the JavaDelegate will fail with missing setter/field when the new version of the process definition is instantiated (and the JavaDelegate "missed/failed" to update). &lt;/SPAN&gt;&lt;STRONG&gt;Do I miss something in the JavaDelegate invocation mechanism?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another option could be to change the process definition to parametrize the JavaDelegate using variables instead of fields. Then to make the delegate to "know" the EJB to call and flexible enough to look-up a setter for each process instance variable (while not failing on missing setters). This approach means:&lt;/SPAN&gt;&lt;OL style="list-style-type:decimal;"&gt;&lt;LI&gt;To mandate the use of &lt;STRONG&gt;statefull EJBs&lt;/STRONG&gt;, which are much difficult to maintain;&lt;/LI&gt;&lt;LI&gt;The whole mechanism of JavaDelegate parameters definition becomes &lt;STRONG&gt;hidden&lt;/STRONG&gt;&lt;OL style="list-style-type:lower-alpha;"&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;as one need to read all the process to reveal what value a variable might have in a certain activity;&lt;/LI&gt;&amp;nbsp; &lt;LI&gt;the EJB setters must be carefully reviewed on each process definition change&lt;BR /&gt;&lt;STRONG&gt;and error prone&lt;/STRONG&gt; - at least there will be no error if some parameter (variable) is missing a setter (due to the flexibility described above)&lt;/LI&gt;&lt;/OL&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Monique&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 09:07:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156658#M110891</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-07T09:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156659#M110892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, we have &lt;/SPAN&gt;&lt;EM&gt;something&lt;/EM&gt;&lt;SPAN&gt; that looks like a solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that adding the &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/8763#comment-8763" rel="nofollow noopener noreferrer"&gt;pgadecki's change&lt;/A&gt;&lt;SPAN&gt; to our &lt;/SPAN&gt;&lt;EM&gt;"Forced &amp;lt;code&amp;gt;ClassDelegate.execute(ActivityExecution)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ClassDelegate.signal(ActivityExecution)&amp;lt;/code&amp;gt; to always call &amp;lt;code&amp;gt;getActivityBehaviorInstance(execution)&amp;lt;/code&amp;gt;"&lt;/EM&gt;&lt;SPAN&gt; we got something that satisfies our needs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We tested each change separately and any of them alone does not work for us.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Now the question is: Are these changes critical to the work of the Activiti Engine?&lt;/STRONG&gt;&lt;SPAN&gt; Subquestions:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;What is the reason the variable &amp;lt;code&amp;gt;activityBehaviorInstance&amp;lt;/code&amp;gt; to be global in &amp;lt;code&amp;gt;ClassDelegate&amp;lt;/class&amp;gt;? It is shared only between &amp;lt;code&amp;gt;execute&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;signal&amp;lt;/code&amp;gt; methods. AFAIR there is no activity to be simultaneously executable and signallable but the implementation provides some kind of a hidden cache. Nevertheless, once the code is written in this manner probably I'm missing something …;&lt;/LI&gt;&lt;LI&gt;Why it is so critical to use &amp;lt;code&amp;gt;clazz = Class.forName(className, true, classLoader)&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;ReflectUtilloadClass(String)&amp;lt;/code&amp;gt; in the case a (custom) ClassLoader is available?&lt;/LI&gt;&lt;BR /&gt;P.S. Here are the changes in &amp;lt;code&amp;gt;ReflectUtil&amp;lt;/code&amp;gt;:&lt;BR /&gt;&amp;lt;code&amp;gt;&amp;nbsp; public static Class&amp;lt;?&amp;gt; loadClass(String className) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Class&amp;lt;?&amp;gt; clazz = null;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; ClassLoader classLoader = getCustomClassLoader();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; // First exception in chain of classloaders will be used as cause when no class is found in any of them&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Throwable throwable = null;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; if(classLoader != null) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOG.trace("Trying to load class with custom classloader: {}", className);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clazz = Class.forName(className, true, classLoader);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clazz = classLoader.loadClass( className );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch(Throwable t) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throwable = t;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;BR /&gt;&amp;lt;/code&amp;gt;and &amp;lt;code&amp;gt;ClassDelegate&amp;lt;/code&amp;gt;:&lt;BR /&gt;&amp;lt;code&amp;gt;&amp;nbsp; // Activity Behavior&lt;BR /&gt;&amp;nbsp; public void execute(ActivityExecution execution) throws Exception {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance == null) {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance.execute(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (BpmnError error) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorPropagation.propagateError(error, execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; // Signallable activity behavior&lt;BR /&gt;&amp;nbsp; public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance == null) {&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (activityBehaviorInstance instanceof SignallableActivityBehavior) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new ActivitiException("signal() can only be called on a " + SignallableActivityBehavior.class.getName() + " instance");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&amp;lt;/code&amp;gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 12:39:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156659#M110892</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-07T12:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156660#M110893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why not implement the routing logic in a stateless EJB as well? So from the java delegate class you just pass along execution info + the process variables to a fixed EJB. Then in this EJB you invoke the EJB you need. This makes the process definition independent from the EJB logic. Yes this means you will have to work with variables instead of field declarations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;About your changes. The activityBehaviorInstance is global because it's instantiated only once and reused when the same service task is executed again. This is for performance reasons.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In don't understand your comment about ReflectUtil. Class.forName(className, true, classLoader) uses the custom classloader to load the class, so why would you want to change that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 11:15:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156660#M110893</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2013-11-13T11:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156661#M110894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tijs,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me start from the Class.forName() behavior. Our investigation (debug, actually, including the Java runtime) revealed that the Class.forName(String, boolean, ClassLoader) calls the private native method Class.forName0(String, boolean, ClassLoader). On the first call to it, forName0() really reaches the (our custom) ClassLoader findClass() method. On the subsequent calls for the same class name and class loader, though, forName0() directly returns, most probably using some internal caches, the class instance thus never reaching again the findClass() in the class loader. At least this is the behavior of JRE 1.7.40 on Windows. I can not claim how JRE behaves on Linux.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an opposite, classLoader.loadClass(String) always reaches the ClassLoader findClass(). Obviously that class caching mechanism is not implemented/activated in loadClass() call sequence or internal implementation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now lets get back to the JavaDelegates. I personally think that your solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Is overcomplicated &lt;/SPAN&gt;&lt;STRONG&gt;for our case&lt;/STRONG&gt;&lt;SPAN&gt;. Nevertheless it might be just &lt;/SPAN&gt;&lt;STRONG&gt;the right solution&lt;/STRONG&gt;&lt;SPAN&gt; for other Activiti Engine users;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Trades the process definition clarity for speed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As &lt;/SPAN&gt;&lt;STRONG&gt;our usage&lt;/STRONG&gt;&lt;SPAN&gt; of the Activiti Engine (currently) does not require high throughput we will sacrifice the engine performance for flexibility and process definition clarity by going with the &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/20175#comment-20175" rel="nofollow noopener noreferrer"&gt;above&lt;/A&gt;&lt;SPAN&gt; solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paweł Gadecki's approach ( &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/8802#comment-8802" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/comment/8802#comment-8802&lt;/A&gt;&lt;SPAN&gt; ) is also tempting but I'm afraid it requires much more changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Monique&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 13:19:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156661#M110894</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-13T13:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156662#M110895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Monique,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And that's why we use the Class.forName code in the ReflectUtil class, because by default we want to cache the class instance for reasons I previously explained. But your use case is valid of course. So let's think about a possible solution that could be implemented in the Activiti Engine module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To start we need to get clear requirements about what's needed. Let me give a first try at that and you can change it to your needs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Service task class instance should be recreated at every execution of the service task activity. Right now the instance is cached and this can only be done by changing the Activiti Engine code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We could add an activiti:singleton="false" attribute. When this is added no class caching is done and a new instance of the Class is created at every execution. Would that fit your requirements?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Nov 2013 21:17:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156662#M110895</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2013-11-13T21:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156663#M110896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Tijs,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, our current vision is that we need &lt;/SPAN&gt;&lt;EM&gt;"The Service task class instance should be recreated at every execution of the service task activity"&lt;/EM&gt;&lt;SPAN&gt; and I think that an attribute will work well for us.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your receptivity! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Monique&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.S. Once we started a discussion and you opened to changes in the Activiti Engine regarding the JavaDelegate dynamics, what about &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/8802#comment-8802" rel="nofollow noopener noreferrer"&gt;Paweł Gadecki's idea of providing a separate class loader for each deployment&lt;/A&gt;&lt;SPAN&gt;? Or it is too risky for the Engine stability? Is this approach much different from the use case with a custom class loader (provided in the engine configuration) in the perspective of the Engine security and stability?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me elaborate a little:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;Our approach allows separate deployment of the JavaDelegates and the process definition:&lt;UL&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The JavaDelegate distribution is separate from the process definition distribution;&lt;/LI&gt; &lt;LI&gt;The JavaDelegate deployment is handled by the environment (usually an application server) and not the Activiti Engine;&lt;/LI&gt; &lt;LI&gt;A JavaDelegate replacement immediately affects the running instances of &lt;STRONG&gt;all versions of all process definitions&lt;/STRONG&gt;&lt;/LI&gt; &lt;LI&gt;Any change in a JavaDelegate must be made with the thought of compatibility with older versions of the deployed process definition. (We are aware of this and are ready to take care for the backwards compatibility but others might not notice this effect)&lt;/LI&gt; &lt;LI&gt;Requires the new JavaDelegate version to be deployed on each node of a cluster configuration.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Paweł's approach ties the JavaDelegates implementation to the process definition version, thus encapsulating all process definition supplements (JavaDelegates) in a dedicated execution environment&lt;UL&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The JavaDelegate is bundled in the distribution package of the process definition;&lt;/LI&gt; &lt;LI&gt;The JavaDelegate distribution is handled by the Activiti Engine database. An access to it is provided via the Engine deployment management API;&lt;/LI&gt; &lt;LI&gt;A change in a JavaDelegate affects exactly one version of the process definition;&lt;/LI&gt; &lt;LI&gt;To apply the changes in a JavaDelegate the process definition have to be re-deployed;&lt;/LI&gt; &lt;LI&gt;The changes will take effect only with the new instances of the process definition;&lt;/LI&gt; &lt;LI&gt;Removal/bypassing of the Activiti Engine caching mechanism is not required;&lt;/LI&gt; &lt;LI&gt;Provides better scalability (in a cluster) due to the common deployments repository&lt;/LI&gt;&lt;/UL&gt;&lt;SPAN&gt;Whether the above features of the both approaches are pros or cons each Activiti Engine user should decide for himself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 12:58:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156663#M110896</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-14T12:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156664#M110897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;IMO, you should not even try to do this with Java. You can achieve what you want with Groovy delegates, which is almost exactly what I'm doing in my Ativiti-based app.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Use the process parsing hooks (&lt;/SPAN&gt;&lt;A href="http://www.activiti.org/userguide/index.html#advanced_parseHandlers" rel="nofollow noopener noreferrer"&gt;http://www.activiti.org/userguide/index.html#advanced_parseHandlers&lt;/A&gt;&lt;SPAN&gt;) to dinamically add delegates to a wrapper that will load user scripts on demand. You can use a convention-based approach or something more elaborated (eg: a DB lookup)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ca&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. When a process instance reaches a given activity that, it will execute your (fixed) delegate, which in turn will:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.1. lookup ou create a GroovyClassLoader instance that load scripts from your script repository (eg: filesystem ou a JCR based content - the former can give you script versioning,for instance). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.2. Use this classloader to instantiate the actual delegate &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.3. execute the delegate&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.4. handle exceptions, etc&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Groovy scripts can do anything Java can, so there is no loss of functionality there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the user changes any script, GroovyClassLoader will pick the changes and apply them on the next invocation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 01:37:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156664#M110897</guid>
      <dc:creator>pmsevestre</dc:creator>
      <dc:date>2013-11-15T01:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156665#M110898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you are loosing in your approach is at least the possibility to debug especially when you need a complicated logic. That is why we prefer to stay with the Java classes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In our case we need to load Domain Objects (EJBs) from the DB, to evaluate their state (with somewhat complex logic, including calls to the application's business logic) and then store back some changes using our persistence mechanism. All this should happen under the transaction management of the application server. I'm not quite sure the Groovy script will allow us all of this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 12:09:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156665#M110898</guid>
      <dc:creator>mmaker1234</dc:creator>
      <dc:date>2013-11-15T12:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156666#M110899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can set breakpoints in Groovy scripts and single-step them, inspect variables and so forth, so there is no loss in my serviceability in my approach. This is what I do everyday in my environment. The IDE (Eclipse) connects to the application server (regular Tomcat, in my case) and I'm able to do all debugging I want. Usually, those scripts perform some business logic that ties state from a given process instance with backend services (webservices, EJB calls). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please note that this approach works with groovy classes instantiated using the GroovyClassLoader approach I've described.I tried to do this with other JSR-223 script engines but their debug support is poor. This is also the reason that made me ruled out the use of "script tasks" in my processes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 13:47:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156666#M110899</guid>
      <dc:creator>pmsevestre</dc:creator>
      <dc:date>2013-11-15T13:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156667#M110900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pawel's approach is exactly what I need!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to package the process definition and delegates in a jar-file and deploy it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Each version of the process definition sould have its own version of delegates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any sample code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I get the Execution Context in the class loader?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 11:20:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156667#M110900</guid>
      <dc:creator>rolf</dc:creator>
      <dc:date>2014-02-19T11:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JavaDelegates</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156668#M110901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I came up with a different solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It might not be a perfect use case for other users, but I thought I could share it anyway. It could open new possibilities. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My web application doesn't have the Activiti engine embedded. The engine is deployed on a slightly modified of the default activiti-rest-webapp, provided by Activiti.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The web application talks to the Engine through REST calls, thanks to the now standardized REST API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the BPMN definition, the only JavaDelegate defined is a class that invoke custom URIs, providing its current Execution state, variables, tasks, … as a set of JSON objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These custom URIs (=callback URIs) are "hardcoded" in the XML. They usually point back to the web application, which is then allowed to notify clients of the BPM progress.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The callback URIs can also query the engine using the REST API, but are &amp;lt;strong&amp;gt;strongly&amp;lt;/strong&amp;gt; discouraged to perform any update with the REST API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The callback URIs may also update process variables and ship them in the response sent back to the process engine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally, the JavaDelegate inspect the response and persist updated variables in the database, all within the same transaction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With this approach, the only classes I need to provide to the engine are rather generic. All the decision logic is delegated to another webapp/JVM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Implementation note: I initially based these URI invocations on Restlet, but it seemed to randomly close response streams. Activiti REST webapp is compiled against Restlet 2.0.x branch, so I couldn't upgrade to the latest 2.1.y branch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the end, I replaced the invocation logic by using java.net.URL. Rather basic, but enough for a simple POST request.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 14:28:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/dynamic-javadelegates/m-p/156668#M110901</guid>
      <dc:creator>dimitrihautot</dc:creator>
      <dc:date>2014-02-20T14:28:28Z</dc:date>
    </item>
  </channel>
</rss>

