[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] Using non-serializable object as shared objects

Hi Fabian,

On 2/15/2011 11:47 PM, Fabian Meyer wrote:
Using non-serializable object as shared objects


is there a way to use non-serializable object as shared objects in ECF? At the moment I'm using somethings that looks a littly hacky to me and doesn't feel correct...

I wrote a bundle which tracks the IContainerManager services. When a new SOContainer is created I'm calling the setSharedObjectMessageSerializer to inject my own message serializer. The serializer uses a special input and output stream for object reading/writing where known non-serializable objects are serialized by hand and wrapped in a container.

protected Object replaceObject(Object obj) throws IOException {
        if (obj instanceof OWLObject) {
                OWLObjectContainer cont = new OWLObjectContainer();
                final String owlObjectString = renderer.render((OWLObject) obj);
                return cont;
        return obj;

On the client side the container is resolved and replaced by the unserialiable object.

protected Object resolveObject(Object obj) throws IOException {
        if (obj instanceof OWLObjectContainer) {
                String owlObjectString = ((OWLObjectContainer) obj).getOWLObjectString();
                OWLObject owlObj = parser.parse(owlObjectString));     
                return owlObj;
        return obj;

I'm not sure I understand...this is working for you...but it doesn't seem correct?

Is it possible to register something like a "serializer service" in ecf that is used to serialize a special class of objects?

No, not currently.  It would be perfectly feasible to introduce such a serializer service (presumably meant to be an OSGi service using whiteboard pattern?), so please open an enhancement/bug to that effect.  And if you can help implement, please do...as our resources for new features are currently minimal.