users@jsr311.java.net

Re: ApplicationConfig and OSGi

From: Reto Bachmann-Gmür <reto_at_gmuer.ch>
Date: Thu, 24 Jul 2008 16:26:34 +0200

Paul Sandoz wrote:
> Hi Reto,
>
> Reto Bachmann-Gmür wrote:
>> Hello
>>
>> Trying to use jax-rs in an OSGi environment we imagine bundles
>> providing web applications by exposing instances of
>> ApplicationConfig. However the jsr311 implementation residing in
>> another bundle cannot instantiate the classes of the bundle providing
>> the application.
>>
>
> I know very little about the technical aspects of OSGi but would not
> the same problem occur for a web application bundle referring to a
> servlet class in the web.xml that needs to be instantiated by servlet
> implementation residing in a different bundle?
you're right the problem would be the same, the OSGi approach would not
be to load classes according to a web.xml but having bundles registering
their servlets to the OSGi registry or to a service. We don't care about
servlets, but would like OSGi bundles to be able to register jsr-311
applications and have another bundle (or bundles) rendering this
accessible over the web.

OSGi and afaict JSR277 do not allow a bundle to create instances of
classes for which they do not import the respective packages.

>
> And also for Web service endpoints, EJBs and JAXB beans when
> unmarshalling.
could be.
>> Could ApplicationConfig be fixed to return factories instead of
>> instances of Class?

To allow the jsr311 implementation to create instances of classes
provided by other bundles and access the annotations in the class
without creating unnecessary instances the factories returned by
Application should provide a method to return an instance as well as one
to return the Class.

reto