11-11-2011 04:15 AM
class CustomSerializableProcessTypeService {
static transactional = false
ProcessEngineConfigurationImpl processEngineConfiguration
def grailsApplication
void registerCustomSerializableType () {
processEngineConfiguration.variableTypes.addType (new CustomSerializableType (), 0)
}
class CustomSerializableType extends SerializableType {
@Override
Object getValue (ValueFields valueFields) {
Object cachedObject = valueFields.getCachedValue ();
if (cachedObject != null) {
return cachedObject;
}
byte[] bytes = valueFields.getByteArrayValue ()?.getBytes ();
ByteArrayInputStream bais = new ByteArrayInputStream (bytes);
Object deserializedObject = null;
try {
ObjectInputStream ois = new CustomObjectInputStream (bais) // <=== This is the line of interest
deserializedObject = ois.readObject ();
valueFields.setCachedValue (deserializedObject);
if (valueFields instanceof VariableInstanceEntity) {
Context.
getCommandContext ().
getDbSqlSession ().
addDeserializedObject (deserializedObject, bytes, (VariableInstanceEntity) valueFields);
}
} catch (Exception e) {
log.warn ("exception occurred in getValue of custom SerializableType, trying super class", e)
} finally {
IoUtil.closeSilently (bais);
}
if (deserializedObject) {
return deserializedObject;
}
return super.getValue (valueFields)
}
}
class CustomObjectInputStream extends ObjectInputStream {
CustomObjectInputStream (InputStream inputStream) {
super(inputStream)
}
protected Class resolveClass (ObjectStreamClass objectStreamClass) throws IOException, ClassNotFoundException {
return Class.forName (objectStreamClass.getName (), true, grailsApplication.classLoader);
}
}
}
11-12-2011 06:01 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.