Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Lyo/OSLC4JAnnotations"

< Lyo
Line 66: Line 66:
 
         )
 
         )
 
</code>
 
</code>
 +
 +
'''Creating the ServiceProvider'''
  
 
To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.
 
To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.

Revision as of 19:01, 7 March 2014

OSLC4J will generate an OSLC service description document for you if you've properly annotated your code. You should have an @OslcService annotation on every JAX-RS resource you want to use with OSLC4J, even if you only have one service description document.

Query Capabilities and Creation Factories

To use @OslcQueryCapability and @OslcCreationFactory, simply add those annotations to the @GET and @POST methods for each resource that handles those requests. The URIs are added to the service description document calculated from the JAX-RS @Path annotation.

Here is an example @OslcQueryCapability:

   @OslcQueryCapability
   (
       title = "Change Request Query Capability",
       label = "Change Request Catalog Query",
       resourceShape = OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST,
       resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
       usages = {OslcConstants.OSLC_USAGE_DEFAULT}
   )
   @GET
   @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   		   OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   public ChangeRequest[] getChangeRequests(@QueryParam("oslc.where") final String where)
   {
      // ... implementation here ...
   }

Here is an example @OslcCreationFactory:

   @OslcCreationFactory
   (
        title = "Change Request Creation Factory",
        label = "Change Request Creation",
        resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST},
        resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
        usages = {OslcConstants.OSLC_USAGE_DEFAULT}
   )
   @POST
   @Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   	       OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   	       OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   public Response addChangeRequest(ChangeRequest changeRequest)
   {
      // ... implementation here ...
   }

Dialogs

  • For selection dialogs, the @OslcDialogs or @OslcDialog annotation has to be on a @GET method, usually the query capability.
  • For creation dialogs, the annotation has to be on an @POST method, usually the creation factory.

The @OslcDialog "uri" determines the URI for the dialog, and you can use path parameters. For instance, the Bugzilla adapter has this selection dialog:

       @OslcDialog
       (
            title = "Change Request Selection Dialog",
            label = "Change Request Selection Dialog",
            uri = "/{productId}/changeRequests/selector",
            hintWidth = "525px",
            hintHeight = "325px",
            resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
            usages = {OslcConstants.OSLC_USAGE_DEFAULT}
       )

Creating the ServiceProvider

To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.

Back to the top