abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Evans" <objective...@gmail.com>
Subject Re: Advice on extending Entry
Date Thu, 28 Jun 2007 18:58:17 GMT
On 6/27/07, James M Snell <jasnell@gmail.com> wrote:
> The first question I would have is why :-)
> Using ElementWrapper, you can implement code for your application
> specific XML as extensions then work directly with it rather than going
> through a subclassed entry.  For instance...
> Entry entry = factory.newEntry();
> Foo foo = factory.newElement(MyConstants.FOO);
> foo.setBar("baz");
> entry.setContent(foo,"application/foo+xml");
> entry.writeTo(System.out);
> <entry xmlns="...">
>   ...
>   <content type="application/foo+xml">
>     <foo xmlns="http://example.org/foo">
>       <bar>baz</bar>
>     </foo>
>   </content>
> </entry>
> All you need to make this work is has Foo extend either the
> ElementWrapper or ExtensibleElementWrapper classes, and provide/register
> an ExtensionFactory implementation.

This clears things up. I failed to realize that the abdera extension
facility would work for content as well as atom extensions. I should
probably spend some time learning about axiom.

At any rate, I did as you said and I'm running into trouble. Looks
like FOMFactory.newContent() can't cast my Order to an OMContainer.
Order isa  ExtensibleElementWrapper.

java.lang.ClassCastException: eman.ism.api.rest.model.Order
	at org.apache.abdera.parser.stax.FOMFactory.newContent(FOMFactory.java:230)
	at org.apache.abdera.parser.stax.FOMFactory.newContent(FOMFactory.java:249)
	at org.apache.abdera.parser.stax.FOMEntry.setContent(FOMEntry.java:234)
	at eman.ism.api.rest.model.OrderTest.testOrder(OrderTest.java:20)

View raw message