Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The only time a lookup is needed

 
Himai Minh
Ranch Hand
Posts: 1313
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Frits' notes, p.63,

7.1 @EJB - injecting an EJB
The only time a lookup is needed is when the @EJB and @Resource is declared on the bean class.


I believe a lookup is also needed when an EJB is injected, like this example on p.66:

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2418
95
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I meant by that remark is that the lookup is not needed in line number 9.

The following code would be sufficient:

Although the code above doesn't look like it has a lookup of the EJB it certainly does a lookup because "Each injection of an object corresponds to a JNDI lookup" (page 63)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic