Este contenido no está disponible en el idioma seleccionado.

Chapter 18. RESTEasy Atom Support


Atom is an XML-based document format that compiles lists of related information, known as feeds. Feeds are composed of a number of items, known as entries, each of which includes an extensible set of metadata (a title, for example).
Atom is primarily used to syndicate web content (such as weblogs and news headlines) to websites, and directly to user agents.
Atom is the RSS feed of the next generation. Although used primarily to syndicate weblogs and news, the format is starting to be used as the envelope for Web services such as distributed notifications and job queues, or simply to send or receive data in bulk to or from a service.

18.1. RESTEasy Atom API and Provider

RESTEasy has defined a simple object model to represent Atom in Java, and uses JAXB to marshal and unmarshal it. The org.jboss.resteasy.plugins.providers.atom package contains the main classes: Feed, Entry, Content, and Link. Each class is annotated with JAXB annotations. The distribution also contains the JavaDocs for this project, which are very useful in learning the model. The following code is a simple example of sending an Atom feed with the RESTEasy API:
import org.jboss.resteasy.plugins.providers.atom.Content;
import org.jboss.resteasy.plugins.providers.atom.Entry;
import org.jboss.resteasy.plugins.providers.atom.Feed;
import org.jboss.resteasy.plugins.providers.atom.Link;
import org.jboss.resteasy.plugins.providers.atom.Person;

@Path("atom")
public class MyAtomService
{

   @GET
   @Path("feed")
   @Produces("application/atom+xml")
   public Feed getFeed() throws URISyntaxException
   {
      Feed feed = new Feed();
      feed.setId(new URI("http://example.com/42"));
      feed.setTitle("My Feed");
      feed.setUpdated(new Date());
      Link link = new Link();
      link.setHref(new URI("http://localhost"));
      link.setRel("edit");
      feed.getLinks().add(link);
      feed.getAuthors().add(new Person("Bill Burke"));
      Entry entry = new Entry();
      entry.setTitle("Hello World");
      Content content = new Content();
      content.setType(MediaType.TEXT_HTML_TYPE);
      content.setText("Nothing much");
      entry.setContent(content);
      feed.getEntries().add(entry);
      return feed;
   }
}
Copy to Clipboard Toggle word wrap
RESTEasy's Atom provider is JAXB-based, so you are not limited to sending Atom objects with XML. You can automatically re-use RESTEasy's other JAXB providers (JSON and FastinfoSet). All you need to do is add +atom in front of the main subtype (that is, @Produces("application/atom+json") or @Consumes("application/atom+fastinfoset").
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat