TypeHandlerSpace Documentation

TypeHandlerSpace provides a JAX-RS Root Resource Class that delegates requests in its URI space (i.e. URIs starting with the prefix the bundle is installed with) to a TypeHandler for the RDF-Type(s) of the resource named by the requested URI. TypeHandlerSpace works on the clerezza.org platform it interacts with Triaxrs and with SCB and expects content and system graph to be located as per the platform conventions.

Processing of requests

While JAX-RS allows to bind Root Resources Classes to a specific URI-Path TypeHandlerSpace allows to bind such resources to an rdf:type. Root Resources are POJO providing methods handling different types of requests, with TypeHandlerSpace such POJOs can be bound to an RDF type in this function the class is called TypeHandler. When a request is processed by TypeHandlerSpace the rdf:types of the requested resource are determined from the content graph.

TypeHandlerSpace provides a root resource org.apache.clerezza.platform.typehandlerspace.TypeHandlerSpace which determines the type(s) of requested resource and calls a service of org.apache.clerezza.platform.typehandlerspace.TypeHandlerDiscovery to get a Typehandler, the request is the forwarded to this TypeHandler

The provided implementation of TypeHandlerDiscovery returns the available TypeHandler for the rdf:type with the highest priority. The Priority of rdf:types is determined by an rdf:List named <urn:x-localinstance:/typePriorityList> in the system graph. The actual TypeHandlers are OSGi services exposing java.lang.Object as service interface and with the property org.apache.clerezza.platform.typehandler=true. TypeHandlers are annotated with the org.apache.clerezza.platform.typehandlerspace.SupportedTypes annotation defining the rdf:types supported by the class.

Example

The following defines a class that is both a regular JAX-RS Root Resource Class as well as a TypeHandler for <http://example.org/ontology#MyType>.

/** * @scr.component * @scr.service interface="java.lang.Object" * @scr.property name="javax.ws.rs" type="Boolean" value="true" * @scr.property name="org.apache.clerezza.platform.typehandler" type="Boolean" value="true" * */ @SupportedTypes(types = { "http://example.org/ontology#MyType" }, prioritize = false) @Path("/example") public class Handler { ... }

Sub Resource Methods

Sub-resource methods in TypeHandlers are never invoked by TypeHandlerSpace, so they are only useful if a typeHandler is also used as regular JAX-RS Root Resource.

Copyright (c) 2009 trialox.org (trialox AG, Switzerland)