42
JAVA REMOTE METHOD INVOCATION (RMI) Mohammad Masudur Rahman [email protected] Department of Computer Science University of Saskatchewan Saskatoon, SK, S7N5C9 Date: April 09, 2013

Java RMI Presentation

Embed Size (px)

DESCRIPTION

A simplified tutorial for Java RMI

Citation preview

Page 1: Java RMI Presentation

JAVA REMOTE METHOD INVOCATION (RMI)

Mohammad Masudur [email protected]

Department of Computer Science

University of Saskatchewan

Saskatoon, SK, S7N5C9

Date: April 09, 2013

Page 2: Java RMI Presentation

2

Page 3: Java RMI Presentation

3

TUTORIAL CONTENTS

Java Remote Method Invocation Historical Background Related Terminologies RMI System Architecture

Layered Structures Working Principles

A Simple RMI Application Server, Client, Interface, Stubs Security, Deployment, Invocation

Strength & Weakness of RMI RMI vs. CORBA Case Study

Page 4: Java RMI Presentation

4

JAVA REMOTE METHOD INVOCATION

Fig: Distributed Object Technology

Page 5: Java RMI Presentation

5

JAVA REMOTE METHOD INVOCATION

RMI Server, client, interface, stubs, skeletons RMI Registry Object version of RPC Method Invocation between JVMs Java RMI API JRMP (Java Remote Method Protocol) Java object serialization Parameter Marshalling

Page 6: Java RMI Presentation

6

HISTORICAL BACKGROUND

Java Sockets by SUN

Java RPC by SUN

Java RMI by SUN

CORBA by OMG

SOAP by Microsof

t

Abstraction: Low level

Abstraction: Procedure level

Abstraction: Object level

Page 7: Java RMI Presentation

7

RELATED TERMINOLOGIES

RPC (Remote Procedure Call) XDR (External Data Representation) CORBA (Common Object Request Broker

Architecture) IIOP (Internet Inter-ORB Protocol) Java IDL (Interface Definition Language) RMI-IIOP SOAP (Simple Object Access Protocol)

Page 8: Java RMI Presentation

8

RMI SYSTEM ARCHITECTURE

Lets divide into two perspectives: Layered Structure Working Principles

Page 9: Java RMI Presentation

9

RMI LAYERED STRUCTURE

Fig: RMI Layered Structure

Page 10: Java RMI Presentation

10

RMI LAYERED STRUCTURE

Application layer: Server, Client Interface: Client stub, Server skeleton Remote Reference layer: RMI registry Transport layer: HTTP

Page 11: Java RMI Presentation

11

RMI WORKING PRINCIPLES

Fig: RMI Working principles

Page 12: Java RMI Presentation

12

READY TO DEVELOP ONE?

Page 13: Java RMI Presentation

13

A SIMPLE RMI APPLICATION

SERVERo Writing an Interfaceo Implementing an

Interfaceo Binding Interface

CLIENTo Writing a Client

DEPLOYMENTo Manage Security

Settingso Running Server &

Client

1

2

3

Page 14: Java RMI Presentation

14

SERVICE INTERFACE: AN AGREEMENT BETWEEN SERVER & CLIENT

Factorial Operation

Check Prime Operation

Square Operation

Page 15: Java RMI Presentation

15

SERVER APPLICATION: WRITING A SERVICE INTERFACE

Fig: MathService Interface

Page 16: Java RMI Presentation

16

SERVER APPLICATION: IMPLEMENTING THE SERVICE INTERFACE

Fig: MathServiceProvider implements MathService Interface

Page 17: Java RMI Presentation

17

SERVER APPLICATION: INSTANTIATING & BINDING THE SERVICE

Fig: Instantiating and Binding MathService Interface

Page 18: Java RMI Presentation

18

A SIMPLE RMI APPLICATION

SERVERo Writing an Interfaceo Implementing an

Interfaceo Binding Interface

CLIENTo Writing a Client

DEPLOYMENTo Manage Security

Settingso Running Server &

Client

1

2

3

Page 19: Java RMI Presentation

19

CLIENT APPLICATION: SERVICE LOOKUP

Fig: Client locating MathService service

Page 20: Java RMI Presentation

20

CLIENT APPLICATION: ACCESSING SERVICE

Fig: Client accessing MathService service

Page 21: Java RMI Presentation

21

A SIMPLE RMI APPLICATION

SERVERo Writing an Interfaceo Implementing an

Interfaceo Binding Interface

CLIENTo Writing a Client

DEPLOYMENTo Manage Security

Settingso Running Server &

Client

1

2

3

Page 22: Java RMI Presentation

22

SERVER DEPLOYMENT: START RMI REGISTRY

To start RMI registry on windows

To start RMI registry on Unix

Page 23: Java RMI Presentation

23

SERVER DEPLOYMENT: COMPILE THE SERVER

Compile both MathService interface and MathServiceProvider class

Page 24: Java RMI Presentation

24

SERVER DEPLOYMENT: CREATE SERVER STUB

Create the server stub that will handle client call

Page 25: Java RMI Presentation

25

SECURITY DEPLOYMENT: CREATE SECURITY POLICY FILE (BOTH CLIENT & SERVER)

Create a security policy file called no.policy with the following content and add it to CLASSPATH

This step implies for both server and client

Page 26: Java RMI Presentation

26

START THE SERVER

Execute the command to run server

Page 27: Java RMI Presentation

27

SERVER RUNNING

Page 28: Java RMI Presentation

28

START THE CLIENT

Execute the command to run client

Page 29: Java RMI Presentation

29

CLIENT INTERFACE

Page 30: Java RMI Presentation

30

ADVANCED CONCEPTS

Java Object Serialization Parameter Marshalling & Demarshalling Object Activation

Page 31: Java RMI Presentation

31

STRENGTH OF JAVA RMI

Object Oriented: Can pass complex object rather than only primitive types

Mobile Behavior: Change of roles between client and server easily

Design Patterns: Encourages OO design patterns as objects are transferred

Safe & Secure: The security settings of Java framework used

Easy to Write /Easy to Use: Requires very little coding to access service

Page 32: Java RMI Presentation

32

STRENGTH OF JAVA RMI

Connects to Legacy Systems: JNI & JDBC facilitate access.

Write Once, Run Anywhere: 100% portable, run on any machine having JVM

Distributed Garbage Collection: Same principle like memory garbage collection

Parallel Computing: Through multi-threading RMI server can serve numerous clients

Distributed Computing Solutions: Available from JDK 1.1, can communicate between all versions of JDKs

Page 33: Java RMI Presentation

33

WEAKNESS OF JAVA RMI

Tied to Java System: Purely Java-centric technology, does not have good support for legacy system written in C, C++, Ada etc.

Performance Issue : Only good for large-grain computation

Security Restrictions & Complexities: Threats during downloading objects from server, malicious client request, added security complexity in policy file.

Overhead: Extra usage of rmic tool.

Page 34: Java RMI Presentation

34

CASE STUDY: JAVA RMI VS. CORBA

Page 35: Java RMI Presentation

35

CASE STUDY: JAVA RMI VS. CORBA

Language Dependence: RMI service interface is in Java CORBA service interface is platform independent

Mobile Behavior Server and client can change roles in RMI Not feasible in CORBA

Performance Issue: RMI needs extra overhead for conversion from byte code to machine codeCORBA performs better for massive computation like fluid mechanics

Page 36: Java RMI Presentation

36

CASE STUDY: JAVA RMI VS. CORBA

Ease of Use: RMI is easy to master for experienced programmers. CORBA is a rich, extensive family of standards, hard to master

Maturity of Technology RMI is less matured CORBA is more matured and already has many implementations running

Page 37: Java RMI Presentation

37

JAVA RMI CUSTOMERS

IBM Swiss Federal Supreme Court CEAS Consulting Avitek Different Chat service Company More can be found here:

http://www.cs.mun.ca/~paul8/jdk1.2beta3/docs/guide/rmi/examples.html

Page 38: Java RMI Presentation

38

CORBA CUSTOMERS

USA AG Cisco Systems American Airlines BHP Information Technology More can be found here:

http://www.corba.org/success.htm

Page 39: Java RMI Presentation

39

CASE STUDY: JAVA RMI VS. CORBA

Results of case study:o No one is better than other necessarilyo Applicability of one on another depends on

Purpose of the application Experience of the designer and developer Necessity of interoperability with non-java

systems.

Page 40: Java RMI Presentation

40

CONCLUSION

Distributed Object Technology Object level abstraction Object version of Java RPC Java centric Technology Comparable to CORBA, SOAP Provides non-java support with the help IDL,

IIOP and CORBA Lightweight and Easy to use Object serialization Concurrent support for clients

Page 41: Java RMI Presentation

41

THANK YOU !!! QUESTIONS PLEASE?

Page 42: Java RMI Presentation

42

REFERENCES[1].Advantages of java RMI

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-138781.html

[2] Java RMI architecture. http://www.cs.mun.ca/michael/java/jdk1.1-beta2-docs/guide/rmi/rmi-arch.doc.html

[3] Introduction to java RMI http://www.javacoffeebreak.com/articles/javarmi/javarmi.html.

[4] Java RMI: Remote method invocation. http://www1.cs.columbia.edu/dcc/nestor/presentations/java-rmi/java-rmi-handouts.pdf

[5] Disadvantages of RMI. http://www.coderanch.com/t/180297/javadeveloper-SCJD/certification/RMI-Advantages-Disadvantages.

[6] Background of java rmi. http://docs.oracle.com/javase/1.5.0/docs/guide/rmi/spec/rmi-intro2.html.

[7] How RMI works. http://www.sce.carleton.ca/netmanage/simulator/rmi/RMIExplanation.htm

Please contact [email protected] to get more.