users@glassfish.java.net

Java EE & OSGi [Re: GlassFish and Container]

From: Alexis Moussine-Pouchkine <alexis.moussine-pouchkine_at_oracle.com>
Date: Thu, 11 Nov 2010 12:07:55 +0100

Hi Richard,

That's a good question as I don't believe this is covered in the official documentation.

There are really two ways to "uses" OSGi at the application layer IMO :
1/ Use OSGi declarative services and inject them in you standard Java EE apps using (@Resource).
This works well with the current stable version of GlassFish (3.0, 3.0.1) and is detailed in Jerome's earlier blog:
http://blogs.sun.com/dochez/entry/glassfish_v3_extensions_part_4

2/ Use the OSGi Enterprise Spec implementation to package your Java EE application and resources into OSGi bundles
(allowing for versioning, dependencies, etc.). For that part you'd need to use GlassFish 3.1 and Sahoo's blog is probably the best place to start: http://www.java.net/blogs/ss141213

Of course you don't *have* to use OSGi. Most people just get the benefits of the GlassFish modularity without being exposed to the implementation details. But if you do want to use OSGi, please try it out and provide feedback!

cheers,
-Alexis

On 11 nov. 2010, at 10:51, Richard Kolb wrote:

> Hi Alexis
>
> On 10 November 2010 23:43, Alexis Moussine-Pouchkine <alexis.moussine-pouchkine_at_oracle.com> wrote:
>
> On 10 nov. 2010, at 20:26, forums_at_java.net wrote:
> > 3. How does glassfish know which container, services ... it must active
> > / start?
>
> It's smart! :)
> It depends on the artifacts you deploy. A WAR file will require the web container for instance, for JARs it decides based on deployment descriptors whether it's an EJB, a library or an ACC archive. Sniffers are responsible for this logic.
> There is also the special case of OSGi bundles that can be deployed using "asadmin deploy --type osgi" to explicitly target the OSGi runtime.
> In any case, GlassFish is auto-adaptative and there is no need to cut a "profile" upfront with a specific set of features.
>
> GlassFish is so cool :)
>
> Is there any good document / tutorials on using OSGi for my Java-EE applications in GlassFish ?
>
> thanks
> Richard.
>