This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Resource Injection. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Resource Injection." Watch "Resource Injection." New topic

Resource Injection.

sasinda Rukshan

Joined: Apr 01, 2011
Posts: 4

concider following entity manager factory injection.

We have specified the <ejb-class> so why do we need to have a <injection-target-class> ?

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Sasinda

The ejb-class represents the bean corresponding class for the a given environment and the injection-* represents the injection applying point.
More precisely, the ejb-class is used to declare entries in the bean context, all the bean instances from this type may use this entries (via JNDI calls) - please notice the "may use it"; there is no must this is just a declaration.
The injection-target-class is used to specify the injection application point - it means inject this instance in this field.

Even if both elements (ejb-class and injection-target-class) have the same meaning they are used in different contexts.

If you dislike to see the "class" in two places you can remove the <ejb-class> element and use <remote> or <local> with the implemented interface.


sasinda Rukshan

Joined: Apr 01, 2011
Posts: 4

Consider Paul's rocket mass heater.
subject: Resource Injection.