• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Persistence EntityManager injection from ejb-jar.xml

 
Marshal
Posts: 6780
1297
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can use the following syntax in EJB 3.0 to inject EntityManager



How can we do the above injection, by using the deployment descriptor?
(Please feel kind to specify all mandotary and optional elements (tags) and sub-elements)
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

For injection to happen in EBJ3, you need to have annotations within your code. You won't be able to "inject" them through deployment descriptors. However, you will be able to bind objects to the ENC of the application through deployment descriptors (this has been there in earlier versions too). Later you can do a lookup in the JNDI for these objects.
 
Ranch Hand
Posts: 342
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

in xml the injection looks like With exception of <persistence-context-ref-name> all elements are optional. The admissible values for <persistence-context-type> are "Container" and "Extended". The <injection-target> tag is responsible for the actual injection into the instance variable em.
[ November 02, 2008: Message edited by: Ralph Jaus ]
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ralph,

Thanks for posting I wasn't aware of this.
 
Devaka Cooray
Marshal
Posts: 6780
1297
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ralph Jaus
 
Devaka Cooray
Marshal
Posts: 6780
1297
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ralph Jaus:
Hi,

in xml the injection looks like



I have another question, why we use <injection-target-class> element? Is it should always same as to the <ejb-class> element under the given <session> element?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it should always same as to the <ejb-class> element under the given <session> element?

dependency injection could also be used in superclasses of the bean class. I didn't check it, but I suppose that the <injection-target-class> serves this purpose and can contain the name of a superclass. Perhaps you can test it and let us know.
 
reply
    Bookmark Topic Watch Topic
  • New Topic