Skip to main content

RDF Support (juneau-rest-server-rdf)

The opt-in juneau-rest-server-rdf module adds RDF (Jena) marshalling to a @Rest-annotated resource by supplying a predefined config interface that mirrors the standard universal config but with the RDF serializers and parsers enabled.

For the RDF serializers and parsers themselves, see RDF Basics.

<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-rest-server-rdf</artifactId>
<version>${juneau.version}</version>
</dependency>

At a glance​

ComponentPurpose
BasicUniversalJenaConfigDrop-in @Rest-annotated-class config identical to BasicUniversalConfig, plus every RDF format from RDF Basics (RDF/XML, Turtle, N3, N-Triples, N-Quads, TriG, TriX, JSON-LD, RDF/THRIFT, RDF/PROTO).

Quick start​

Extend BasicUniversalJenaConfig (or reference it via @Rest(config=...)) instead of the plain universal config to get RDF media types negotiated alongside JSON, XML, HTML, etc.:

@Rest
public class MyResource extends BasicRestServlet implements BasicUniversalJenaConfig {

@RestGet("/pojo")
public MyBean getPojo() {
return new MyBean(...);
}
}

A client that prefers Turtle then gets it for free:

String turtle = client.get("/pojo")
.accept("text/turtle")
.run()
.getContent().asString();

No handler code changes are required — the same POJO is serialized through whichever serializer content negotiation selects.

Relationship to juneau-marshall-rdf​

This module contributes no new marshalling logic of its own; it only wires the serializers/parsers that already ship in juneau-marshall-rdf into a @Rest config. Consumers who already build their own custom config interface can skip this module entirely and reference the RDF serializer/parser classes directly.

See also​

  • RDF Basics — the underlying serializers/parsers and supported formats.
  • @Rest-Annotated Classes — BasicUniversalConfig and the other predefined config interfaces this module extends.