• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dependency Injection in EJB

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What does it mean when we say that "server looks up the dependency in the environment naming context"?
How server resolves the dependency?

Thanks
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container find the resource or bean by the J.N.D.I names provided by the developer.
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But a developer can use any name he wishes to.
How does he know that what is the name by which server does a lookup ?

Thanks
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we are talking about looking up a bean by its JNDI name, it should be something in this format:

java:global[/application name]/module name/enterprise bean name[/interface name]

where application name is the name of the .ear, module name is the name of .war or .jar file, where bean name is the name of the bean class and interface name is the interface of the bean if any.

reference:http://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html

For environment entries lookup, you define values of environment entries in the deployment descriptor and the bean can inject the values of environment entries using @Resource.
For more example, please refer to Fritz's notes session 7.8
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic