users@glassfish.java.net

Re: Java EE & OSGi [Re: GlassFish and Container]

From: Sanjeeb Sahoo <sahoo_at_sun.com>
Date: Thu, 11 Nov 2010 19:15:38 +0530

I discourage use of @Resource to inject OSGi service. It does not offer
the kind of support needed to inject dynamic OSGi service. I recommend
using a glassfish specific CDI qualifier annotation called
org.glassfish.osgicdi.OSGiService in conjunction with @Inject to get a
reference to OSGi service in your app. This support is now part of
3.1-b28 by default. I am going to add a sample of this very soon in our
samples page. If you get there before I have added, I can send you a
ready made app that I have.

We are trying to consolidate OSGi related information in GlassFish at
http://wikis.sun.com/display/GlassFish/Osgi . Please check out the blogs
and samples link there as well as the presentation section to get a
rough idea of what GlassFish currently offers and is trying to offer.

If you want to get started with Java EE & OSGi together, then the best
resource that I can point to is a 6-parts/2 hours hands-on-lab turned
into a youtube video presentation that Arun and I did. Please find it here:

http://blogs.sun.com/arungupta/entry/screencast_32_osgi_enabled_java

Thanks,
Sahoo

On Thursday 11 November 2010 04:37 PM, Alexis Moussine-Pouchkine wrote:
> 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.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>