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.

Using the 0.3.0-incubating release
abdera.getWriterFactory().getWriter("prettyxml").writeTo(feed, System.out);
Using the current trunk

JSON Writer

The JSON XML Writer is provided by the JSON Extension Jar

Using the 0.3.0-incubating release
abdera.getWriterFactory().getWriter("json").writeTo(entry, System.out);
Using the current trunk

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 = {
  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.

  • No labels