org.ow2.jonas.jaxrs.jersey.internal
Class JerseyApplicationPublisher

java.lang.Object
  extended by org.ow2.jonas.jaxrs.jersey.internal.JerseyApplicationPublisher

public class JerseyApplicationPublisher
extends Object

The JerseyApplicationPublisher is responsible of publishing JAX-RS Application registered in the OSGi service registry onto the HttpService.

Without any configuration (and any dependency on a JAX-RS implementation), a client can easily expose his Application with the following code:

     bundleContext.registerService(Application.class, new MyApplication(), null);
 

This RESTful application will be available under the following path: /{bundle-symbolic-name}/{bundle-version}.

Name collision could happen if the same Bundle provides more than 1 Application.

To avoid collisions, the client should provide a unique value into the jonas.jaxrs.context-path service property when registering his services.

     Properties sp = new Properties();
     sp.setProperty("jonas.jaxrs.context-path", "/my-app");
     bundleContext.registerService(Application.class, new MyApplication(), sp);
 
O

Notice that @ApplicationPath (if provided) will be respected (appended to the context path).

Author:
Loic Albertin

Field Summary
static String CONTEXT_PROPERTY
          Optional service property that defines the web context name of the REST application.
 
Constructor Summary
JerseyApplicationPublisher()
           
 
Method Summary
 void bindApplication(javax.ws.rs.core.Application application, org.osgi.framework.ServiceReference reference)
          Manage a newly registered Application service.
 void setHttpService(org.osgi.service.http.HttpService httpService)
          Bind the required OSGi HTTP Service.
 void stop()
          Stop the publisher, un-registering all managed REST applications.
 void unbindApplication(org.osgi.framework.ServiceReference reference)
          Un-manage the given Application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_PROPERTY

public static final String CONTEXT_PROPERTY
Optional service property that defines the web context name of the REST application.

See Also:
Constant Field Values
Constructor Detail

JerseyApplicationPublisher

public JerseyApplicationPublisher()
Method Detail

setHttpService

public void setHttpService(org.osgi.service.http.HttpService httpService)
Bind the required OSGi HTTP Service.

Parameters:
httpService - required service

stop

public void stop()
Stop the publisher, un-registering all managed REST applications.


bindApplication

public void bindApplication(javax.ws.rs.core.Application application,
                            org.osgi.framework.ServiceReference reference)
Manage a newly registered Application service.

Parameters:
application - REST application
reference - the associated ServiceReference.

unbindApplication

public void unbindApplication(org.osgi.framework.ServiceReference reference)
Un-manage the given Application.

Parameters:
reference - reference of the Application service.


Copyright © 2013 OW2 Consortium. All Rights Reserved.