1 / 17

Remote Method Invocation (RMI)

Remote Method Invocation (RMI). IST 411 Lecture 8 Spring 2004. List. A collection is a data structure, an object, that can hold references to other objects. One collections-framework interface is a List

gdunn
Télécharger la présentation

Remote Method Invocation (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. Remote Method Invocation (RMI) IST 411 Lecture 8 Spring 2004

  2. List • A collection is a data structure, an object, that can hold references to other objects. • One collections-framework interface is a List • Frameworks include a number of features that minimize the amount of coding programmers need to do to create and manipulate collections • Members of the package java.util.*

  3. List • A List (sometimes called a sequence) is an ordered Collection that can contain duplicate elements • Index is zero based • Interface List may be implemented by class ArrayList • ArrayList is a resizable-array implementation of a List • ArrayList execute faster than Vectors

  4. Remote Method Invocation • Remote method invocation • Distributed systems technology • One JVM invokes object methods that will run on another JVM on a network • Used in development of large-scale systems • Distribute resources and processing load across multiple machines

  5. Remote Method Invocation • Before object-oriented programming, technology used was Remote Procedure Calls (RPC). • Developed by Sun Microsystems • Designed as a platform-neutral way of communicating between applications • Operating system or language independent

  6. Remote Method Invocation • Difference between RPC and RMI: • Java is platform-neutral language • Java applications conceivably able to communicate with Java applications running on any hardware or operating system that supports JVM • RMI only support applications written in Java • RPC supports multiple languages

  7. Remote Method Invocation • RMI systems are divided into two categories: • Clients – invokes object methods of the server • Servers – provides an RMI service • RMI servers must register with a lookup service so clients can find them • Java platform has an application called rmiregistry which runs as a separate process • Allows applications to register RMI services

  8. Remote Method Invocation • Once a server is registered, waits for incoming RMI requests from clients

  9. Remote Method Invocation • RMI clients send RMI messages to invoke an object method remotely • Client needs remote object reference • Normally obtained from the RMI registry • Format of an RMI remote object reference: rmi://hostname:port/servicename • Hostname represents name of a server (or IP address) • Port is the location of the service on that machine; default port number for RMI registry is 1099 • Servicename is a string description of the service

  10. Remote Method Invocation • Networking details of requests are transparent to application developer • Remote objects seem like local objects • Achieved through division or RMI system into two components: • Stub – acts as a proxy object; RMI service is defined as an interface, not as an implementation • Skeleton – responsible for listening for incoming RMI requests and passing them on to the RMI service

  11. Remote Method Invocation • The stub is derived by compiling the remote object class using the rmic compiler • Utility supplied with J2SE SDK • A stub class forwards method invocations to the RMI layer; performs network communication to invoke method call on the remote object • In Java 1.1, rmic produced 2 classes – a stub class and a skeleton class • Java 2 no longer requires the skeleton class

  12. Remote Method Invocation • Messages are sent between the stub and skeleton using TCP sockets • Skeleton listens for incoming socket requests • When stub passes a request, it must package parameters • Either primitive datatypes, objects, or both • Called data marshalling • Skeleton reconstitutes parameters…unmarshalling • Use specialized subclasses of ObjectOutputStream and ObjectInputStream classes • Parameters are passed by value

  13. Remote Method Invocation • RMI Service Interface • Service interface defines the object methods that can be invoked remotely • Specifies parameters, return types, and exception that may be thown • All RMI service interfaces extend java.rmi.Remote • Common exception is: throws java.rmi.RemoteException which could occur when the system is down

  14. Compiling and Executing • Compiling and executing the server and client • Compile the classes • Compile the remote object class using the rmic compiler rmic –v1.2 <name of the Java file> • Start the RMI registry rmiregistry • Make the remote object available to receive remote method calls, bind the object to the name in the RMI registry java <application>

  15. Compiling and Executing • Run the client program java <client program name> • If the remote application is running on a different machine from the client, you can specify the IP address or host name on the command-line java <client program name> <IP address>

More Related