DOC PREVIEW
CMU ISM 95702 - Remote Method Invocation

This preview shows page 1-2-3-22-23-24-44-45-46 out of 46 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Goals/Principles Of RMISlide 3Slide 4Slide 5Slide 6Slide 7The Proxy Design PatternExample 1 - A ClientSlide 10Notes about the clientSlide 12Slide 13Slide 14File client.policyNotes About the clientFiles on the server Product.javaNotes on Product InterfaceFiles on the server ProductImpl.javaNotes on ProductImpl.javaFiles on the server ProductServer.javaSlide 22Notes on the ProductServer.javaSummary of ActivitiesParameter Passing in Remote MethodsSlide 26Slide 27Example 2 - RMI WhiteboardClient DirectoryServer DirectoryGraphicalObject.javaSlide 32Shape.javaShapeServant.javaSlide 35ShapeList.javaShapeListServant.javaSlide 38Slide 39ShapeListServer.javaSlide 41ShapeListClient.javaSlide 43Slide 44Slide 45Slide 46RMI 1Remote Method InvocationSlides Adapted from “Core Java 2” by Cay Horstmann, the RMI Tutorial from Sun, and Coulouris text on Distributed Systems95-702 OCTRMI 2Goals/Principles Of RMI•Distributed Java •Almost the same syntax and semantics used by non-distributed applications•Allow code that defines behavior and code that implements behavior to remain separate and to run on separate JVMs •The transport layer is TCP/IPRMI 3Goals/Principles Of RMI•On top of TCP/IP, RMI originally used a protocol called Java Remote Method Protocol (JRMP). JRMP is proprietary.•For increased interoperability RMI now uses the Internet Inter-ORB Protocol (IIOP). This protocol is language neutral and runs on TCP/IP providing a standard way to make method calls to remote objects.RMI 4Goals/Principles Of RMI•RMI uses the proxy design pattern. An object in one context is represented by another (the proxy) in a separate context. The proxy knows how to forward method calls between the participating objects. •In JDK 1.1 the client connects to an existing, waiting, object.•In JDK 1.2, RMI supports activatable remote objects. Dormant objects are brought from disk into memory.RMI 5Goals/Principles Of RMI•A naming or directory service is run on a well-known host and port number •Usually a DNS name is used instead of an IP address •RMI itself includes a simple service called the RMI Registry, rmiregistry. The RMI Registry runs on each machine that hosts remote service objects and accepts queries for services, by default on port 1099RMI 6Goals/Principles Of RMI•On the client side, the RMI Registry is accessed through the static class Naming. It provides the method lookup() that a client uses to query a registry. •The registry is not the only source of remote object references. A remote method may return a remote reference.•The registry returns references when given a registered nameRMI 7ClientVirtual MachineServerVirtual Machinemethod calls withparametersreturn values andexceptionsThe roles of client and server only apply to a single method call.It is entirely possible for the roles to be reversed.RMIRMI 8The Proxy Design PatternService Proxy Service ImplementationClientService ProxyService ImplementationService InterfaceRMI 9Example 1 - A Client import java.rmi.*;public class ProductClient { public static void main(String args[]) { System.setSecurityManager( new RMISecurityManager()); String url = "rmi://localhost/";RMI 10try { // get remote references Product c1 = (Product)Naming.lookup(url + "toaster"); Product c2 = (Product)Naming.lookup(url + "microwave"); // make calls on local stubs // get two String objects from server System.out.println(c1.getDescription()); System.out.println(c2.getDescription()); } catch( Exception e) { System.out.println("Error " + e); } System.exit(0); }}RMI 11Notes about the client• The default behavior when running a Java application is that no security manager is installed. A Java application can read and write files, open sockets, start print jobs and so on.• Applets, on the other hand, immediately install a security manager that is quite restrictive.• A security manager may be installed with a call to the static setSecurityManager method in the System class.RMI 12Notes about the client• Any time you load code from another source (as this client is by dynamically downloading the stub class), you need a security manager.• By default, the RMISecurityManager restricts all code in the program from establishing network connections. But, this program needs network connections. -- to reach the RMI registry -- to contact the server objects• So, Java requires that we inform the security manager through a policy file.RMI 13Notes about the client• The Naming class provides methods for storing and obtaining references to remote objects in the remote object registry. • Callers on a remote (or local) host can lookup the remote object by name, obtain its reference, and then invoke remote methods on the object.• lookup is a static method of the Naming class that returns a reference to an object that implements the remote interface. Its single parameter contains a URL and the name of the object.RMI 14Notes about the clientThe object references c1 and c2 do not actually refer to objects on theserver. Instead, these references refer to a stub class that must existon the client. Product c1 = (Product)Naming.lookup(url + "toaster");Product c2 = (Product)Naming.lookup(url + "microwave");The stub class is in charge of object serialization and transmission.it’s the stub object that actually gets called by the client with theline System.out.println(c1.getDescription());RMI 15File client.policygrant { permission java.net.SocketPermission "*:1024-65535", "connect";};This policy file allows an application to make any networkconnection to a port with port number at least 1024. (The RMIport is 1099 by default, and the server objects also use ports>= 1024.)RMI 16Notes About the clientWhen running the client, we must set a system propertythat describes where we have stored the policy.javac ProductClient.java java –Djava.security.policy=client.policy ProductClientRMI 17Files on the server Product.java// Product.javaimport java.rmi.*;public interface Product extends Remote { String getDescription() throws RemoteException;}RMI 18Notes on Product Interface•This interface must reside on both the client and the server.•All interfaces for remote objects must extend remote.•Each method requires the caller to handle a


View Full Document

CMU ISM 95702 - Remote Method Invocation

Documents in this Course
Homework

Homework

12 pages

Lecture

Lecture

25 pages

Lecture

Lecture

21 pages

Lecture

Lecture

24 pages

Exam

Exam

11 pages

Homework

Homework

16 pages

Homework

Homework

38 pages

lecture

lecture

38 pages

review

review

7 pages

lecture

lecture

18 pages

review

review

8 pages

Chapter2

Chapter2

32 pages

Lecture 4

Lecture 4

47 pages

Lecture

Lecture

22 pages

Naming

Naming

26 pages

lecture

lecture

34 pages

lecture

lecture

42 pages

lecture

lecture

112 pages

Lecture

Lecture

33 pages

Axis

Axis

43 pages

lecture

lecture

32 pages

review

review

17 pages

Lecture

Lecture

53 pages

Lecture

Lecture

80 pages

Lab

Lab

14 pages

Load more
Download Remote Method Invocation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Remote Method Invocation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Remote Method Invocation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?