users@glassfish.java.net

Re: Accessing OSGi Context / Bundles from a standard WAR/EAR/etc in GF v3.0

From: <glassfish_at_javadesktop.org>
Date: Wed, 28 Apr 2010 01:47:51 PDT

> Here is a sample that shows how to invoke a OSGi
> service from a JAX-WS
> endpoint:
>
> http://blogs.sun.com/arungupta/entry/totd_130_invoking
> _a_osgi
>
> This is deployed in v3.0.
>
> HTH,
> -Arun

Hello,

thank you for your answer!

In your tutorial you are deploying your war as a web application bundle (so it is a real bundle in terms of a OSGi), because of that you can use all OSGi services... My application uses JSF with custom components, so it does not work in 30 as a WAB, it requires changes available in 3.1 branch. (There is a thread in this forum about this issue...) I have been using nightly build of 3.1 where everything were working correctly.

The release plan of the 3.1 is not yet available (in wiki) and in a real development we cannot rely on a nightly builds for a long time, so I was thinking about some temporary work around, which makes it possible to access OSGi services from a normal WAR, which is deployed as a normal WAR.

 BundleContext ctx = BundleReference.class.cast(
           App.class.getClassLoader()).getBundle().getBundleContext();

Maybe if I use instead of App class some system bundle activator class that is already available in GlassFish, then I can get a bundle context of some module bundle and use it? I understand that this is really weird hack..... but anyway it can be used as a temporary work around..


Thanks,
Michael
[Message sent by forum member 'smikesh']

http://forums.java.net/jive/thread.jspa?messageID=399341