FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
Published byModified over 4 years ago
Presentation on theme: "FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an."— Presentation transcript:
JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. Similar to RPC but is more simpler and written in JAVA language. Can only be used between JAVA programs.
The server must first bind it name to the registry. The client lookup the server name in the registry to establish remote references. The stub (client side) serializing the parameters to skeleton, the skeleton (server side) invoking the remote method and serializing the result back to the stub.
A client invoke a remote method, the call is first forwarded to stub. The stub is responsible for sending the remote call over to the server-side skeleton. The stub opening a socket to the remote server, marshaling the object parameters and forwarding the data stream to the skeleton. A skeleton contains a method that receives the remote calls, unmarshals the parameters, and invokes the actual remote object implementation.
The stub forward request and receives the result. The skeleton responsible to receiving the request and forward the result. Remote Reference Layer (RRL) responsible for carrying out a specific remote reference protocol. Transport Layer responsible for connection set up and reporting object tracking.
Must have: JDK 1.1 or above rmiregistry – remote object registry service rmic – generate stubs and skeletons for remote object(Below JAVA version 5) rmid - RMI activation system daemon serialver - return class serialVersionUID Optional: Textpad
Generally, JAVA RMI consists of: a) RMI Interface b) RMI Server c) RMI Client
1. Define the remote interface. 2. Develop the remote object by implementing the remote interface. 3. Develop the client program. 4. Compile the JAVA source files. 5. Generate the client stubs and server skeleton. 6. Start the RMI regisitry. 7. Start the remote object server. 8. Run the client.
A RMI interface is an interface that declares a set of methods that maybe invoked from a remote JAVA virtual machine. Requirement: Must extended java.rmi.Remote Each method must declare java.rmi.RemoteException
UnicastRemoteObject - classes that remote object implementations can extend which facilitate remote object creation. super() calls the following superclass constructor: a)UnicastRemoteObject() Creates and exports a new UnicastRemoteObject object using an anonymous port. a)exportObject(Remote obj) Exports the remote object to make it available to receive incoming calls using an anonymous port.
The Naming class provides methods for storing and obtaining references to remote objects in a remote object registry: rebind(String name, Remote obj) Rebinds the specified name to a new remote object.
lookup(String name) Returns a reference, a stub, for the remote object associated with the specified name. //host:port/name where host is the host (remote or local) where the registry is located- default is localhost port is the port number on which the registry accepts calls- default is 1099 Client can using remote object method through stub.
After developing the code for RMI interface, RMI server, RMI client. Compile all of them. Next, using command line and go to the directory on when user store all this code. At there, type start rmiregistry Then, run the server code. Run the client code.