1 / 13

RMI

RMI. RMI is the java API that facilitate distributed computing by allowing remote method calls. A remote method call represents a method invocation between different JVM . Remote Object or RMI server . RMI Client. Remote Method Call .

gotzon
Télécharger la présentation

RMI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RMI RMI is the java API that facilitate distributed computing by allowing remote method calls. A remote method call represents a method invocation between different JVM . Remote Object or RMI server RMI Client Remote Method Call

  2. RMI provides basic infrastructure required for distributed computing. • Commonly used terms or terminology of RMI . • 1) Remote object / RMI server :- A remote object /RMI server is a distributed object that exposes remote method which can be invoke on the remote object in a distributed manner from different JVM. • 2) RMI client: is an object that invokes a remote method using RMI.

  3. Web Server 1.0 registered Domain name Server Web Application Domain Name IP Address ISP 1.1 domains name are provided Client

  4. 3) Stub :- A stub represents a proxy of remote object that hides the internal details of remote method invocation from the RMI client . • 4) Skeleton:- A skeleton is the proxy of RMI client that hides the internal details of RMI from the remote object . • In order to invoke remote method using RMI following sequence of operation are required.

  5. Remote Object Directory Server 1.0 Name Stub JVM 1.1 2.5 1.2 2.4 2.0 Stub Skeleton 2.3 2.1 Stub Proxy for client RMI Client 2.6 2.2 2.7 JVM Proxy for server

  6. 1.0 Remote object is created • 1.1 Stub & skeleton for the remote object is created. • 1.2 Remote stub is registered with a logical name in directory server • 2.0 search remote stub . • 2.1 Remote stub is obtained • 2.2 invokes remote method • 2.3 establises connection with its skeleton & marshals method call to the skeleton • 2.4 unmarshalls method call and invokes method on actual object

  7. 2.5 method completes and result is returned to skeleton • 2.6 skeleton marshals result of method call to the stub . • 2.7 stub unmarshals result and provide it to client. • STEPS TO CREATE RMI BASED APPLICATION:- • 1) Define a remote interface , each remote object exposes remote interface to its clients .this interface extends java.rmi.remote interface and provides remote method. Each remote method in the remote interface through java java.rmi.RemoteException.

  8. 2) Define a class that implements remote interface & provides Exporting logic .java.rmi.server.UnicastRemoteObject class provides exporting logic logic(Statements to create stub & skeleton for a remote object ) • This class must be extended by the implementation class. • 3) compile implementation class & generate its stub & skeleton class. • rmic:(rmi compiler ) tools provided with jdk is used to generate stub & skeleton class for a rmi object. • Syntax: rmicclassName of RemoteObject • Ex . RmicMyadder • MyAdder_Stub.class & MyAdder_skeleton.class

  9. 4) start a directory service to facilitate registration & lookup of remote stub . • An implementation of directory service is provided with jdk that provides the facility of registration & lookup of remote stub. • syntax to start rmiregistry: 1) on default port(1099) • Rmiregistry • 2) on a specific port :- rmiregistry port number • 5) Create remote object and register its stub with the directory server. Enter Enter

  10. Java.rmi.Naming : class provides static method to register or lookup a remote object with RMI registry. • bind():- register a remote stub with the given name in the RMI registry . • Public static void bind(String name, Remote Object)throws RemoteException, AlreadyBindException . • rebind(): public static void rebind(String name,remote object)throws RemoteException ; • Lookup():- is used for search remote stub. • Public static Remote lookup(String lookup String)throws RemoteException; • Formateof lookup String:- protocal/host Address/port/registered name • Note: protocal/host address is optional if rmiregistry is running on default port on localhost.

  11. 5) Define a class to represent client: in client class obtain the reference of remote stub from the directory server and invoke remote method on it. • If rmi registry is running on a different port then default method of registering remote stub is changed.i.e at the time of registration address of the host as well as port number of the rmi registry is used. • For this purpose registry & LocateRegistryClass provided in java.rmi.registry package.

  12. LocateRegistry class is a factory that provides method to obtain registry object. A registry object is used to bound ,unbound or lookup a stub in the rmi registry. • You can see easily using • >javapjava.rmi.registry.LocateRegistry >a.txt. • > a.txt • getRegistry() method of LocateRegistry class is used to create a registry object. • 1)Public static registry getRegistry(String hostName) remote exception. • 2) Public static Registry getRegistry(int port)throws remote exception.

  13. Public static registry getRegistry(String host name,int port)throws remote exception; • A registry class provides bind & rebind method to register an object to the directory server.

More Related