160 likes | 337 Views
JAVA REMOTE METHOD INVOCATION (RMI). FONG CHAN SING (143334) WONG YEW JOON (143388). What is JAVA RMI?. JAVA RMI is a distributive system programming interface introduced in JDK 1.1 .
E N D
JAVA REMOTE METHOD INVOCATION (RMI) FONG CHAN SING (143334) WONG YEW JOON (143388)
What is JAVA RMI? • 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.
JAVA RMI CONCEPT • 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.
JAVA RMI ARCHITECTURE • The stubforward 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.
TOOLS NEEDED FOR JAVA RMI • 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
COMPONENT OF JAVA RMI • Generally, JAVA RMI consists of: • RMI Interface • RMI Server • RMI Client How it JAVA RMI works?
STEPS FOR DEVELOPING JAVA RMI SYSTEM • Define the remote interface. • Develop the remote object by implementing the remote interface. • Develop the client program. • Compile the JAVA source files. • Generate the client stubs and server skeleton. • Start the RMI regisitry. • Start the remote object server. • Run the client.
RMI INTERFACE • 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
RMI SERVER • UnicastRemoteObject - classes that remote object implementations can extend which facilitate remote object creation. • super() calls the following superclass constructor: • UnicastRemoteObject() Creates and exports a new UnicastRemoteObject object using an anonymous port. • exportObject(Remoteobj) Exports the remote object to make it available to receive incoming calls using an anonymous port.
RMI SERVER • The Naming class provides methods for storing and obtaining references to remote objects in a remote object registry: rebind(String name, Remoteobj) • Rebinds the specified name to a new remote object.
RMI CLIENT • 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.