• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 Dependency Injection

 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Spring it's easy to understand, I configure the remote object putting the ip and the name for look-up, and Spring do the injection for me.
But with EJB3, I just use @EJB annotation in a field and the EJB is injected. So the question is, how it work's? And, can I configure a different server for EJB look-up.


thank's.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can.

Basically the Annotations have "smart" defaults, so in that basic case the object reference type in your code tells the App Server which bean to inject. If there are differences betweent the reference type, or if it has to look it up in a remote app server, then you will include attributes to the @EJB to tell it where to find it. It is called only configuring to the exception. So you only have to put more stuff in there if you have to be different than the smart defaults.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic