You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by mjustin <mi...@gmx.net> on 2009/02/14 09:46:54 UTC

XStream annotations for XML transformation


Dejan Bosanac wrote:
> 
> 
> is your SamplePojo properly annotated so it can be marshaled with XStream?
> 
> 

In my tests (using ActiveMQ 5.2, XStream 1.3) I found that the serialization
to XML works fine even without annotations, a simple (serializable) class
can be received by a Stomp client in XML format, which is great because
there are no dependencies in the class definition. My original problem was
solved using correct transformation name.

Now I tried to use annotations following the example on
http://xstream.codehaus.org/annotations-tutorial.html. I can see the
serialized 'RendezvousMessage' in the Admin console (as
RendezvousMessage$NNNNN). And I can receive it in the Stomp client as XML,
however, the annotations do not have an effect on the XML content.

I have not yet checked in the ActiveMQ source if it calls the
xstream.processAnnotations method for the object class, which seems to be
necessary, or if I made a mistake somewhere else.

-- 
View this message in context: http://www.nabble.com/Broker-sends-empty-body-in-STOMP-ObjectMessage-%28using-jms-json-transformation%29-tp21727046p22010420.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: XStream annotations for XML transformation

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi Michael,

We can inject the configured xstream the transformer will use. For example,
for the SamplePojo used in tests we configure the xstream like this

  <bean class="org.apache.activemq.util.XStreamFactoryBean" name="xstream">
          <property
name="annotatedClass"><value>org.apache.activemq.transport.stomp.SamplePojo</value></property>
  </bean>

so it get properly annotated.

I see now that they added autodetectAnnotations(), so I'll experiment with
it a bit.

Cheers
--
Dejan Bosanac

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Sat, Feb 14, 2009 at 9:46 AM, mjustin <mi...@gmx.net> wrote:

>
>
> Dejan Bosanac wrote:
> >
> >
> > is your SamplePojo properly annotated so it can be marshaled with
> XStream?
> >
> >
>
> In my tests (using ActiveMQ 5.2, XStream 1.3) I found that the
> serialization
> to XML works fine even without annotations, a simple (serializable) class
> can be received by a Stomp client in XML format, which is great because
> there are no dependencies in the class definition. My original problem was
> solved using correct transformation name.
>
> Now I tried to use annotations following the example on
> http://xstream.codehaus.org/annotations-tutorial.html. I can see the
> serialized 'RendezvousMessage' in the Admin console (as
> RendezvousMessage$NNNNN). And I can receive it in the Stomp client as XML,
> however, the annotations do not have an effect on the XML content.
>
> I have not yet checked in the ActiveMQ source if it calls the
> xstream.processAnnotations method for the object class, which seems to be
> necessary, or if I made a mistake somewhere else.
>
> --
> View this message in context:
> http://www.nabble.com/Broker-sends-empty-body-in-STOMP-ObjectMessage-%28using-jms-json-transformation%29-tp21727046p22010420.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>