0% found this document useful (0 votes)
64 views

Remote Method Invocation

Remote Method Invocation (RMI) allows methods to be invoked on objects residing in different Java Virtual Machines (JVMs), whether on the same or different machines. RMI uses stubs and skeletons as proxies - the stub acts as a local proxy for the remote object on the client side, while the skeleton receives method invocations from the stub and passes them to the object on the server side. The client, server, and an object registry are the three main entities involved, with the registry associating remote objects with names to allow clients to look them up.

Uploaded by

rgayathiridevi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Remote Method Invocation

Remote Method Invocation (RMI) allows methods to be invoked on objects residing in different Java Virtual Machines (JVMs), whether on the same or different machines. RMI uses stubs and skeletons as proxies - the stub acts as a local proxy for the remote object on the client side, while the skeleton receives method invocations from the stub and passes them to the object on the server side. The client, server, and an object registry are the three main entities involved, with the registry associating remote objects with names to allow clients to look them up.

Uploaded by

rgayathiridevi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

REMOTE METHOD INVOCATION

Java RMI
• Allows a method to be invoked that resides on
a different JVM:
– remote machine
– same machine, different JVM (different
address space)
• Object-oriented RPC
• Java RMI is a mechanism to allow the
invocation of methods that reside on different
• Java Virtual Machines (JVMs). The JVMs may
be on different machines or they could be on
the same machine. In either case, the method
runs in a different address space than the
calling process.
RMI ARCHITECTURE
DISTRIBUTED OBJECT
STUB & SKELETON
• Stubs and Skeletons. Stub is the local code
that serves as a
• proxy for a remote object. The skeleton is
another proxy that
• lives on the same host as the real object. The
skeleton
• receives remote method invocations from the
stub and passes
• them on to the object.
CORBA Vs RMI
• CORBA is language/machine independent
• - RMI was designed for Java running on a JVM
• CORBA includes more mechanisms:
server application starting
managing persistent state
support for transactions
• -Java RMI does not have an Object Broker
Participating processes
• Client
– process that is invoking a method on a remote object
• Server
– process that owns the remote object (local object to
the server)
• Object Registry
– name server that associates objects with names
– objects are registered
– URL namespace
Three entities involved in running a
program that uses RMI:
• client: this is the program that you write to access remote
methods
• server: this is the program that you write to implement
the remote methods – clients connect to the server and
request that a method be executed. The remote methods
to the client are local methods to the server.
• Object registry: this is a program that you use.
The object registry runs on a known port (1099 by default)
A server, upon starting, registers its objects with a textual
name with the object registry.
A client, before performing invoking a remote method,
must first contact the
object registry to obtain access to the remote object.
Two kinds of classes
• Remote class (remote object)
– instances can be used remotely
– works like any other object locally
– in other address spaces, object is referenced

with an object handle


– if a remote object is passed as a parameter.
• class (serializable object)
• – instances can be copied between address
Spaces
• – can be passed as a parameter or be a
return value to a remote object
• value of object is copied
• – implements java.io.Serializable interface
Remote classes
• Remote class has two parts:
– interface definition
– class definition
• Remote interface
– must be public
– must extend java.rmi.Remote
– every method must declare that it throw
java.rmi.RemoteException
• Remote class
– implements Remote interface
– extends
java.rmi.server.UnicastRemoteObject
Remote interface
• The interface definition:
- must be public
- must extend the interface java.rmi.Remote
- every method in the interface must declare
that it thows
The Remote class:
• The Remote class:
- must implement a Remote interface
- should extend
EXECUTION OF RMI
• Start the rmiregistry
• Compile the server
• Start the server
• Start the client

You might also like