• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how does dependency injection managed in application container?

 
jianming chen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct. For JEE 5 you are injecting standard resources from the JNDI.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic