wood burning stoves 2.0*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes how does dependency injection managed in application container? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "how does dependency injection managed in application container?" Watch "how does dependency injection managed in application container?" New topic
Author

how does dependency injection managed in application container?

jianming chen
Ranch Hand

Joined: Jul 21, 2009
Posts: 33
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Correct. For JEE 5 you are injecting standard resources from the JNDI.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: how does dependency injection managed in application container?