*
The moose likes EJB and other Java EE Technologies and the fly likes OSGI+EJB or the real profit of @Inject @OSGiService (JavaEE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "OSGI+EJB or the real profit of @Inject @OSGiService (JavaEE)" Watch "OSGI+EJB or the real profit of @Inject @OSGiService (JavaEE)" New topic
Forums: Glassfish EJB and other Java EE Technologies
Author

OSGI+EJB or the real profit of @Inject @OSGiService (JavaEE)

Pasha Turok
Greenhorn

Joined: Jun 09, 2014
Posts: 5
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
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

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?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pasha Turok
Greenhorn

Joined: Jun 09, 2014
Posts: 5
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.
 
 
subject: OSGI+EJB or the real profit of @Inject @OSGiService (JavaEE)