What I understand - please correct me if I'm wrong.
There are two great technologies OSGI and CDI. I use glassfish 4 and when I started to use it I hoped that such great server will provide all I think. Now I need the use of both technologies and I'm a little bit shocked. As I see CDI with osgi works only with servlet and EJB. It means you can inject in servlet, but you can't inject in pojo. So what I have in practise:
Bundle1 - servlet - frontcontroller + jsp
Bundle2 - service providing controllers and commands and models
Bundle3 - EJB.
I can inject EJB to servlet - that's ok. I can inject service to servlet. But I can't do the most necessary thing - I can't inject EJB to my controllers/commans etc. Can anyone explain where is my misunderstanding?
Rob Spoor wrote:How do you create your controllers / commands / other POJOs? I assume you know that CDI won't work if you create instances directly using new?
You got the point! This is what I am talking about. Yes, I know that if I create via operator new than CDI framework can't hook object (controllers/commands etc). I know that. The problem is that I can't create these objects 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: 1) I do something wrong 2) it's not supported by weld\fighterfish. If someone sees my mistake in my thoughts please correct me.