Link Serialization With JAX-RS 2+

JAX-RS 2+ supports rfc5988 compliant and JAXB-serializable links.

A Link can be treated as an ordinary payload:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

public class Message {

    private Link airhacksLink;

    public Message() {
        this.airhacksLink = Link.fromUri("").

An entity directly exposed via:

public class MessagesResource {

    public Message get() {
        return new Message();

produces the following output:

	<airhacksLink href="" rel="workshops"/>

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting

NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: and newsletter:

A book about rethinking Java EE Patterns


Your code uses rel("javaee"), but the output contains rel="workshops". Is that a typo (semantico?) or am I missing something?

Posted by ron on February 18, 2015 at 11:14 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments