Reputation:
There are two great technologies OSGI and CDI and I'm newbie in both of them. I use glassfish 4 and when I started to use it I hoped that such great server would provide all I'd learned. Now I need to use both technologies. So what I have in practice:
Bundle1 - servlet as frontcontroller + jsp
Bundle2 - service providing controllers, commands,[models]
Bundle3 - EJB.
I can inject EJB to servlet - that's ok. I can inject service to servlet - that's ok. But I can't do the most necessary thing - I can't inject EJB to my controllers/commands/models etc - here I have to do manual lookup of EJB, but I want to use CDI!
My thoughts: The problem is that I can't create these objects from bundle2 without new!!! Because entry point in osgi bundle is osgi service. Other bundles work with this bundle via its service. So, I must inject my objects to service - however this doesn't work. Here are two possible reasons:
If someone sees my mistake in my thoughts please correct me. So the question - can I inject EJB in controllers/commands, provided by service of bundle 2 or it's impossible?
Upvotes: 2
Views: 664
Reputation: 19606
Just use stateless session beans for the services in bundle 2. So you can easily inject the EJB.
Upvotes: 1