On 04/20/2013 11:14 PM, Jörg Schaible wrote:
Hi,

Xybrek wrote:

Hello,

Anyone knows of a library or extension to XStream that allows
(de)serialization of BSON documents?

This is the only implementation I can find so far:

http://www.axonframework.org/apidocs/2.0/org/axonframework/serializer/bson/DBObjectXStreamSerializer.html

However, the framework's serializer is quite geared toward its
frameworks models etc. Thus, very hard to integrate with a simple library.

Is there any library that is independent of a framework.

Actually I think that BSON and XStream do not really match. See, XStream's
converters will typically produce Strings i.e. all converters are
implemented to work with String representations of the objects they handle.
The hierarchical writer will write all values as String into the resulting
document - there's nothing else possible.

Actually even XStream's "binary" driver will simply write optimized values
as Strings and I don't see, how you can write anything that will produce a
compliant BSON document.

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

     http://xircles.codehaus.org/manage_email




I see, I just wonder how the Axon Framework was able to achieve this.
This is one of the unit test code I found for the DBObjectXStreamSerializer:

        @Test
    public void testSerializeAndDeserializeDomainEvent() {
SerializedObject<byte[]> serializedEvent = testSubject.serialize(new TestEvent("Henk"), byte[].class);
        assertNotNull(serializedEvent.getData());
        Object actualResult = testSubject.deserialize(serializedEvent);
        assertTrue(actualResult instanceof TestEvent);
        TestEvent actualEvent = (TestEvent) actualResult;
        assertEquals("Henk", actualEvent.getName());
    }


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to