The Guided Tour walks you through the following tasks:
Examine how the TRS toolkit, can help you create a TRS provider, using JAX-RS
- Open the file org.eclipse.lyo.rio.trs.resources.BaseResource.java. Notice @Path("/trs/"+TRSConstants.TRS_TERM_BASE) at the top of the class.
- This is a JAX-RS annotation that assigns a relative path (from the jax-rs servlet context) for the Base Resource RESTful endpoint. There are various constants and vocabularies defined in the toolkit to abstract the terms and namespaces from TRS provider implementers.
- In the reference application, the Base Resource is paged so that, according to the specification, a get on the base resources will do a redirect to the first page of base resources. This is what happens in the getBase() endpoint.
- The other method, getBasePage(page), returns the Base resource at the given page. The class org.eclipse.lyo.core.trs.Base is provided by the TRS toolkit. It is basically a simple java bean that has been annotated with various OSLC4J annotations to allow the OSLC4J marshalling to create the proper RDF document for the JAX-RS configured serialization.
- Both methods have additional annotations such as @GET, which identifies the type of HTTP traffic it can handle, as well as an @Produces that identifies the return type the method can handle. In all cases, the REST endpoints can return RDF XML, XML, or JSON. JAX-RS dynamically returns the correct format based on the HTTP request that is received.
- Open the file com.ibm.teams.integration.refapps.trs.resources.TRSResource.java
- In similar fashion it also has an @Path annotation that identifies the root of the RESTful service for the Tracked Resource Set.
- The reference application is utilizing the segmented Changelog concept from the TRS Specification (sec 18.104.22.168). The method getTrackedResourceSet() returns a tracked resource set with the most recent segment of the changelog.
- The other method in this class, getChangeLog(page), returns the segmented portion of the change as requested by the HTTP request