• 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

Polymorphism & DI

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


Client Layer



Doubt
Since I am using interface in client layer; how would I archive the following;



I would appreciate your help.

Regards,
Sanjeev.
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you have to deploy the two beans (with a different jndi name), then add two @EJB injections which points to the two different names.
But if the choice between the two ejbs is decided at deployment time, you can play with xml stuff...
 
sanjeev mehra
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agrees to deploy 2 beans,
And client side needs 2 DI (which means injection of two EJB objects at client side)

But if I use lookup (initCtx.lookup) based on condition; then only one EJB would be injected (client would be bound / have only one EJB) and can avoid second EJB, which is not needed.

Am I correct?


Thanks.
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you have no EJB injected at all.
In fact, you simply access your ejb using jndi instead of using injection.
 
sanjeev mehra
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I meant using DI client would have 2 object

Using lookup client would have only 1 object, since lookup can be kept under condition.

what I am trying to understand is that lookup process has advantage in this case compare to DI.

Am I correct?
reply
    Bookmark Topic Watch Topic
  • New Topic