Abdera includes the ability to plug in custom serializers. These are implementations of the org.apache.abdera.writer.Writer interface and are configured via the classpath.
There are two custom Writer implementations that ship with Abdera. The PrettyXML writer and a JSON Writer.
Pretty XML Writer
The Pretty XML Writer is always available.
abdera.getWriterFactory().getWriter("prettyxml").writeTo(feed, System.out);
feed.writeTo("prettyxml",System.out);
JSON Writer
The JSON XML Writer is provided by the JSON Extension Jar
abdera.getWriterFactory().getWriter("json").writeTo(entry, System.out);
feed.writeTo("json",System.out);
The JSON Writer is only capable of writing Atom Entry documents.
Custom Writers
You can implement your own Writer by extending the AbstractNamedWriter class.
public class MyWriter extends AbstractNamedWriter { private static final String[] FORMATS = { "application/custom", }; public MyWriter() { super("mywriter", FORMATS); } //... impl methods }
Once implemented, the custom writer is registered with Abdera by listing the full class name of the writer in the META-INF/services/org.apache.abdera.writer.NamedWriter file. You can include this file in your applications jar or classpath and it will be automatically discovered by Abdera.