Abdera2 - Getting Started

Apache Abdera2 is an updated implementation of the IETF Atom Syndication Format (RFC 4287), Atom Publishing Protocol (RFC 5023) and Activity Streams (http://activitystrea.ms) standards.

Creating and Consuming Atom Documents

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

Minimal required Maven dependency:


    org.apache.abdera2
    abdera2-core
    2.0  

]]>

Parsing an Atom Document and printing entry titles

Example code:

 doc = parser.parse(url.openStream(),url.toString());
Feed feed = doc.getRoot();
System.out.println(feed.getTitle());
for (Entry entry : feed.getEntries()) {
  System.out.println("\t" + entry.getTitle());
}
System.out.println (feed.getAuthor());
]]>

Creating an Atom Feed Document and adding an entry

Example code:

This is the entry title

"); entry.setUpdated(new Date()); entry.setPublished(new Date()); entry.addLink("http://example.com/foo/entries/1"); ]]>

Instantiating Abdera

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.

New for Abdera2: The default constructor on the Abdera class has been protected making it impossible to use Abdera abdera = new Abdera() This is to help ensure that only a single Abdera instance is used per application. To acquire the singleton, static instance of the Abdera class, use Abdera abdera = Abdera.getInstance().

The Atom Publishing Protocol (Atompub)

TBD

Creating and Consuming Activity Streams

Consuming an Activity Stream:

 stream = io.readCollection(url.openStream(),"UTF-8");
for (Activity activity : stream.getItems()) {
  System.out.println(activity.getTitle());
}
]]>

Creating an Activity Stream:

 stream =
  new Collection();
 
Activity activity = 
  new Activity();
activity.setVerb(Verb.POST);
 
PersonObject actor = 
  new PersonObject();
actor.setDisplayName("James");
activity.setActor(actor);
 
NoteObject note = 
  new NoteObject();
note.setContent("This is a note");
activity.setObject(note);
  
stream.addItem(activity);
 
stream.writeTo(System.out);
]]>

Abdera2 also supports a hybrid streaming model for producing Activity Streams:

The Activity Stream Publishing Protocol

TBD

Overview of Abdera2 Modules

As with previous versions, Abdera2 leverages a modular architecture that provides a great deal of flexibility to deploy only the components necessary for an application. For this version, the modules have been reorganized.

Classpath

Maven


  org.apache.abdera2
  abdera2-common
  2.0

 

  org.apache.abdera2
  abdera2-core
  2.0

 

  org.apache.abdera2
  abdera2-client
  2.0

 

  org.apache.abdera2
  abdera2-server
  2.0

 

  org.apache.abdera2
  abdera2-security
  2.0

 

  org.apache.abdera2
  abdera2-ext
  2.0

 

  org.apache.abdera2
  abdera2-activities
  2.0

]]>

Manual Classpath Setup

Abdera2 HTTP Client API

In Abdera2, the HTTP Client interface has been significantly updated and factored around the Apache HTTP Components version 4.1.2.

Generic REST Client

The Generic REST Client is an HTTP Client that supports all of the core HTTP Methods (get, post, put, delete, head, options, trace) and includes support for extension methods.

Creating the Generic REST Client:

Retrieving a Resource (GET):

The ClientResponse object provides access to all of the response headers such as ETag and Last-Modified.

Creating resources using HTTP Post:

Updating resources using HTTP PUT:

Deleting resources with HTTP DELETE:

Using custom HTTP methods:

Customizing request options:

Using SSL

TBD

Authentication

TBD

Cookies

TBD

Caching

TBD

AtomPub Client

TBD

Activity Streams Client

TBD