• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Pasha Turok
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic