• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 42003
911
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.
 
Pay attention! Tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic