• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dependency injection using Deployment descriptors

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How dependency injection is done using DD file.I have seen the tag <injection-target> in an article. But haven't find that in specs. is this the only tag available. where can i find the information about injection tags
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this book! Chapter, section: 14.2!
http://www.oreilly.com/catalog/entjbeans5/
 
Andor Nemeth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Senthil Kumar SS:
How dependency injection is done using DD file.I have seen the tag <injection-target> in an article. But haven't find that in specs. is this the only tag available. where can i find the information about injection tags



The <injection-target> element is used if you want to inject an EntityManagerFactory into an EJB's bean class.

<persistence-unit-ref> <persistence-unit-ref-name>persistence/YourDB</persistence-unit-ref-name>
<persistence-unit-name>YourDB</persistence-unit-name>
<injection-target> <injection-target-class>org.andir.YourBean</
injection-target-class>
<injection-target-name>yourField</injection-target-name>
</injection-target>
</persistence-unit-ref>

The EntityManager is injected into the field named yourField or passed as a parameter to a setter method named setYourField( ) in YourBean class.

(I've modified the example a bit, because i didn't wanted to quote totally the book!)
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's also in EJB3 in Action, in Appendix D. But there's no example. It's not only for EntityManagerFactory. It's used to inject anything like a resource, an EJB, an entity manager...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll find an example in the core spec, to inject environment entries :
16.4.1.3 Declaration of Simple Environment Entries in the Deployment Descriptor
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic