• 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

how does dependency injection managed in application container?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I just dependency injection such as Spring or Google guice, I always have to define a context which contains all the classes that will be initialized by DI framework, and also defines all the dependencies will be injected into those classes. Such as
<bean id="someClass" class="..">
<property name="someProp" ref="someOtherBean"/>
</bean>

What I think in this case is that the DI framework initialize the class and call set method to add dependencies.

But in application container, I don't have to define those kind of context, how could container know which classes can be injected?
Or application container can only inject certain classes based on anotation, such as:
@PersistenceUnit(unitName="..")
private EntityManagerFactory emf;

If I want to be able to inject my own classes, I still have to use some other framework?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct. For JEE 5 you are injecting standard resources from the JNDI.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic