Creating Applications Using RMI Lesson 1B / Slide 1 of 19 Network and Distributed Programming in Java Pre-assessment Questions 1.Which of the following.

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
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.
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
Changing the way of designing distributed applications Communication oriented design: FIRST design the communication protocol for the distributed system.
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.
DISTRIBUTED FILE SYSTEM USING RMI
Java RMI. What is RMI? RMI is an RPC system for an object based language. Objects provide a natural granularity for the binding of functions. –RMI allows.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
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.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
RMI Components java.rmi: client-side RMI classes, interfaces, and exceptions java.rmi.server: server-side RMI classes, interfaces, and exceptions java.rmi.registry:
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
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.
Presentation: RMI Continued 2 Using The Registry & Callbacks.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
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.
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.
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.
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.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Example: RMI Program How to write it.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
Java Remote Method Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Remote Method Invocation Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
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.
Java RMI. RMI Any object whose methods can be invoked from another Java VM is called a remote object.
Java Distributed Object Model A remote object is one whose methods can be invoked from another JVM on a different host. It implements one or more remote.
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.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Java Distributed Computing
Chapter 4 Remote Method Invocation
Java Distributed Computing
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Remote Method Invocation
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
----> In Server side dos window
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Creating Applications Using RMI Lesson 1B / Slide 1 of 19 Network and Distributed Programming in Java Pre-assessment Questions 1.Which of the following refers to the component-based approach of creating distributed applications? a.Two-tier architecture b.Three-tier architecture c.Monolithic architecture d.Single-tier architecture 2. Which of the following is NOT true for RMI? a.RMI is a specification that enables one JVM to invoke methods of an object located in another JVM. b.RMI is implemented on the middle-tier of the three-tier architecture framework. c.RMI application run on cross-platform specification. d.RMI supports cross-language specification.

Creating Applications Using RMI Lesson 1B / Slide 2 of 19 Network and Distributed Programming in Java Pre-assessment Questions 3. RMI registry is a _____. a.Server b.Client c.Middle-tier d.Service 4.Which of the following services is provided by the transport layer in the RMI architecture? a.Creating the connection between the client and server b.Creating the server objects c.Registering the server object d.Invoking the remote method

Creating Applications Using RMI Lesson 1B / Slide 3 of 19 Network and Distributed Programming in Java Pre-assessment Questions 5. Which system property controls the lease time? a.java.rmi.dgc.lease.clean b.javax.rmi.dgc.leaseValue c.java.rmi.dgc.leaseValue d.java.rmi.dgc.lease.dirty

Creating Applications Using RMI Lesson 1B / Slide 4 of 19 Network and Distributed Programming in Java Solutions to Pre-assessment Questions 1. b. Three-tier Architecture 2. d. RMI supports cross-language specification. 3. d. Service 4. a. Creating the connection between the client and server 5. c. java.rmi.dgc.leaseValue

Creating Applications Using RMI Lesson 1B / Slide 5 of 19 Network and Distributed Programming in Java Objectives In this lesson, you will learn about: Transmit files using RMI Create application using client-side callbacks

Creating Applications Using RMI Lesson 1B / Slide 6 of 19 Network and Distributed Programming in Java Demonstration-Transmitting Files Using RMI Problem Statement Create a distributed application using RMI, where an RMI client can download a file (plain text or binary) from the RMI server.

Creating Applications Using RMI Lesson 1B / Slide 7 of 19 Network and Distributed Programming in Java Demonstration-Transmitting Files Using RMI (Contd.) Solution The steps to create the distributed application using RMI are: 1.Create the FileRemote interface for the RMI server. 2.Create the FileRemoteImpl class that implements the FileRemote interface. 3.Create the RMIFileServer class. 4.Create the RMIFileClient class. 5.Run the application.

Creating Applications Using RMI Lesson 1B / Slide 8 of 19 Network and Distributed Programming in Java Client-Side Callbacks In client-side callbacks: The RMI server invokes the method of the RMI client. The RMI client acts as an RMI server. The RMI client extends the UnicastRemoteObjcet class.

Creating Applications Using RMI Lesson 1B / Slide 9 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) Creating an Application using Client-Side Callbacks 1.Create a remote interface for the client 2.Create a remote interface for the server 3.Implement the server interface 4.Implement the client interface 5.Create an RMI server 6.Create an RMI client 7.Run the client and server applications

Creating Applications Using RMI Lesson 1B / Slide 10 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 1.Creating Remote Interface for the Client The code to create a remote interface for the RMI client is: public interface CRemote extends Remote { public void displayValue(String s) throws RemoteException; }

Creating Applications Using RMI Lesson 1B / Slide 11 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 2.Creating Remote Interface for the Server The code to create a remote interface for the RMI server is: public interface SRemote extends Remote { public void registerClient(CRemote c) throws RemoteException; public CRemote getCallback() throws RemoteException; }

Creating Applications Using RMI Lesson 1B / Slide 12 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 3.Implementing the Server Interface The code snippet to implement the server interface is: public class SRemoteImpl extends SRemote {public void registerClient(CRemote c) throws RemoteException { } public CRemote getCallback() throws RemoteException { }

Creating Applications Using RMI Lesson 1B / Slide 13 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 4.Implementing the Client Interface The code snippet to implement the client interface is: public class CRemoteImpl extends CRemote { public void displayvalue(String s) throws RemoteException { }

Creating Applications Using RMI Lesson 1B / Slide 14 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 5.Creating an RMI Server The code snippet to create the RMI server is: public class CallbackServer { public static void main (String args []) throws Exception { SRemote b = new SRemoteImpl(); UnicastRemoteObjcet.exportObjcet(b); Naming.rebind(“callback”, b); }

Creating Applications Using RMI Lesson 1B / Slide 15 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 6.Creating an RMI Client The code snippet to create the RMI client is: public class CallbackClient { public static void main (String args []) throws Exception { CallbackS = (SRemote)Naming.lookup(“rmi:// /callback”); CallbackC = callbackS.getCallback(); UnicastRemoteObjcet.exportObjcet(callbackC); callbackS.registerClient(callbackC); }

Creating Applications Using RMI Lesson 1B / Slide 16 of 19 Network and Distributed Programming in Java Client-Side Callbacks (Contd.) 7.Running the Application The steps to run an RMI application using client-side callbacks are: 1.Compile all the Java source files. javac *.java 2.Generate the stub and skeleton for the RMI server. rmic SRemoteImpl 3.Generate the stub and skeleton for the RMI client. rmic CRemoteImpl 4.Start the RMI registry. start rmiregistry 5.Run the server-side application. java CallbackServer 6.Run the client-side application. java CallbackClient

Creating Applications Using RMI Lesson 1B / Slide 17 of 19 Network and Distributed Programming in Java Demonstration-Implementing a Chat Application Problem Statement Create a chat application using RMI where an RMI server receives a message from one client and sends that message to all other clients.

Creating Applications Using RMI Lesson 1B / Slide 18 of 19 Network and Distributed Programming in Java Demonstration-Implementing a Chat Application (Contd.) Solution The steps to create the chat application using RMI are: 1.Create the ServerRemote interface for the chat server 2.Create the ClientRemote interface for the chat client. 3.Create the ChatServer class that implements the ServerRemote interface. 4.Create the ChatClient class that implements the ClientRemote interface. 5.Run the chat application.

Creating Applications Using RMI Lesson 1B / Slide 19 of 19 Network and Distributed Programming in Java Summary In this lesson, you learned that: You use serialization to convert a set of objects into byte streams. The byte streams can be sent from one JVM to another JVM. When the RMI server calls back a remote method, such as progress feedback, or an alert message to the RMI client, these method calls are called client-side callbacks. The RMI client calls the exportObject() method of java.rmi.server.UnicastRemoteObject class to allow the RMI server to perform client side callbacks.