users@glassfish.java.net

Re: lookup ejb from OSGI ServiceListener

From: <forums_at_java.net>
Date: Thu, 2 Jun 2011 06:18:11 -0500 (CDT)

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