users@glassfish.java.net

Re: OSGI declarative services and _at_Resource issues in 3.1

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Tue, 26 Jul 2011 22:01:27 +0530

Yes, using an OSGi service via @Resource is really discouraged for the
kind of behaviors you have observed. It is unaware of service dynamism.
You are much better of using @Inject @OSGiService as mentioned in that
doc. @OSGiService has an attribute called dynamic which you can set to
true to have the desired dynamic behavior. It also has a timeout
attribute that allows a service that might be of your help.

Sahoo

On Tuesday 26 July 2011 08:07 PM, forums_at_java.net wrote:
> Thanks Sahoo!
>
> In section 4.9, is this WAR to WAB done when you deploy from the Felix
> OSGi
> Console?
>
> I am going to try the WAB conversion but I am still thinking that I
> might run
> into the issue of the WAB starting before the bundle and the @Resource
> will
> break. Also I noticed that once @Resource breaks it will never recover, I
> have to restart the WAR, and for some reason doing it from asadmin
> does not
> fix it, I need to do it from the console, very weird.
>
> I guess if this happens my best bet is to remove the @Resource and use
> the
> declarative service injection in the WAB. Not sure how that will go...
>
> If I were to remove the declarative services and use regular OSGI
> service and
> use the CDI @Inject, is that a dynamic call (aka it will perform
> injection on
> every request to the servlet as opposed to a static one like @Resource
> seems
> to be doing?)
>
> Thanks
>
>
>
>
>
>
>
>
> --
>
> [Message sent by forum member 'el_eduardo']
>
> View Post: http://forums.java.net/node/822383
>
>