You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Larry Touve <lt...@potomacfusion.com> on 2010/04/06 18:55:30 UTC

OSGI Bundles as Web Services

I'm using Jersey to develop some RESTful Web Services.  I'd like to create these as OSGI bundles that I can deploy.  Is there any (relatively easy) way to do this?  I'm currently running Glassfish V3, and am deploying bundles to the underlying Felix, but  I'd like to run just Felix (without GF) and have the Web Services exposed (through the Felix http bundle?).

I looked at the example from the Apache Felix HTTP Service page (http://felix.apache.org/site/apache-felix-http-service.html)  where the ServiceReference from the HttpService class is used to register a pojo that extends HttpServlet.  Would It be similar for a Jersey POJO?


Thanks,
 Larry


Re: OSGI Bundles as Web Services

Posted by Chris Blunck <ch...@thebluncks.com>.
Larry,

You will need to implement your own ResourceConfig and ClassScanner that are
OSGi-aware.  The DefaultResourceConfig with Jersey will not work out of the
box and the ClassScanner they provide does not work either.

The way I'd recommend going is:
  - Implement your ResourceConfig and ClassScanner
  - Implement a service and activator
  - In the service activator register the Jersey servlet with the
HttpService provided by Jetty

The other issue you'll encounter is that Jersey creates a new instance of
your JSR311 annotated classes for each request.  If you are using DS you'll
need some sort of ServiceLocator that can get a ServiceReference and resolve
a service.  I use FrameworkUtil.getBundle() to get my bundle, from which I
get a BundleContext, from which I can resolve services.

I have my Jersey wired up this way and it works pretty nicely.  I can
refresh/update my services and my thin JSR311 layer takes advantage of the
new services when they come online.  Very handy...


Good luck,

-c

On Tue, Apr 6, 2010 at 12:55 PM, Larry Touve <lt...@potomacfusion.com>wrote:

> I'm using Jersey to develop some RESTful Web Services.  I'd like to create
> these as OSGI bundles that I can deploy.  Is there any (relatively easy) way
> to do this?  I'm currently running Glassfish V3, and am deploying bundles to
> the underlying Felix, but  I'd like to run just Felix (without GF) and have
> the Web Services exposed (through the Felix http bundle?).
>
> I looked at the example from the Apache Felix HTTP Service page (
> http://felix.apache.org/site/apache-felix-http-service.html)  where the
> ServiceReference from the HttpService class is used to register a pojo that
> extends HttpServlet.  Would It be similar for a Jersey POJO?
>
>
> Thanks,
>  Larry
>
>

RE: OSGI Bundles as Web Services

Posted by Larry Touve <lt...@potomacfusion.com>.
Thanks for everyone's suggestions.  I have more than enough information to research now.  One other thing that I found was Dynamic-RS from http://www.dynamicjava.org that seems to be promising as well.  However, their example doesn't work on Felix, which is what we're running.  I'll check on the latest from Jersey, thanks for the heads up.

Thanks again!


> -----Original Message-----
> From: David Tkaczyk [mailto:dtkaczyk@camiant.com]
> Sent: Wednesday, April 07, 2010 8:32 AM
> To: Karl Pauls; users@felix.apache.org
> Subject: RE: OSGI Bundles as Web Services
> 
> I would recommend checking in with the Jersey guys.  I believe they are
> very close to an OSGi compliant release.  If you can wait, that's your
> best bet...
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: OSGI Bundles as Web Services

Posted by David Tkaczyk <dt...@camiant.com>.
I would recommend checking in with the Jersey guys.  I believe they are very close to an OSGi compliant release.  If you can wait, that's your best bet...

-----Original Message-----
From: Karl Pauls [mailto:karlpauls@gmail.com]
Sent: Tuesday, April 06, 2010 3:13 PM
To: users@felix.apache.org
Subject: Re: OSGI Bundles as Web Services

Not sure whether this is what you are looking for but iirc clerezza
(http://incubator.apache.org/clerezza/) has a JAX-RS implementation
designed to work in an OSGi environment and allowing to provide
Root-Resources as OSGi services. There is virtually no documentation
yet but you can always ask at the mailing list if you have further
questions. Maybe have a look at one of the subprojects that use jaxrs
like http://svn.apache.org/repos/asf/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.web.fileserver

regards,

Karl

On Tue, Apr 6, 2010 at 6:55 PM, Larry Touve <lt...@potomacfusion.com> wrote:
> I'm using Jersey to develop some RESTful Web Services.  I'd like to create these as OSGI bundles that I can deploy.  Is there any (relatively easy) way to do this?  I'm currently running Glassfish V3, and am deploying bundles to the underlying Felix, but  I'd like to run just Felix (without GF) and have the Web Services exposed (through the Felix http bundle?).
>
> I looked at the example from the Apache Felix HTTP Service page (http://felix.apache.org/site/apache-felix-http-service.html)  where the ServiceReference from the HttpService class is used to register a pojo that extends HttpServlet.  Would It be similar for a Jersey POJO?
>
>
> Thanks,
>  Larry
>
>



--
Karl Pauls
karlpauls@gmail.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI Bundles as Web Services

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

Just for the record, Distributed OSGi RI [1] can have OSGI services exposed
as RESTful endpoints with the help of the CXF JAX-RS implementation, please
see [2] and [3]

cheers, Sergey 

[1] http://cxf.apache.org/distributed-osgi.html 
[2]
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-IntegrationwithDistributedOSGi
[3]
http://cxf.apache.org/distributed-osgi-reference.html#DistributedOSGiReference-ServiceProviderpropertiesForConfiguringRESTfulJAXRSbasedendpointsandconsumers



Karl Pauls wrote:
> 
> Not sure whether this is what you are looking for but iirc clerezza
> (http://incubator.apache.org/clerezza/) has a JAX-RS implementation
> designed to work in an OSGi environment and allowing to provide
> Root-Resources as OSGi services. There is virtually no documentation
> yet but you can always ask at the mailing list if you have further
> questions. Maybe have a look at one of the subprojects that use jaxrs
> like
> http://svn.apache.org/repos/asf/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.web.fileserver
> 
> regards,
> 
> Karl
> 
> On Tue, Apr 6, 2010 at 6:55 PM, Larry Touve <lt...@potomacfusion.com>
> wrote:
>> I'm using Jersey to develop some RESTful Web Services.  I'd like to
>> create these as OSGI bundles that I can deploy.  Is there any (relatively
>> easy) way to do this?  I'm currently running Glassfish V3, and am
>> deploying bundles to the underlying Felix, but  I'd like to run just
>> Felix (without GF) and have the Web Services exposed (through the Felix
>> http bundle?).
>>
>> I looked at the example from the Apache Felix HTTP Service page
>> (http://felix.apache.org/site/apache-felix-http-service.html)  where the
>> ServiceReference from the HttpService class is used to register a pojo
>> that extends HttpServlet.  Would It be similar for a Jersey POJO?
>>
>>
>> Thanks,
>>  Larry
>>
>>
> 
> 
> 
> -- 
> Karl Pauls
> karlpauls@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/OSGI-Bundles-as-Web-Services-tp28154612p28162455.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI Bundles as Web Services

Posted by Karl Pauls <ka...@gmail.com>.
Not sure whether this is what you are looking for but iirc clerezza
(http://incubator.apache.org/clerezza/) has a JAX-RS implementation
designed to work in an OSGi environment and allowing to provide
Root-Resources as OSGi services. There is virtually no documentation
yet but you can always ask at the mailing list if you have further
questions. Maybe have a look at one of the subprojects that use jaxrs
like http://svn.apache.org/repos/asf/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.web.fileserver

regards,

Karl

On Tue, Apr 6, 2010 at 6:55 PM, Larry Touve <lt...@potomacfusion.com> wrote:
> I'm using Jersey to develop some RESTful Web Services.  I'd like to create these as OSGI bundles that I can deploy.  Is there any (relatively easy) way to do this?  I'm currently running Glassfish V3, and am deploying bundles to the underlying Felix, but  I'd like to run just Felix (without GF) and have the Web Services exposed (through the Felix http bundle?).
>
> I looked at the example from the Apache Felix HTTP Service page (http://felix.apache.org/site/apache-felix-http-service.html)  where the ServiceReference from the HttpService class is used to register a pojo that extends HttpServlet.  Would It be similar for a Jersey POJO?
>
>
> Thanks,
>  Larry
>
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: OSGI Bundles as Web Services

Posted by Sahoo <Sa...@Sun.COM>.
It is not clear if you were able to devleop RESTful web services as OSGi 
bundles in GlassFish V3 or not. [1] says he was able to do so.

Thanks,
Sahoo

[1] http://blogs.sun.com/mohitg/entry/rest_based_hybrid_osgi_javaee

Larry Touve wrote:
> I'm using Jersey to develop some RESTful Web Services.  I'd like to create these as OSGI bundles that I can deploy.  Is there any (relatively easy) way to do this?  I'm currently running Glassfish V3, and am deploying bundles to the underlying Felix, but  I'd like to run just Felix (without GF) and have the Web Services exposed (through the Felix http bundle?).
>
> I looked at the example from the Apache Felix HTTP Service page (http://felix.apache.org/site/apache-felix-http-service.html)  where the ServiceReference from the HttpService class is used to register a pojo that extends HttpServlet.  Would It be similar for a Jersey POJO?
>
>
> Thanks,
>  Larry
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org