Remote Method Invocation - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Remote Method Invocation

Description:

is a framework for distributed objects using the Python programming language ... is a Java application programming interface for performing the object equivalent ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 17
Provided by: dlf9
Category:

less

Transcript and Presenter's Notes

Title: Remote Method Invocation


1
Remote Method Invocation 
Developing Remote Object Programs  Hea
ther Jenkins Daniel Ferrell University of
North Carolina at Wilmington
2
Before Distributed Objects
  • Began with monolithic mainframe systems
  • Each system contained its own logic
  • System was unable to share data with other
    systems
  • Monolithic systems were inefficient and costly
  • Reusing code was difficult
  • Usually it meant copying a segment of code
  • Modifying it
  • Then deploying the modified copy
  • A change to one meant a change to all

3
Distributed Objects
  • Divides today's still monolithic client/server
    applications into self-managing components, or
    objects, which can interoperate across dissimilar
    networks and operating systems.
  • EXAMPLE
  • Programs that can be written which enable code on
    other computers to send messages to them
  • oldUpdateProxy.adjust (oldVal, newVal)

4
Distributed Objects Applications
  • CORBA
  • lets one build distributed mixed object systems
  • DCOM
  • is a framework for distributed objects on the
    Microsoft platform
  • PYRO
  • is a framework for distributed objects using
    the Python programming language
  • Distributed Ruby (DRb)
  • is a framework for distributed objects using the
    Ruby programming language
  • RMI
  • is a Java application programming interface for
    performing the object equivalent of remote
    procedure calls.

5
RMI Remote Method Invocation
  • Pure Java technology that is restricted to the
    development of distributed objects expressed only
    in Java
  • A mechanism that allows you to invoke a method or
    an object that is located in another address
    space
  • Provides a homogeneous environment
  • It supports features such as code portability,
    dynamic code loading, Java security, and garbage
    collection

6
RMI Remote Method Invocation
  • Registry
  • The client communicates to the server and
    requests an object. Once the registry has found
    the object, then it directs the request to the
    correct object.
  • Security
  • INSECURE with RMI
  • Spoofing someone acts as a client and could
    potentially read data that the remote object has
    access to.
  • Security Manager RMISecurityManage()
  • Garbage Collectors
  • Keeps a count of the number of references to
    each object. When the number reaches 0, the
    memory space is de-allocated for future use.

7
RMI Layer Terminology
  • Stubs/Skeletons
  • A stub for a remote object acts as a client's
    local representative or proxy for the remote
    object.
  • Remote Reference Layer
  • determines whether the request is a Unicast or
    Multicast Protocol.
  • Transport
  • sets up and manages the request

8
Alternatives to RMI
  • TCP Sockets
  • implemented using TCP sockets to allow
    distributed components of the system to
    communicate with each other.
  • CORBA
  • - Common Object Request Broker Architecture
    More Expensive. No free development kit. Not
    Java.
  • RCP Library
  • Remote Procedure Call Better suited for linear
    programming.

9
RMI Expensive? Cheap? Easy?
  • Java is a widely known OOP
  • - Development kits and other resources freely
    available.
  • Cheaper than other alternatives of middleware
  • - Cheaper than CORBA.
  • JDK Development Kit 1.1
  • - Development is can easily be started.

10
Implementation of RMI
  • Remote Objects , Communication, Load Definitions
    for Objects.

11
Example A Simple Hello World-
RemoteInterface.Java
  • import java.rmi.Remote
  • import java.rmi.RemoteException
  • public interface RemoteInterface extends Remote
  • String REGISTRY_NAME "RMI_Example"
  • int REGISTRY_PORT 3273
  • String getMessage() throws RemoteException

12
Server.Java
  • import java.rmi.registry.LocateRegistry
  • import java.rmi.registry.Registry
  • import java.rmi.server.UnicastRemoteObject
  • public class Server implements RemoteInterface
  • public String getMessage()
  • return "Hello World"
  • public static void main(String args)
  • try
  • Registry registry
    LocateRegistry.getRegistry(RemoteInterface.REGISTR
    Y_PORT)
  • RemoteInterface remoteReference
  • (RemoteInterface)
    UnicastRemoteObject.exportObject(new Server())
  • registry.rebind(RemoteInterface.REGIST
    RY_NAME, remoteReference)

13
ClientApplet.Java
  • import java.rmi.registry.LocateRegistry
  • import java.rmi.registry.Registry
  • import javax.swing.JApplet
  • import javax.swing.JLabel
  • public class ClientApplet extends JApplet
  • public void init()
  • try
  • Registry registry
  • LocateRegistry.getRegistry(getCode
    Base().getHost(), RemoteInterface.REGISTRY_PORT)
  • RemoteInterface remoteReference
  • (RemoteInterface)
    registry.lookup(RemoteInterface.REGISTRY_NAME)
  • getContentPane().add(new
    JLabel(remoteReference.getMessage()))
  • catch (Exception e)

14
How To Put It All Together
  • 1. Create HTML File For Applet
  • ltHTMLgt
  • lttitlegtHello Worldlt/titlegt
  • ltcentergt lth1gtHello Worldlt/h1gt lt/centergt
  • The message from the HelloServer is
  • ltpgt
  • ltobject classid"javaClientApplet.class"
  • type"application/x-java-applet"
  • height"50" width"150" gt
  • lt/objectgt
  • lt/pgt
  • lt/HTMLgt

15
Now Run!
  • 1. Compile the classes.
  • - javac .java
  • Run RMI
  • - rmic Server
  • Start RMI Registry (Open Port)
  • start rmiregistry 3273
  • (unix) rmiregistry 3273
  • Start the server
  • start java Server
  • (unix) java Server
  • Open HTML!

16
RMI Questions?
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com