users@glassfish.java.net

Re: lookup ejb from OSGI ServiceListener

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Thu, 02 Jun 2011 17:13:44 +0530

I don't understand your use case. Please provide sample code which shows
all relevant parts.


On Thursday 02 June 2011 04:48 PM, forums_at_java.net wrote:
> Hi Sahoo,
>
> Thanks for your answer.
>
> [quote=Sahoo]
>
> Depending on when the ServiceEvent is raised, the looked up EJB
> reference may
> or may not be in a valid reference. If the EJB has been undeployed, which
> happens on Bundle.STOPPING state, then the reference becomes invalid.
> What's
> wrong if you look up every time you need the EJB?
>
> [/quote]
>
> I inject ServiceListener in Singleton Startup EJB. I do it to use @Inject
> annotation and avoid lookups (in the above sample I used lookups as a
> workaround). That means, ServiceListener is created while a bundle loads,
> and I get the exception when event is raised (after bundle was loaded).
>
> [quote=Sahoo]
>
> Have you looked at GlassFish's support for EJB as OSGi service? It
> automatically makes available stateless EJBs with local business
> interfaces
> as OSGi services.
>
> [/quote]
>
> In my case EJB and ServiceListener are located in the same bundle. If
> I export EJB as OSGI service, it becomes available only *after *a bundle
> is loaded, and I need it before.
>
> Is there a more convenient way to access EJB from ServiceListener with
> Inject/OSGIService annotation?
>
> thanks
>
>
> --
>
> [Message sent by forum member 'okna2000']
>
> View Post: http://forums.java.net/node/808455
>
>