Skip to content

harschware/osgi-jax-rs-connector

 
 

Repository files navigation

OSGi - JAX-RS Connector 2.4.1

JAX-RS (JSR 311) is the community-driven Standard for building RESTful web services with Java. The reference implementation for JAX-RS is Jersey and ships as OSGi bundles. This project connects Jersey and OSGi at the service level. This means that OSGi services can be published as RESTful web services by simply registering them as OSGi services and also consumed as OSGi services ;).

Features

When the com.eclipsesource.jaxrs.connector bundle is activated all @Path/@Provider annotated objects that are registered as OSGi services will be published as RESTful web services. Services can be added or removed during runtime and will be published or postponed. To publish services on different ports the http.port service property can be used. The connector detects configuration changes during runtime (e.g. when done by the OSGi Configuration Admin Service).

The second major feature of the connector is the consumer part. The idea behind this is to be able to reuse the @Path/@Provider interfaces for consuming the services. See these posts for a detailed description: Consuming REST services in Java the cool way, Consuming REST services in OSGi the cool way.

Installation

Install from this software repository into your target: http://hstaudacher.github.com/osgi-jax-rs-connector or download the binaries:

If dependencies can't be satisfied please disable "include required software" within the target editor.

Usage

  • For Eclipse: Add the com.eclipsesource.jaxrs.connector.feature (OSGi JAX-RS Connector) to your target using the url above.
  • Add the com.eclipsesource.jaxrs.connector and the 3 Jersey bundles to your OSGi instance.
  • Convert some OSGi service to resources like in this tutorial
  • Point your client to the specified url. Don't forget that the default root path is /services. So registering a service with the path /example would lead to /services/example.
  • Read this post to see how to handle the consumer.

Examples

This git repository contains two example bundles. A @Path annotated resource will be registred in com.eclipsesource.jaxrs.connector.example and com.eclipsesource.jaxrs.connector.example.ds. In the ds bundle OSGi Declarative Services will be used to register the service and it provides an additional example for @Provider annotated providers. If you want to run the examples within your Eclipse IDE use the launch configurations located in the bundles.
After you have started the bundles a service will be available at http://localhost:9090/services/osgi-jax-rs.

Requirements

  • OSGi Core Specification 4.2 and an OSGi HttpService implementation (e.g. Equinox, Felix).
  • JRE 1.6 (same as Jersey)

Alternatives

Jersey version

Jersey 2.0 (m12) is included in the software repository.

Changelog

  • 1.0 (Jan 23rd, 2012): Functionality to publish @Path annotated OSGi services as web resources.
  • 2.0 (Aug 27th, 2012): Use the config admin to specify the root path. The default root path is /services. You can configure the path by specifying a config with the service.pid com.eclipsesource.jaxrs.connector and the property root. The path needs to be a valid servlet path e.g. "/api".
  • 2.1 (Oct 26th, 2012): Besides @Path annotated object it's now possible to register @Provider annotated objects as OSGi services too. Thanks to Dirk Lecluse for this contribution.
  • 2.1.1 (Nov 11th, 2012): Updated included Jersey Version (1.15).
  • 2.2.0 (Jan 3rd, 2013): Updated included Jersey Version (2.0 m11). Added Consumer integration.
  • 2.3.0 (Jan 22th, 2013): Added service property to exclude a resource from publishing. See ServiceProperties.
  • 2.4.0 (Feb 28th, 2013): Updated included Jersey Version (2.0 m12).
  • 2.4.1 (Mar 3rd, 2013): Adds error handling to consumer.

License

The code is published under the terms of the Eclipse Public License, version 1.0.

Included binaries from Jersey, version 2.0 m12, which are published under two licenses, the CDDL 1.1 and GPL 2 with CPE

About

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below

Resources

Stars

Watchers

Forks

Packages

No packages published