• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Resource Injection.

 
Greenhorn
Posts: 4
Java ME Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
concider following entity manager factory injection.
<enterprise-beans>
<session>
<ejb-class>com.ex.A</ejb-class>
<ejb-name>BeanName</ejb-name>
<persistence-unit-ref>
<persistence-unit-ref-name>jndiname</persistence-unit-ref-name>
<injection-target>
<injection-target-class>com.ex.A</injection-target-class>
<injection-target-name>fieldName</injection-target-name>
</injection-target>
</persistence-unit-ref>

</session>
</enterprise-beans>
We have specified the <ejb-class> so why do we need to have a <injection-target-class> ?
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
Mihai

 
sasinda Rukshan
Greenhorn
Posts: 4
Java ME Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic