users@jersey.java.net

Re: [Jersey] iPojo + Jersey

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 26 Aug 2010 10:50:55 +0200

Hi David,

As an aside there is OSGi support in Jersey, some brief documentation
here (which needs to be expanded a bit):

   https://jersey.dev.java.net/nonav/documentation/1.4-SNAPSHOT/user-guide.html
#osgi

But if i understand correctly what you want to do is plug in an IoC
framework, iPOJO, into Jersey correct?

I do not know of any pre-existing work using iPOJO, and this is the
first time i have heard of iPOJO, so it is tricky for me to guide you
with specifics of your case.

We do not have strong documentation around this area, so the best
place to look is code and JavaDoc of the components and existing code.

I think the best thing to do in this respect is look at the Guice
integration code:

   https://fisheye4.atlassian.com/browse/jersey

   http://download.java.net/maven/2/com/sun/jersey/contribs/jersey-guice/1.4-SNAPSHOT/jersey-guice-1.4-SNAPSHOT-sources.jar

   https://jersey.dev.java.net/nonav/apidocs/latest/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html

Specifically look at the GuiceComponentProviderFactory:

https://fisheye4.atlassian.com/browse/jersey/trunk/jersey/contribs/jersey-guice/src/main/java/com/sun/jersey/guice/spi/container/GuiceComponentProviderFactory.java?r=HEAD

Notice that it implements IoCComponentProviderFactory which is
responsible for returning IoCComponentProvider instances based on the
class (returning null means it cannot support the class as a
component). There are a few extensions of IoCComponentProvider that
signal to Jersey the type of life-cycle and injection control.

For example, with the Guice integration it supports three types of
control:

   1) Guice instantiated and Jersey managed with
GuiceInstantiatedComponentProvider implementing
IoCInstantiatedComponentProvider;

   2) Jersey instantiated, Jersey managed and Guice injected with
GuiceInjectedComponentProvider implementing
IoCProxiedComponentProvider; and

   3) Guice instantiated, Guice managed and Jersey injected with
GuiceManagedComponentProvider implementing IoCManagedComponentProvider.

I don't know enough about iPOJO to say if an of the above fits your
requirements.

Hth,
Paul.

On Aug 25, 2010, at 8:59 PM, David Allen wrote:

> Hello -
>
> I'm developing an app in OSGI using iPojo for injection and
> lifecycle management. Now I want to add a REST API bundle and Jersey
> is just the ticket... however it seems after much trial and error
> that I need to do some work with "ComponentProvider"s to get to my
> dependencies provided in other bundles.
>
> First off... has anyone done this yet?!
>
> Secondly, is this the right direction?
>
> Third, is there some solid docs or examples for creating a
> ComponentProvider based on another framework? I'm no Jersey Guru,
> Spring or Guice expert, so looking at the code for these modules is
> elusive at best.
>
> Any guidance would be appreciated.
>
> David Allen
> CSO & Co-Founder
> veloGraf Systems
> dave_at_velograf.com