Docsity

Java Remote Method Invocation (RMI) - An Introduction, Slides of Java Programming

Partial preview of the text

Download Java Remote Method Invocation (RMI) - An Introduction and more Slides Java Programming in PDF only on Docsity!

RMI

Introduction to RMI

Warning

  • This course is very volatile. Software is upgraded every semester. You should not assume that an example in the presentation is complete, or that it will work in the present environment. It is best to get your code examples from the Sun Java tutorials and modify them to work. Use the lectures to understand the general principles.

Remote Method Invocation

  • RMI provides the means to invoke methods remotely.
  • RMI allows for applications to communicate and execute across multiple systems on a network.
  • RMI is supported by the java.rmi, java.rmi.server, and java.rmi.registry
  • Enhanced security of Java 2 requires a security policy implementation.

Serializable objects

  • For a parameter to be passed remotely in Java, it must be serializable. This means that it must be capable of being packaged in a form that can be marshaled and unmarshaled. Marchaling is the process of packaging information so that it can be passed over a connection without errors due to any differences in the client and server environments.

Parts in a RMI System

  • Interface definitions for remote services
  • Implementations of the remote services
  • Stub and Skeleton files
  • A server to host the remote services
  • An RMI Naming service that allows clients to find the remote services
  • A class file provider (an HTTP or FTP server)

RMI process

Java Client Java Server

Client Stub Server Skeleton

Client Method (^) Called Method

Network transport Network Transport

arguments results

Network

Not needed In Java 2

Stub Class

  • A stub for a remote object is the client-side proxy for the remote object. Such a stub implements all the interfaces that are supported by the remote object implementation. The client-side stub responsibilities are shown on the next slide.

Stub Class Responsibilities

  • Initiating a call to the remote object (by calling the remote reference layer).
  • Marshaling arguments to a marshal stream (obtained from the remote reference layer).
  • Informing the remote reference layer that the call should be invoked.
  • Unmarshaling the return value or exception from a marshal stream.
  • Informing the remote reference layer that the call is complete.

Remote Reference Layer

  • The remote reference layer deals with the lower level transport interface and is responsible for carrying out a specific remote reference protocol which is independent of the client stubs and server skeletons. The remote reference layer has two cooperating components: the client-side and the server-side components.

Remote Reference Layer (2)

  • The client-side component contains information specific to the remote server (or servers, if the remote reference is to a replicated object) and communicates via the transport to the server- side component. During each method invocation, the client and server-side components perform the specific remote reference semantics.

Remote Reference Layer (4)

  • For example, the server side could handle ensuring atomic multiple delivery by communicating with other servers in the replica group.The remote reference layer transmits data to the transport layer via the abstraction of a stream-oriented connection. The transport takes care of the implementation details of connections. Although connections present a streams-based interface, a connectionless transport may be implemented beneath the abstraction

RMI Registry

  • The Registry tracks the addresses of the remote objects exported by applications
  • It is the central management point for RMI
  • Does not actually invoke remote methods
  • Bind() links the object in the registry
  • Rebind() replaces object with a new one

Parameter Marshalling

  • RMI stubs are responsible for packaging parameters used in a remote method in a block of bytes using the big-endian byte order. This is called parameter marshalling. A receiver object on the server must unmarshall the parameters or report errors.

Building RMI Applications

  • Define remote interfaces
  • Create classes that implement the interfaces
  • Create stub and skeleton classes for the implementation classes.
  • Create Security Policy