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.
- Common - code used throughout all of the other modules
- Annotations
- ISO 8601 DateTime, Duration and Interval Implementation
- Geographic Coordinates and ISO 6709 Position Implementation
- HTTP Header support includeing custom authentication, cache-controls,
preference negotiation, content negotiation, and web linking.
- IO Utilities for character set detection, rewindable input streams,
and filtered readers
- Internationalized Resource Identifier (IRI) implementation
- RFC 4646 Language Tag Implementation
- MIME Media Type utilities
- URI Templates implementation based on the most recent draft
- Utilities for working with Unicode codepoints and normalization
- A new Selector framework for more intelligent filtering of objects
in the Atom Feed Object Model API
- A new Pub/Sub "Pusher" framework for enabling asynchronous notification
of Atom Entries or Activities
- The core Publishing Protocol Framework
- Core - the core of the Atom Syndication Format implementation.
- Feed Object Model - The primary API for Atom documents
- Axiom-based FOM Implementation - The default implementation of the
Feed Object Model APIs based on Apache Axiom and the StAX Pull Parser
- The Core Factory and ExtensionFactory framework for creating Atom documents.
- The Core Parser framework for parsing Atom documents.
- The Core Writer framework for serializing Atom documents.
- Support for navigating and querying the Feed Object Model using
XPath expressions.
- Client - RESTful HTTP Client implementation that supports both the
Atom Publishing Protocol and Activity Streams.
- Server - Provides framework code used to build Atom Publishing Protocol servers.
- Security - Provides support for XML Digital Signatures and XML Encryption of Atom Documents
- Extensions - Provides support for a number of standard and non-standard extension to the
Atom format:
- Atom Threading Extensions
- Atom License Extension
- Atom Feature Discovery
- Atom Bidi Attribute
- Feed Paging and Archiving
- GeoRSS
- Simple Sharing Extensions
- MediaRSS
- OpenSearch* -- (Not yet ported to Abdera2)
- Activities - Provides an implementation of the Activity Streams standard
- Support for consuming and producing Activity Streams
- Framework code for producing Activity Streams Publishing servers
- Standard and non-standard extensions to the Activity Streams format
- Examples
- Test Cases
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 Jars
- Common - abdera2-common-2.0-SNAPSHOT.jar
Depends on:
- Java Activation Framework (JAF) 1.1 (e.g. geronimo-activation_1.1_spec)
- Java Servlet API 3.0
- Apache Commons Logging v1.1.1
- Apache Commons Codec v1.5
- International Components for Unicode (ICU4J) v4.8.1.1
- Core - abdera2-core-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- Apache Axiom 1.2.12
- Jaxen v1.1.1
- StAX API (e.g. org.codehaus.woodstox v3.2.6)
- Security - abdera2-security-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- abdera2-core-2.0-SNAPSHOT.jar
- Apache Santuario XML Security v1.4.5
- Client - abdera2-client-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- abdera2-core-2.0-SNAPSHOT.jar (required if using Atompub client)
- Apache HTTP Components v4.1.2 (including httpclient, httpmime, httpcore and httpcache)
- Server - abdera2-server-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- abdera2-core-2.0-SNAPSHOT.jar
- Java Servlet API 3.0
- Extensions - abdera2-ext-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- abdera2-core-2.0-SNAPSHOT.jar
- abdera2-server-2.0-SNAPSHOT.jar
- abdera2-client-2.0-SNAPSHOT.jar
- nu.validator.htmlparser v1.2.1
- Java Servlet API 3.0
- Activities - abdera2-activities-2.0-SNAPSHOT.jar
Depends on:
- abdera2-common-2.0-SNAPSHOT.jar
- com.google.code.gson v1.7.1
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