Skip to content

Commit

Permalink
Update doc to match new feature style and put a few more items in the…
Browse files Browse the repository at this point in the history
… demo model
kingsfleet committed Jan 31, 2014
1 parent 919bfcb commit d311dc7
Showing 2 changed files with 39 additions and 20 deletions.
57 changes: 37 additions & 20 deletions docs/src/main/docbook/linking.xml
Original file line number Diff line number Diff line change
@@ -51,6 +51,26 @@
APIs must be hypertext-driven</ulink>. JAX-RS currently offers &jaxrs.core.UriBuilder; to simplify URI
creation but Jersey adds an additional annotation-based alternative that is described
here.</para>

<section>
<title>Dependency</title>

<para>
To use Declarative Linking you need to add &lit.jersey-media-linking; module to your
&lit.pom.xml; file:

<programlisting language="xml" linenumbering="unnumbered">&lt;dependency&gt;
&lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
&lt;artifactId&gt;jersey-media-linking&lt;/artifactId&gt;
&lt;version&gt;&version;&lt;/version&gt;
&lt;/dependency&gt;</programlisting>

If you're not using Maven make sure to have all needed dependencies (see &jersey-media-linking;) on
the classpath.
</para>
</section>


<section>
<title>Links in Representations</title>
<para>Links are added to representations using the <literal>@Ref</literal> annotation on
@@ -174,28 +194,25 @@ URI offers;</programlisting>
which can contain multiple <literal>@LinkHeader</literal> annotations.</para>
</section>


<section>
<title>Configuration</title>
<para>Declarative hyperlinking support is provided in the form of a filter. First, the application
must declare a dependency on the <literal>jersey-media-linking</literal> module:</para>
<programlisting language="xml">&lt;dependency&gt;
&lt;groupId&gt;org.glassfish.jersey.media.linking&lt;/groupId&gt;
&lt;artifactId&gt;jersey-media-linking&lt;/artifactId&gt;
&lt;version&gt;${jersey-version}&lt;/version&gt;
&lt;/dependency&gt;</programlisting>
<para>Second the filter needs to be installed in the application either programmatically by
adding:</para>
<programlisting>com.sun.jersey.server.linking.LinkFilter</programlisting>
<para>to the list defined by:</para>
<programlisting>com.sun.jersey.spi.container.ContainerResponseFilters</programlisting>
<para>or using a <literal>web.xml</literal> init parameter:</para>
<programlisting language="xml">&lt;init-param&gt;
&lt;param-name&gt;com.sun.jersey.spi.container.ContainerResponseFilters&lt;/param-name&gt;
&lt;param-value&gt;com.sun.jersey.server.linking.LinkFilter&lt;/param-value&gt;
&lt;/init-param&gt;
</programlisting>
<para>See the <ulink url="https://maven.java.net/content/repositories/&repository;/org/glassfish/jersey/examples/jersey-examples-declarative-linking">jersey-examples-declarative-linking</ulink> for more details.</para>
<title>Configure and register</title>

<para>
In order to add the Declarative Linking feature register &jersey.media.LinkingFeature;

<example>
<title>Creating JAX-RS application with Declarative Linking feature enabled.</title>

<programlisting language="java">// Create JAX-RS application.
final Application application = new ResourceConfig()
.packages("org.glassfish.jersey.examples.linking")
.register(LinkingFeature.class);</programlisting>
</example>
</para>
</section>




</chapter>
Original file line number Diff line number Diff line change
@@ -65,6 +65,8 @@ private ItemsModel() {
items.add(new ItemModel("Item 0"));
items.add(new ItemModel("Item 1"));
items.add(new ItemModel("Item 2"));
items.add(new ItemModel("Item 3"));
items.add(new ItemModel("Item 4"));
}

public boolean hasNext(String currentId) {

0 comments on commit d311dc7

Please sign in to comment.