• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

reference injection

 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I earlier version of ejb if we want to get reference of another ejb reference then we had to do the look up and get the home object through which he had to get the bean but in new version of ejb do we still have to do the look up or @ejb private some variable will inject the reference?

Thanks in advance
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Example:

@Stateless
@Local({One.class})
class OneBean implements One{
public void doSmth(){...}
}

@Stateless
@Local({Two.class})
class TwoBean implements Two{

@EJB
private One oneBeanInstance;
public void doSmth2(){...}
}

You have to refer to OneBean class through business interface.
Container will inject implementation of that interface after bean creation and before every invocation of business method.
 
expectation is the root of all heartache - shakespeare. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic