File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Difference between Remote & Local Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Difference between Remote & Local" Watch "Difference between Remote & Local" New topic
Author

Difference between Remote & Local

Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
Hello

I am reading book on EJB but I am not getting the difference between Remote Interface & Local Interface. Both Interfaces are used for Stateless & Statefull Session Beans. so on which condition it is determined which one to use.

suppose there is Server S on which EJB Container & my project resides. client A , B & C access S . so in my application which interface would be use local or Remote ?



SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
Cool down, its just begining....

You are discussing 4 things.....

Stateful - is used if you want to have multiple operations & specific to single client
(One stateful instance for a client)

Stateless - container create a pool of instances & forward it when a client request comes, does not matter who is the client
(One instance can serve multiple clients)

Local interface - used if EJB will be accessed locally (same env)
(so you can have local interface for stateful as well as for stateless)

Remote interface - if your ejb will be used remotely (in different env)
(& you can have remote interface for stateful as well as for stateless)


if your SessionBeans (SB) are accessed remotely by another SB, servlet or any other component then use Remote interface.
But if for example client is accessing servlet at remote address and that servlet is using SB (in servlet's env) then you can use Local interface for SB.

It all depends on design.....

Sugon Yu
Greenhorn

Joined: May 28, 2009
Posts: 5
If clients and EJB reside in the same JVM, use local interface. eg. clients from servlet, jsp, jsf, ejb components in the same Java EE 5 container.

If clients and EJB does not reside in the same JVM, use remote interface. eg. clients from Application Client Container.
Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
Thank you Sugon & Deepika ..

yes its a beginning .

Still in little confusion . if client access some session bean on web application server then we use Local Interface and that session bean access some other session bean on different physical server then we should use Remote Interface .

am I correct ?

In one physical machine can we have 2 different JVM's ?

" clients and EJB resides in same JVM " please clarify the statement.
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
if client access some session bean on web application server

- web server is used to deploy web component (e.g. servlet, jsp,...)
- application server is used for enterprise application components & design to have EJB Container/server, web server, messaging,....
web application server can not deploy EJB. But an application server can deploy web application & EJB.
I hope you meant application server and not web application server.
that session bean access some other session bean on different physical server then we should use Remote Interface .

that other session bean should use (implement) remote interface, you are correct.
In one physical machine can we have 2 different JVM's

Open 3 command prompt & run same or three different Java programme at same time, you are already using 3 JVM on same machine.
" clients and EJB resides in same JVM " please clarify the statement

A client is who is asking for a service and a server (here server is server object and not application or web server) is who is asked for the service.
or
A client could be an application or object (a reference) who is requesting a service (called operation or method call) to a server object (EJB, other java object)
or
a client is an object which invoke / call the method and server (object) is whose method is called. Server object could be any Java object (an EJB is also a Java Object)
clients(servlet, another EJB, .....) and EJB (you want to call method of this EJB) resides in same JVM
Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
okey.. now get it . Thanks a lot Deepika.

now It will be more fun in learning EJB .

Thanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Remote & Local