LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
RMI Varun SainiYing Chen. What is RMI? RMI is the action of invoking a method of a remote interface on a remote object. It is used to develop applications.
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.
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
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.
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.
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
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.
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.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
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.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
Creating Applications Using RMI Lesson 1B / Slide 1 of 19 Network and Distributed Programming in Java Pre-assessment Questions 1.Which of the following.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
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)
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.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Remote Method Invocation (RMI)
Broker in practice: Middleware
Remote Method Invocation
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Chapter 40 Remote Method Invocation
Creating a Distributed System with RMI
Remote method invocation (RMI)
Remote Method Invocation
Creating a Distributed System with RMI
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
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:

LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007

LAB 1CSIS04022 Lab One Organization RMI Introduction A Simple Example Recap of RMI Components Assignment One Overview System Architecture Remarks Lab Exercise on RMI Reference

LAB 1CSIS04023 Introduction to RMI Often consists of 2 separate programs: a server and a client Provide the mechanism by which the server and the client communicate and pass information back and forth. Make the communication like making a method call inside a single process.

LAB 1CSIS04024 A Simple RMI Example Skeleton Stub Client Server Client looks up the remote object by its name from the server’s registry and obtains a remote reference (i.e. the stub) of it. Network The stub either creates a socket connection to the skeleton on the server or reuses a pre-existing connection. It marshals all the information associated to the method call, with name of method and arguments and sends to the skeleton. The skeleton de-marshals the data and makes the method call on the actual server object. The skeleton gets the return value back from the server object, marshals the return value and sends to the stub. RMIRegistry Server creates a remote object, registers the service to RMIRegistry and passes the object reference to the registry Client invokes a method on the stub The stub de- marshals the return value and returns it to the client.

LAB 1CSIS04025 Recap of RMI Components RMIRegistry Runs on a central server and functions like a phone book Maps logical names to actual servers so that client programs can easily locate and use appropriate server applications Stub Acts as the local representative for the remote object Implements the same remote interface as the remote object Maintains a socket connection to the remote object’s JVM automatically Responsible for marshalling and de-marshalling data on the client side

LAB 1CSIS04026 Skeleton A server-side object responsible for maintaining network connections with the stub marshalling and de-marshaling data on the server side Stubs and Skeletons are generated from the implementation class files by a command-line application called rmic

LAB 1CSIS04027 Assignment One Overview

LAB 1CSIS04028 A Simple File Hosting System OnlineDrive v1.0 Offer a sort of "network storage" for personal backup, file access or file distribution Support three sharing options Personal Can be viewed and downloaded by the file owner only. Group Public In Assignment One, you only need to develop the GUI and the simplest mode of sharing: Personal. You are required to use RMI to handle ALL communications between server and clients.

LAB 1CSIS04029 GUI From Java.Swing: - JFrame - JSplitPane - JTree - JTextArea - JButton - JLabel …

LAB 1CSIS System Architecture OnlineDriveServer.java -Server interface that describes the behavior of the server OnlineDriveServerImp.java - Class that implement the server functions OnlineDriveClientImp.java - Client application that maintains the Chatroom functionalilities implements Server side componentsClient side component

LAB 1CSIS Remarks Class names to be used… Server class: OnlineDriveServerImp.java Client class: OnlineDriveClientImp.java RMIC for server To generate stubs and skeletons Make sure… your server can be started by > java OnlineDriveServerImp your client can be started by > java OnlineDriveClientImp

LAB 1CSIS Lab Exercise on RMI CountServer

LAB 1CSIS CountServer Overview A RMI application consists of a RMI server and a client swing application. Client inputs a message and sends to the server. Server receives the message, count the number of characters and return the count to the client. Client displays the count on the GUI.

LAB 1CSIS System Architecture CountServerImp.java CountServer.java CountClientImp.java extends CountServer interface that describes the behavior of the server Class that implements the server functions Swing client application that captures user’s input, sends to the server and displays server’s reply to the GUI.

LAB 1CSIS CountServer.java (Interface class of the server) … import java.rmi.*; public interface CountServer extends Remote { public int countMsg(String msg) throws RemoteException; } Return types of the remote method Exception thrown by RMI to signal that something unforeseen has happened at the network level

LAB 1CSIS CountServerImp.java (Implementation class of the server) import java.rmi.*; import java.rmi.server.*; public class CountServerImp extends UnicastRemoteObject implements CountServer { public int countMsg(String msg) throws RemoteException { return msg.length(); } Automatically relates the instance into the RMI runtime and listens for remote method calls. Return the string to the remote client

LAB 1CSIS public static void main( String args[] ) { … CountServerImp server = new CountServerImp(); Naming.rebind( "//localhost/CountServer",server ); … } Create a CountServer object to provide services for clients Static method of the naming registry class to bind the server object to the specified host with the name ‘CountServer’ CountServerImp.java(2) (Implementation class of the server)

LAB 1CSIS CountClientImp.java (Implementation class of the client) import java.rmi.*; … public class CountClientImp extends JFrame { … public CountClientImp( String hostname ) { serverLookup(); … } private void serverLookup(){ try{ server = (CountServer)Naming.lookup( "//localhost/CountServer" ); } catch(Exception e){ System.err.println(e); } Swing Application Call the static method of the Naming class to look up the remote server on the requested host and the specified server name Get a handle to the remote object

LAB 1CSIS JButton sendButton = new JButton(“Count Message"); … sendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ sendMsgToServer(); } … private void sendMsgToServer(){ String msg = tArea.getText(); try{ Integer count = (Integer) server.countMsg(msg); msgCount = Integer.toString(count); tField.setText(msgCount); }catch(RemoteException re) { System.err.println(re); } … Remotely invoke the RMI Server and send the message to it Register the action listener for send button CountClientImp.java(2) (Implementation class of the client)

LAB 1CSIS public static void main( String args[] ) { … try{ CountClientImp client = new CountClientImp(); }catch( Exception e ){ e.printStackTrace(); } Create a CountClientImp object CountClientImp.java (3) (Implementation class of the client)

LAB 1CSIS Lab Exercise - How to start Download the lab1.zip from the course homepage Compile the files by javac *.java Generate stub and skeleton rmic CountServerImp Start the RMI registry (keep on running) rmiregistry

LAB 1CSIS Lab Exercise - How to start(2) Start the RMI Server in another command prompt java CountServerImp Start the client in another command prompt and connect to the server java CountClientImp

LAB 1CSIS Lab Exercise - How to start(3) Test the application Type a message in the text area on the Client GUI, click “Count Message”. Check if the count is returned and displayed on the GUI.

LAB 1CSIS Reference (1) Swing (for the GUI) in Java Tutorial Getting start with Swing html Layout Manager x.html Event Listener x.html

LAB 1CSIS Reference (2) RMI in Java Tutorial erview.html RMI course from jGuru eTraining/rmi/RMI.html#JavaRMIArchitecture