15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.

Slides:



Advertisements
Similar presentations
Remote Method Invocation CS587x Lecture Department of Computer Science Iowa State University.
Advertisements

15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Remote Method Invocation in Java Bennie Lewis EEL 6897.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation
FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
CSE331: Introduction to Networks and Security Lecture 11 Fall 2002.
Introduction to Remote Method Invocation (RMI)
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Java RMI RMI = Remote Method Invocation. Allows Java programs to invoke methods of remote objects. Only between Java programs. Several versions (JDK-1.1,
Internet Software Development Remote Method Invocation Paul Krause.
1 Java Programming II Java Network II (Distributed Objects in Java)
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
+ A Short Java RMI Tutorial Usman Saleem
Presentation: RMI Continued 2 Using The Registry & Callbacks.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
Java RMI: Remote Method Invocation January 2000 Nancy McCracken Syracuse University.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Presentation 18: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI RMI is the java API that facilitate distributed computing by allowing remote method calls. A remote method call represents a method invocation between.
RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
Remote Method Invocation onlineTraining/rmi/RMI.html.
RMI Continued IS Outline  Review of RMI  Programming example.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Presentation: RMI introduction. Goals of this lesson After this 35 min. lesson you will be: Introduced to Java RMI Ready to present RMI’s position in.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Presentation 11: RMI introduction. Ingeniørhøjskolen i Århus Slide 2 af 20 Goals of this lesson After these 2x35 lessons you will be –Introduced to Java.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Remote Method Invocation with Java-RMI
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
Florida State UniversityCOP Advanced Unix Programming Remote Method Invocation /rmi/index.html.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Remote Method Invocation RMI architecture stubs and skeletons for remote services RMI server and client in Java Creating an RMI Application step-by- step.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
1 Lecture 15 Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Distributed programming in Java Faculty:Nguyen Ngoc Tu Session 5 - RMI.
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
Netprog Java RMI1 Remote Method Invocation.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
Principles of Software Development
Java Remote Method Invocation (RMI)
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Java RMI (more) CS-328 Internet Programming.
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Creating a Distributed System with RMI
Remote Method Invocation
Creating a Distributed System with RMI
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Java Remote Method Invocation
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

15 - RMI

Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using RMI

3 NOEA2009Java-kursus – RMI Communikation between different machines Sockets, RPC and RMI –For sockets a common protocol on application level is needed to encode and decode sent and received messages –RPC (Remote Procedure Call) pulls the abstraction level for communication up ti procedural level –RMI (Remote Method Invocation) handles communication between objects in different adress spaces.

4 NOEA2009Java-kursus – RMI Distributed Object-application (DOA) A application, where the server provides remote objects on which methods might be activated from different clients, is called a hvis metoder kan kaldes fra forskellige klienter ”distributed object-application” DOA needs to: –Localize remote objects –Communicate with remote objects –Handle byte code for objects that are send as a parameter or a return value RMI can handle this

5 NOEA2009Java-kursus – RMI Architecture

6 NOEA2009Java-kursus – RMI Example for building a RMI-application The steps: 1.Contruct an interface (remote) 2.Implement the interface 3.Create a server class 4.Create a client class 5.Compile it (javac og rmic) 6.Run the application start rmi-registry (not nessesary from java 1.5), server and klient

7 NOEA2009Java-kursus – RMI Oprettelse af interface import java.rmi.*; public interface Hello extends Remote { public String getGreeting() throws RemoteException; } Java.rmi.Remote is a interface that all RMI-application must inherit from Java.rmi.RemoteException is the superclass for exceptions that RMI can throw and shall always be handled

8 NOEA2009Java-kursus – RMI Implementation af interfacet import java.rmi.*; import java.rmi.server.*; public class HelloImpl extends UnicastRemoteObject implements Hello{ public HelloImpl() throws RemoteException { //Default constructor is implemented because of RemoteException } public String getGreeting() throws RemoteException { return ("Hello there!"); }

9 NOEA2009Java-kursus – RMI Server class //Server. import java.rmi.*; public class HelloServer{ private static final String HOST = "localhost"; public static void main(String[] args) throws Exception{ HelloImpl temp = new HelloImpl(); String rmiObjectName = "rmi://" + HOST + "/Hello"; //Could omit host name, since 'localhost' would be //assumed by default. Naming.rebind(rmiObjectName,temp); System.out.println("Binding complete...\n"); }

10 NOEA2009Java-kursus – RMI Client class import java.rmi.*; public class HelloClient{ private static final String HOST = "localhost"; public static void main(String[] args){ try{ Hello greeting = (Hello)Naming.lookup("rmi://" + HOST + "/Hello"); System.out.println("Message received: " + greeting.getGreeting()); } catch(ConnectException conEx){ System.out.println("Unable to connect to server!"); } catch(Exception e){ e.printStackTrace(); }

11 NOEA2009Java-kursus – RMI From JDK 1.5 this is done automaticly Generate the stub We still missing the piece of code that handles the communication. It is placed in the file HelloImpl_Stub The file is generated by running rmic.exe på impl-filen: rmic –v1.2 HelloImpl

12 NOEA2009Java-kursus – RMI How does it function? - Deployment To make the client run: the HelloClient, Hello and HelloImpl_stub must be present on the client HelloServer, Hello, HelloImpl and HelloImpl_stub must be present on the server The stub is a proxy class for the remote-object. The stub takes care of the communication between the client and the server by marshalling/unmarshalling The client knows how to manipulate the server object because yhe server object implements the interface that is also known on the client

13 NOEA2009Java-kursus – RMI RMIRegistry Rmiregistry is a program that handles the nameservice. Registry shall be started before the server is started (This is done automatically in jdk1.5+) The rebind-method of the server binds a name (URL) to the implementation object on the server. The client can use the lookup method to get a reference to the impl-object Add your server files to classpath in order for rmiregistry to find them. Rmiregistry is started from the command promt by: start rmiregistry

14 NOEA2009Java-kursus – RMI Call semantics When a method is called on a remote object, there is two ways of passing the parameters dependent of whether the parameter (and the return value) is a remote object or not. If remote then is call-by-reference If not then it is call-by-value (copy) Objects that are sent by copy shall implement the interface Serializable