Variable serialization & Class Loading

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2014 04:04 AM
AFAIK Activiti Engine offers class loading extension point by the following means:
This can be seen in class
No context information is set here before loading the class.
Even if core team decides to abandon this request, I would like to extend core behaviour with providing deployment context in se/deserialization.
However, overriding this behaviour is cumbersome since classes
- Developer can provide custom class loader by setting
property ofclassLoader‍
;org.activiti.engine.ProcessEngineConfiguration‍
- Custom class loader may refer to the
method for deployment context.org.activiti.engine.impl.context.Context.getExecutionContext().getProcessDefinition().getDeploymentId()‍
This can be seen in class
org.activiti.engine.impl.variable.SerializableType‍
: protected ObjectInputStream createObjectInputStream(InputStream is) throws IOException { return new ObjectInputStream(is) { protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { return ReflectUtil.loadClass(desc.getName()); } }; }‍‍‍‍‍‍‍‍‍
No context information is set here before loading the class.
Even if core team decides to abandon this request, I would like to extend core behaviour with providing deployment context in se/deserialization.
However, overriding this behaviour is cumbersome since classes
org.activiti.engine.impl.variable.SerializableType‍
and org.activiti.engine.impl.variable.DeserializedObject‍
are rather poorly designed:- it's hard to override
, since it's private static – you have to copy/paste entire methods calling it. Its fellow method createObjectInputStream is protected and not static.org.activiti.engine.impl.variable.SerializableType.createObjectOutputStream‍
uses static method mentioned above, you have to overrride the entire method and also override methods containing creation of deserialized object inorg.activiti.engine.impl.variable.DeserializedObject.flush()‍
. I would suggest deserialized object calling callback method for serialization in the creating object, which is subject to overriding.org.activiti.engine.impl.variable.SerializableType‍
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2014 05:31 AM
So you mean you want to have classloaders specifically for certain deployments?
The problem is that this information is not always available and sometimes will need to be fetched from the database, right?
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?
The problem is that this information is not always available and sometimes will need to be fetched from the database, right?
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?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2014 11:08 AM
Joram, yes, if variable is of per-deployment class then during its deserialization the quick way to learn its classloader is via serialized information.
Another solution is to set context above in the call stack, wrapping deserialization invocations (engine knows for which process>definition>deployment it is deserializing a variable), but it's hard for me to assess impact and feasibility of such solution.
I'll make a pull request for the first variant and post link to it here, okay?
Another solution is to set context above in the call stack, wrapping deserialization invocations (engine knows for which process>definition>deployment it is deserializing a variable), but it's hard for me to assess impact and feasibility of such solution.
I'll make a pull request for the first variant and post link to it here, okay?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2014 02:59 AM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2014 12:19 PM
Certainly. We will reviewing pull requests shortly, it's very hectic currently (just before the Alfresco Summit it is always crazy)
