my dog learned polymorphism
The moose likes EJB and other Java EE Technologies and the fly likes EJB3 Dependency Injection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB3 Dependency Injection" Watch "EJB3 Dependency Injection" New topic

EJB3 Dependency Injection

Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
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.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: EJB3 Dependency Injection
It's not a secret anymore!