Atom is an XML-based document format that describes lists of related information known as "feeds". Feeds are composed of a number of items, known as "entries", each with an extensible set of attached metadata. For example, each entry has a title. The primary use case that Atom addresses is the syndication of Web content such as weblogs and news headlines to Web sites as well as directly to user agents.
Apache Wink provides an Atom Syndication Format data model for consuming and producing Atom Feeds and Atom Entries (application/atom+xml). All of the model classes are located under the org.apache.wink.common.model.atom and org.apache.wink.common.model.synd packages.
The Atom Syndication Format data model can also be used to produce Atom Feeds and Atom Entries in HTML (text/html) and JSON (application/json) formats. For more details regarding HTML see section HTML (TBD). For JSON format see section (TBD) |
The following table shows the Atom Feed data models and the representations in which the Atom data models can be serialized and de-serialized.
|
Supported |
Media Types |
Data Model |
Provider registration |
---|---|---|---|---|
Read |
Yes |
application/atom+xml |
org.apache.wink |
Not required. Registered by default |
Write |
Yes |
application/atom+xml |
org.apache.wink |
Not required. Registered by default |
The following table shows the Atom Entry data models and the representations in which it can be serialized and de-serialized.
|
Supported |
Media Types |
Data Model |
Provider registration |
---|---|---|---|---|
Read |
Yes |
application/atom+xml |
org.apache.wink |
Not required. Registered by default |
Write |
Yes |
application/atom+xml |
org.apache.wink |
Not required. Registered by default |
The following code example demonstrates reading and writing of Atom Feeds and Atom Entries.
The following code example demonstrates the creation of an Atom Feed.
@GET @Produces(MediaType.APPLICATION_ATOM_XML) public AtomFeed getFeed() { AtomFeed feed = new AtomFeed(); feed.setId("http://example.com/atomfeed"); feed.setTitle(new AtomText("Example")); feed.setUpdated(new Date()); AtomLink link1 = new AtomLink(); ... return feed; } } |
The following code example demonstrates the consumption of an Atom Feed.
@POST @Consumes(MediaType.APPLICATION_ATOM_XML) public void setFeed(AtomFeed feed) { ... return; } |
The following code example demonstrates the creation of an Atom Entry.
@GET @Produces(MediaType.APPLICATION_ATOM_XML) public AtomEntry getEntry() { AtomEntry entry = new AtomEntry(); entry.setId("http://example.com/entry"); entry.setTitle(new AtomText("Web Demo")); entry.getLinks().add(link2); entry.setUpdated(new Date()); entry.setPublished(new Date()); ... return entry; } |
The following code example demonstrates the consumption of an Atom Entry.
@POST @Consumes(MediaType.APPLICATION_ATOM_XML) public void setEntry(AtomEntry entry) { ... return; } |