<?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 Variable serialization &amp; Class Loading in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192342#M145472</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;AFAIK Activiti Engine offers class loading extension point by the following means:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;Developer can provide custom class loader by setting &lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;classLoader&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt; property of &lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.ProcessEngineConfiguration&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;;&lt;/LI&gt;&lt;LI&gt;Custom class loader may refer to the &lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.context.Context.getExecutionContext().getProcessDefinition().getDeploymentId()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt; method for deployment context.&lt;/LI&gt;&lt;/UL&gt;&lt;SPAN&gt;However, if you want to use variables in you process instance of types defined in the per-deployment class loader, you'll find yourself in trouble: Activiti Engine will call your class loader without providing context information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This can be seen in class &lt;/SPAN&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.SerializableType&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp; protected ObjectInputStream createObjectInputStream(InputStream is) throws IOException {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new ObjectInputStream(is) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected Class&amp;lt;?&amp;gt; resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ReflectUtil.loadClass(desc.getName());&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;No context information is set here before loading the class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even if core team decides to abandon this request, I would like to extend core behaviour with providing deployment context&amp;nbsp; in se/deserialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, overriding this behaviour is cumbersome since classes &lt;/SPAN&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.SerializableType&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.DeserializedObject&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; are rather poorly designed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;it's hard to override &lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.SerializableType.createObjectOutputStream&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;, since it's private static – you have to copy/paste entire methods calling it. Its fellow method createObjectInputStream is protected and not static.&lt;/LI&gt;&lt;LI&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.DeserializedObject.flush()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt; uses static method mentioned above, you have to overrride the entire method and also override methods containing creation of deserialized object in &lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;org.activiti.engine.impl.variable.SerializableType&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;. I would suggest deserialized object calling callback method for serialization in the creating object, which is subject to overriding.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Aug 2014 08:04:43 GMT</pubDate>
    <dc:creator>oefimov</dc:creator>
    <dc:date>2014-08-13T08:04:43Z</dc:date>
    <item>
      <title>Variable serialization &amp; Class Loading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192342#M145472</link>
      <description>AFAIK Activiti Engine offers class loading extension point by the following means&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;eveloper can provide custom class loader by setting classLoader‍ property of org.activiti.engine.ProcessEngineConfiguration‍;Custom class loader may refer to the org.activiti.engine.impl.context.Context.getExecutionCo</description>
      <pubDate>Wed, 13 Aug 2014 08:04:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192342#M145472</guid>
      <dc:creator>oefimov</dc:creator>
      <dc:date>2014-08-13T08:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable serialization &amp; Class Loading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192343#M145473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So you mean you want to have classloaders specifically for certain deployments?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that this information is not always available and sometimes will need to be fetched from the database, right?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regarding your suggestions of code changes: it's easier to put these into pull requests where we can discuss them and incorporate them in the code if both parties agree. Would you be able to do that?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 09:31:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192343#M145473</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-08-19T09:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Variable serialization &amp; Class Loading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192344#M145474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Joram, yes, if variable is of per-deployment class then during its deserialization the quick way to learn its classloader is via serialized information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another solution is to set context above in the call stack, wrapping deserialization invocations (engine knows for which process&amp;gt;definition&amp;gt;deployment it is deserializing a variable), but it's hard for me to assess impact and feasibility of such solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll make a pull request for the first variant and post link to it here, okay?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2014 15:08:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192344#M145474</guid>
      <dc:creator>oefimov</dc:creator>
      <dc:date>2014-08-19T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variable serialization &amp; Class Loading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192345#M145475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Joram,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please review the pull request I've created: &lt;/SPAN&gt;&lt;A href="https://github.com/Activiti/Activiti/pull/360" rel="nofollow noopener noreferrer"&gt;https://github.com/Activiti/Activiti/pull/360&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Aug 2014 06:59:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192345#M145475</guid>
      <dc:creator>oefimov</dc:creator>
      <dc:date>2014-08-20T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable serialization &amp; Class Loading</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192346#M145476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Certainly. We will reviewing pull requests shortly, it's very hectic currently (just before the Alfresco Summit it is always crazy)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 Aug 2014 16:19:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/variable-serialization-class-loading/m-p/192346#M145476</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-08-30T16:19:34Z</dc:date>
    </item>
  </channel>
</rss>

