You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

Apache Abdera provides an implementation of the IETF Atom Syndication Format and Atom Publishing Protocol standards (RFC's 4287 and 5023).

Abdera is composed of a number of individual modules:

  • Core: Provides the core interfaces used throughout Abdera:
    • Feed Object Model - A set of Java interfaces and abstract classes modeled after the various document and element types defined by the Atom specifications.
    • Parser and Factory interfaces - Interfaces that provide the mechanisms for creating and consuming Atom documents.
    • ExtensionFactory - The primary means by which extensions to the Atom format are integrated into Abdera. Extension Factories are used by both the Parser and Factory.
    • Writer - The means by which Feed Object Model objects are serialized into XML or other formats
    • ParseFilter - Provides a means of filtering the stream of parse events
    • Converter - Base interfaces and utilities for converting objects into Feed Object Model objects
    • XPath - Base interface for navigating the Feed Object Model using XPath
  • Dependencies: Contains all of the other jars and code Abdera depends on
  • Parser: Provide an implementation of the Feed Object Model based on the Apache Axiom project
  • Protocol: Provides the base interfaces and utility classes used for the RFC 5023 (Atompub) implementation
  • Server: Provides framework code used to build Atompub servers
  • Client: Provides an Atompub client implementation that is based on the Apache Commons HTTP Client.
  • Spring: Extends the Server module by adding support for the Spring framework
  • Security: Provides support for XML Digital Signatures and XML Encryption
  • Extensions: Provides support for a number of standard and non-standard extensions to the Atom format
    • Atom Threading Extensions
    • Atom License Extension
    • Atompub Feature Discovery
    • Atom Bidi Attribute
    • Feed Paging and Archiving
    • GeoRSS
    • Simple Sharing Extensions
    • MediaRSS
    • OpenSearch
    • GData and WSSE Autbentication
  • Examples: Provides a number of examples

Getting Started

The two most common uses for Abdera are creating and parsing Atom documents.

Parsing an Atom Document and printing entry titles
  Abdera abdera = new Abdera();
Parser parser = abdera.getParser();
  
URL url = new URL("http://www.snellspace.com/wp/wp-atom1.php");
Document<Feed> doc = parser.parse(url.openStream(),url);
Feed feed = doc.getRoot();
System.out.println(feed.getTitle());
for (Entry entry : feed.getEntries()) {
  System.out.println("\t" + entry.getTitle());
)
Creating an Atom Document and adding an entry
  Abdera abdera = new Abdera();
Feed feed = abdera.newFeed();

feed.setId("tag:example.org,2007:/foo");
feed.setTitle("Test Feed");
feed.setSubtitle("Feed subtitle");
feed.setUpdated(new Date());
feed.addAuthor("James Snell");
feed.addLink("http://example.com");
feed.addLink("http://example.com/foo","self");

Entry entry = feed.addEntry();
entry.setId("tag:example.org,2007:/foo/entries/1");
entry.setTitle("Entry title");
entry.setSummaryAsHtml("<p>This is the entry title</p>");
entry.setUpdated(new Date());
entry.setPublished(new Date());
entry.addLink("http://example.com/foo/entries/1");

As you can see in both of these examples, the first step to using Abdera is to create an instance of the Abdera object. This special thread-safe class bootstraps the Abdera configuration and provides access to all of the other components. One of the most important tasks that the Abdera object performs is the automatic discovery of extensions.

Creating a new instance of the Abdera object can be time consuming so it is recommended that only a single instance be creating per application. The Abdera object and it's direct children (Parser, Factory, XPath, etc) are threadsafe and can be stored statically.

Creating a static instance of Abdera
  public class MyApplication {
    private static Abdera abdera = null;
    
    public static synchronized Abdera getInstance() {
      if (abdera == null) abdera = new Abdera();
      return abdera;
    }
  }

Once an Abdera instance is created, you can begin parsing and creating Atom documents.

Configuring Abdera

Abdera uses a powerful and flexible configuration mechanism that, fortunately, most developers will never actually have to even think much about. Abdera uses it's configuration model to automatically discover the various implementation classes for it's Parser, Factory, Feed Object Model, ExtensionFactories, etc. The closest most developers will ever need to get to the configuration system is when implementing a new ExtensionFactory for a new Atom format extension. Implementation of Extension Factories will be covered later. For now, we can skip the details about the Abdera configuration system.

The Feed Object Model

The Feed Object Model is the set of objects you will use to interact with Atom documents. It contains classes such as "Feed", "Entry", "Person" etc, all of which are modeled closely after the various elements and documents defined by the two Atom specifications. The Javadocs for the Feed Object Model can be found here.

TODO Complete this

  • No labels