Skip to main content



      Home
Home » Modeling » EMF » [CDO] Possibility to implement custom (de-)serialization for ObjectType JAVA_OBJECT?
[CDO] Possibility to implement custom (de-)serialization for ObjectType JAVA_OBJECT? [message #1826832] Fri, 01 May 2020 15:51 Go to next message
Eclipse UserFriend
Hi,

Is there any way to customize the (de-)serialization of JAVA_OBJECT types by registering/using an application-provided implementation of the JAVA_OBJECT type?

Thanks & best regards, CLemens

Background: Java's built-in serialization has a high space (and time) overhead, especially for small objects. I am currently working on persisting an existing data model which until now was in-memory only and with the builtin serialization approach I see a fixed overhead per Object of about ~100 bytes, which is to be expected. The model consists of tons of tiny Java Objects (dates, Enums, primitive-wrappers, ...) which however are very dynamic in type and structure - so those 100bytes sum up quickly and I fear DB bloat. The application is quite large, so I would prefer enhancing the serialization approach instead of messing with application code.

I have had great results with Kryo in other projects, if possible I would like to integrate it.
E.g. size in bytes of a small serialized java object: https://tinyurl.com/y7pr3p8y

[Updated on: Sat, 02 May 2020 06:58] by Moderator

Re: Possibility to implement custom (de-)serialization for ObjectType JAVA_OBJECT? [message #1826838 is a reply to message #1826832] Sat, 02 May 2020 00:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The easist approach is probably just to set serializable=false in your Ecore model.

If that is not appropriate, XMISave/XMIHelper have many places where an override activated by your custom XXXResourceImpl can change behaviour. I often find that while changing one of these I discover an EMF facility that I was unaware of that can be used instead.

Regards

Ed Willink
Re: Possibility to implement custom (de-)serialization for ObjectType JAVA_OBJECT? [message #1826844 is a reply to message #1826838] Sat, 02 May 2020 03:50 Go to previous message
Eclipse UserFriend
I suspect this is a CDO question not really tagged as a CDO question. In the Ecore model EJavaObject is serialized via org.eclipse.emf.ecore.impl.EFactoryImpl.convertToString(Object) and org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(String) called from org.eclipse.emf.ecore.impl.EcoreFactoryImpl.convertEJavaObjectToString(EDataType, Object) and org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createEJavaObjectFromString(EDataType, String). So the general way is to define an EDataType and implement the factory method to somehow convert the value to and from a string representation.

Previous Topic:[CDO] Connect to example standalone server Server.java
Next Topic:Add Property programmatically
Goto Forum:
  


Current Time: Fri Nov 07 22:49:55 EST 2025

Powered by FUDForum. Page generated in 0.07365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top