JAVA RMI Introduction Design Implementation Testing

Authors Avatar

JAVA RMI

  • Introduction
  • Design
  • Implementation
  • Testing

INTRODUCTION:

Remote method invocation allows applications to call object methods located remotely, sharing resources and processing load across systems. Unlike other systems for remote execution which require that only simple data types or defined structures be passed to and from methods, RMI allows any Java object type to be used - even if the client or server has never encountered it before. RMI allows both client and server to dynamically load new object types as required.

Remote Method Invocation (RMI) facilitates object function calls between Java Virtual Machines (JVMs). JVMs can be located on separate computers - yet one JVM can invoke methods belonging to an object stored in another JVM. Methods can even pass objects that a foreign virtual machine has never encountered before, allowing dynamic loading of new classes as required.

DESIGN:

In order to understand the design of the RMI program, it is important to comprehend the way that RMI functions, a brief look at the RMI architecture will help explain the design of our program.

RMI architecture:

  • The server must first bind its name to the registry
  • The client lookup the server name in the registry to establish remote references.
  • The Stub serializing the parameters to skeleton, the skeleton invoking the remote method and serializing the result back to the stub.

Stub and Skeleton:      

  • A client invokes 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, marshalling the object parameters and forwarding the data stream to the skeleton.
  • A skeleton contains a method that receives the remote calls, unmarshalls the parameters, and invokes the actual remote object implementation.

Flow Diagrams:

The following will represent:
     □ The RMI Client side flow diagram

      □ The RMI Server side flow diagram

     

IMPLEMENTATION:

RMIFile INTERFACE:  

 /*Import package java.rmi*/

import java.rmi.*;

Join now!

/*Define public interface that is an extension of java.rmi.Remote*/

public interface RMIFile extends Remote

{

    /*Declare a read() method that takes two arguments and throws a RemoteException*/

        String read(int linenum, char passwd) throws RemoteException;

}

RMIFileImpl:

/*Import the following packages to be used in the program*/

import java.rmi.*;

import java.rmi.server.*;

import java.io.*;

/*Declare a public class that extends a UnicastRemoteObjec and implements the RMIFile*/

public class RMIFileImpl extends UnicastRemoteObject implements RMIFile

{

/*Declare a static String object and assign to "localhost"*/

        public static final String Host ="localhost";

        

/*Define a constructor that ...

This is a preview of the whole essay