Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dependency Injection VS JNDI  RSS feed

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
Does server uses JNDI under the hood to perform a dependency injection of EJBs ?
Please reply.

Thanks,
Sudhanshu
 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Dependency injection is to ease developer's task of performing doing JNDI lookup.
With dependency injection, developers won't need to instantiate and initialize objects.
The container will do the instantiation and initialization of the objects for developers.


Reference:
http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3
http://www.onjava.com/pub/a/onjava/2006/01/04/dependency-injection-java-ee-5.html?page=5
 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"@EJB annotation was added to the specification... the container uses the DI pattern to wire up beans. Although J.N.D.I is still used in the background, those details are hidden from the developer by the @annotation."
Quote from EJB in Action, p 121.
It is true that dependency injection uses j.n.d.I behind the scene.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!