wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes An EJB should behave as local and remote as well Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "An EJB should behave as local and remote as well" Watch "An EJB should behave as local and remote as well" New topic
Author

An EJB should behave as local and remote as well

padma warlu
Greenhorn

Joined: Aug 17, 2005
Posts: 8
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
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
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
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
padma warlu
Greenhorn

Joined: Aug 17, 2005
Posts: 8
But what if the same EJB is being called from the client ie servlet or jsp which is in the different container ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An EJB should behave as local and remote as well