On Sep 27, 2009, at 3:25 AM, Vlatko Davidovski wrote:
> Hi!
>
> I am trying to port atmosphere-spade-server (with all required
> dependencies) to OSGi.
> After a lot of problems I had, I finally managed to get a normal
> OSGi bundle containing the required code for the atmosphere-spade-
> server to run.
>
> However, I hit a huge problem in respect to the REST resource class
> loading. Seems that the PackagesResourceConfig class contains OSGi
> unfriendly code (it tries to treat classes as resources, which seems
> not to work on OSGi). Therefore, there is now way I can attach any
> resource classes, no matter the spade server runs.
Yes, PackagesResourceConfig is not appropriate for an OSGi environment.
We might be able to use alternative registration mechanism, for
example see here:
https://jersey.dev.java.net/nonav/documentation/1.1.2-ea/user-guide.html
#d4e115
for registering an Application or ResourceConfig. For example,
https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/core/ClassNamesResourceConfig.html
However, further errors will occur because of META-INF/services files.
> I found out that someone already hit the same problem on Jersey
> level and provided info on http://coderthoughts.blogspot.com/2008/03/using-jersey-jsr311-inside-osgi-with.html
> and this might be of help.
>
Yes.
We are working to modify Jersey jars to support OSGi. The plan is to
use Apache service mix and we will provide separate OSGi-based jars
(because we want to reduce the risks given the release of Java EE 6 in
November that Jersey will be a part of). The problem is we keep get
distracted from this task due to higher priority Glassfish tasks!
> So here are few questions:
>
> 1. I was wondering, would it be possible to do something to remove
> this constraint that stops running the spade server in OSGi.
>
> 2. Is the dev team planning to include some support in providing a
> single OSGi Atmosphere Spade Server bundle that will contain all
> required code to run the server and would have a simple service to
> allow registration of resource classes? I believe this would be of a
> great help for many OSGi developers interested in having Comet
> support on RESTful architecture. On my side, I could provide some
> more feedback, and potentially help in writing the OSGi services.
>
Thanks, Jakub from the Jersey team is responsible for the
OSGi'ification of Jersey. He can provide a better description of the
plan of action than I.
> 3. A final question.. Currently one can set up only a package
> containing the resource classes for the atmosphere spade server. It
> would be quite helpful, if there would be a method in the server
> class allowing something like server.addResource(...) (to add a
> single resource class). Could we have such functionality?
>
I think it would be more appropriate to pass in an a class or instance
of javax.ws.rs.Application.
Paul.