users@glassfish.java.net

Re: OSGi EJB injection requires full JNDI path lookup

From: <forums_at_java.net>
Date: Thu, 2 May 2013 01:30:32 -0500 (CDT)

Seems like there is a misunderstanding of how OSGi/JavaEE integration works.
There are two parts to consider: a) You enable automatic publication of your
local EJBs as OSGi services. You do this by converting your EJB jar to an
OSGi bundle and adding a "Export-EJB: ALL" header in its manifest. Once the
EJBs are published as services, they can be consumed from both Java EE or
non-JavaEE modules like regular OSGi services. We make it easier to consume
OSGi service from EE components easier via OSGi/CDI which is where the second
point comes into play. b) Consuming an OSGi Service from a Java EE component
like Servlet or another EJB. You do this by converting your client Java EE
module to an OSGi bundle that uses OSGi/CDI feature of GlassFish. You need to
have an empty beans.xml and add @OSGiService at your injection point like
this: // no need to use @EJB. At this point you don't even know whether it is
an EJB or not. @Inject @OSGiService MyEJB ejb; Take a look at our sample [1]
that demonstrates all these aspects. You can just checkout, build and try it
yourself. Refer to "Appendix C - Samples" of our guide [2] to learn more
about what each sample demonstrates. Thanks for asking these questions.
Please feel free to ask us after going through the referenced materials. [1]
https://svn.java.net/svn/glassfish~svn/trunk/fighterfish/sample/uas [2]
http://glassfish.java.net/public/GF-OSGi-Features.pdf

--
[Message sent by forum member 'ss141213']
View Post: http://forums.java.net/node/896631