• 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

An EJB should behave as local and remote as well

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want my EJB to behave as remote and local as well. If my EJB is being called from client ( say servlet ) then there sbould be a remote call. If my EJB is being called from any other EJB then it should be a local call.

Using local interfaces we can do. But my EJB should be remote and local as well.

for this i have an aproach. I dont know how far it is correct and reliable.

the aproach is as follows :

I will declare my EJB in the ejb-jar.xml for remote block and also for local block. but with different ejb names. I use remote ejb name to lookup from the servlet. and i use local ejb name to lookup from another EJB.
Will this be a good approach. Or there are any other alternatives to acheive this type of issue.

Thanks with Regards
Venkat
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
What you are saying is correct, Your EJB will have 4 interfaces 2 Component interfaces & 2 local interfaces. As well as you have to write entries in ejb-jar.xml


Regards
Shrinivas
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I will declare my EJB in the ejb-jar.xml for remote block and also for local block. but with different ejb names. I use remote ejb name to lookup from the servlet. and i use local ejb name to lookup from another EJB.
Will this be a good approach. Or there are any other alternatives to acheive this type of issue.


If you have defined local interfaces for an EJB and is called from another EJB in the same container then you will always get the local instance. You don't need to name local and remote differently.
 
padma warlu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what if the same EJB is being called from the client ie servlet or jsp which is in the different container ?
reply
    Bookmark Topic Watch Topic
  • New Topic