Knowledge Byte In this section, you will learn about:

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Remote Method Invocation
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
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.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
Introduction to Remote Method Invocation (RMI)
Systems Architecture, Fourth Edition1 Internet and Distributed Application Services Chapter 13.
Beyond DHTML So far we have seen and used: CGI programs (using Perl ) and SSI on server side Java Script, VB Script, CSS and DOM on client side. For some.
1 Java Programming II Java Network II (Distributed Objects in Java)
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
+ A Short Java RMI Tutorial Usman Saleem
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.
CORBA/IDL Common Object Resource Broker Architecture (CORBA) Interface Definition Language (IDL) Object Management Group (OMG) ( Specification.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
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 remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Collaborate Lesson 4C / Slide 1 of 22 Collaborate Knowledge Byte In this section, you will learn about: The EJB timer service Message linking in EJB 2.1.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
CORBA Common Object Request Broker Architecture. Basic Architecture A distributed objects architecture. Logically, an object client makes method calls.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
 Common Object Request Broker Architecture  An industry standard developed by OMG to help in distributed programming.
Fall 2007cs4251 Distributed Computing Umar Kalim Dept. of Communication Systems Engineering 17/10/2007.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
 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.
Khoa CNTT 1/37 PHẠM VĂN TÍNH   Java RMI (Remote Method Invocation)
CSC 480 Software Engineering Lab 6 – RMI Nov 8, 2002.
CEN6502, Spring Understanding the ORB: Client Side Structure of ORB (fig 4.1) Client requests may be passed to ORB via either SII or DII SII decide.
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 Objects. Contents I. The Roles of Client and Server II. Remote Method Calls III. The RMI Programming Model IV. Parameters and Return Values.
Remote Method Invocation Internet Computing Workshop Lecture 17.
Java Distributed Computing
Internet and Distributed Application Services
CORBA: An Overview Mojtaba Hosseini.
Java Remote Method Invocation (RMI)
Distributed Computing
Java Distributed Computing
Java Remote Method Invocation (RMI)
Remote Method Invocation
Java RMI CS-328 Internet Programming.
CORBA Alegria Baquero.
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
CORBA Alegria Baquero.
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Creating a Distributed System with RMI
Chapter 40 Remote Method Invocation
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Creating a Distributed System with RMI
Overview of RMI Architecture
Creating a Distributed System with RMI
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Java Remote Method Invocation
Knowledge Byte In this section, you will learn about:
Creating a Distributed System with RMI
Overview of RMI Architecture
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Knowledge Byte In this section, you will learn about: Passing Parameters in RMI RMI over IIOP Introduction to JNDI Collaborate

Passing Parameters in RMI The two methods that enable you to pass parameters to invoke a remote method across a network are: Pass-by-value Pass-by-reference Collaborate

Passing Parameters in RMI (Contd.) Pass-by-value method: Passes a copy of the original data to the remote method. Changes made by the remote method are reflected only in the copy of the original data. The original data values remain unaffected. The following figure shows how to pass parameters using pass-by-value method: Collaborate

Passing Parameters in RMI (Contd.) Pass-by-reference method Passes the original data as parameters to the remote method. Changes made by the remote method are reflected in the original data. The following figure shows passing the parameters using pass-by-reference method: Collaborate

RMI Over IIOP RMI-IIOP: Combines the features of RMI with the interoperability of the IIOP (Internet Inter-ORB Protocol). Enables you to create distributed objects in Java. Allows creating applications that can communicate with Common Object Request Broker Architecture(CORBA). Enables you to pass Java objects between various application components either by value or by reference. Uses two packages: java.rmi javax.rmi Uses two protocols IIOP Genera Inter ORB Protocol (GIOP) Collaborate

RMI Over IIOP (Contd.) You can generate the IIOP stub and skeleton using the -iiop option with the rmic command as shown: rmic -iiop [implementation CLASS file] Creates a distributed application without using the Interface Definition Language (IDL) or mapping with different languages. GIOP: Defines the structure and formats for passing the messages over ORB architectures. Provides seven layers architecture. Enables communication between multiple applications across different platforms. Collaborate

RMI Over IIOP (Contd.) GIOP Architecture Collaborate

Introduction to JNDI Java Naming and Directory Interface (JNDI): Is an Application Program Interface (API) that provides naming and directory services to Java applications. Provides information about the applications, naming services, networks, and end-users. Collaborate

Introduction to JNDI (Contd.) Uses of JNDI in RMI: The RMI registry service provider enables JNDI applications to access remote objects that are registered in the RMI registry. The JNDI service provider binds a naming context to an RMI object. You can access the remote object from any namespace location using the naming context associated with the RMI object. An RMI client does not require the host name or port number of the RMI registry to access the remote object. JNDI environment properties: java.naming.factory.initial java.naming.provider.url java.naming.factory.state java.naming.factory.object Collaborate

Introduction to JNDI (Contd.) Binding the Naming Context to Objects using JNDI Collaborate

Introduction to JNDI (Contd.) JNDI Architecture: Contains the following components: Java Application JNDI API JNDI Naming and Directory Manager JNDI Service Provider Interface (SPI) Collaborate

Introduction to JNDI (Contd.) JNDI Architecture Collaborate

Introduction to JNDI (Contd.) J2EE application server includes the following service providers for naming and directory services: CORBA Lightweight Data Access Protocol (LDAP) RMI Network Information System (NIS) Novell Directory Services (NDS) Domain Name Service (DNS) Collaborate

From the Expert’s Desk In this section, you will learn: Best practice on using SecurityManager class in RMI applications Tip on enhancing performance of RMI calls FAQs on RMI Collaborate

Best Practices Using the SecurityManager Class in RMI Applications The RMI SecurityManager class provides a security manager that: Implements the security policies for the RMI applications. Prevents the unauthenticated user to access the method stored on RMI server. Checks if any security check is currently in progress or not Ensures that a network connection is secure or not Ensures that the dynamic libraries can be linked or not Secures the RMI application from virus attacks. Collaborate

Best Practices Using the SecurityManager Class in RMI Applications (Contd.) You can use the following code snippet to implement the SecurityManger class in an RMI client: System.setSecurityManager(new RMISecurityManager()) You have to create a policy file to assign the security permissions to an RMI client. The policy file is saved as .java.policy file and is stored in the installation directory. You can use the following code snippet to create a policy file: grant { permission java.net.SocketPermission "*:1024-65535", "connect"; }; Collaborate

Tips Enhancing Performance of RMI Calls To enhance the performance of RMI calls, pass the serialize primitive type instead of passing the objects as parameter. Passing the primitive type across the network is much faster than the passing the object as a parameter. To enhance the performance of RMI calls, try minimizing the number of remote method invocations that a client will need to make. For example, If your RMI server application provides information of flight information, define a single remote method that returns all flight information in an object instead of defining remote methods, such as, getFlightName(), getFlightDeparture(), and getFlightArrival() for each information. Collaborate

FAQs How can you modify the default port of the RMI registry? You can modify the default port of the rmi registry by specifying a port at the command prompt. The command to change the default port number is: start rmiregistry 1234 Collaborate

FAQs (Contd.) Can you send a ResultSet object back to the client using RMI? You cannot send the ResultSet object back to the client over RMI communication because the java.sql.ResultSet interface is not a serializable object. But if you want to send the ResultSet object over RMI connection, you need to use the following methods: Extract data from the ResultSet object, encapsulate the data in serializable objects, and pass them through RMI. Wrap the ResultSet object in the remote object and register the remote object to the RMI registry. As a result, a client can access the remote object. Collaborate

FAQs (Contd.) How can you dynamically register a remote object to the RMI registry? You can dynamically register a remote object to the RMI registry with the help of the forName() method of the java.lang.Class package. The Class.forName() method dynamically loads the class, creates the instances of the class, and registers the class objects to the RMI registry. To dynamically register a remote object to the RMI registry, you need a class name and object name. The class name provides a class that you want to instantiate. The object name provides name of the remote object under which you register the instance of the class. Why is the server-side skeleton class not required in J2SDK 1.2 or later versions? The J2SDK1.2 or above version have an additional stub protocol that eliminates the need for a skeleton. Collaborate

FAQs (Contd.) Can a single RMI client connect to multiple RMI servers simultaneously? Yes, a single RMI client can communicate to multiple RMI server, simultaneously. You can use the following code snippet to connect a single RMI client to multiple RMI servers: Server1 ser1 = (Server1)Naming.lookup("rmi://server1.host/server1"); Server2 ser2 = (Server2)Naming.lookup("rmi://server2.host/server2"); Server3 ser3 = (Server3)Naming.lookup("rmi://server3.host/server3"); Collaborate

FAQs (Contd.) How can you programmatically stop an RMI server? When you start an RMI server, a Java thread is automatically started. The Java thread does not stop even if you stop the RMI server. As a result, the RMI server remains persistent until you shutdown the RMI server manually. You provide a remote method, shutdown(), to the RMI server to shutdown the RMI server programmatically. The shutdown() method contains a shutdown thread that is waiting for the notify() method of the Thread class. When the RMI server finishes all the processes, it notifies the shutdown thread. As a result the shutdown() method calls the System.exit(0) method to end the JVM after a specified time delay. The time delay enables you to send a message from server to the clients that the server will go to shut down. Collaborate

FAQs (Contd.) Can you pass an Image object from a remote server to the client using RMI? You can pass the Image object from a remote server to the client using RMI, if you create the image object for the javax.swing.Imageicon class. The class that passes the Image object across the network using RMI must implement the java.io.Serializable interface. Collaborate

Challenge Select the correct option that describes a stub in RMI: A server side proxy that allows RMI communication A client side proxy that allows RMI communication An object of RMI generated helper class that allows RMI communication An object of user defined class that allows RMI communication What is the role of an RMI registry? Which one of the following options specifies the default port of the RMI registry: 1095 1009 1099 1900 Collaborate

Challenge (Contd.) To generate both the stub and skeleton class file for an RMI application use the command _______. What are the JNDI packages that provide the naming and directory services? Collaborate

Solutions to Challenge b. A client side proxy that allows RMI communication The RMI registry acts as a middle-tier that binds a server object with the name space. When a server object is registered with the RMI registry, an authorized RMI client uses the RMI registry to access the remote object stored on RMI server using the name of the server object. c. 1099 rmic JNDI packages consist of various classes and interfaces. These classes and interfaces provide the linkage between Java applications and various naming and directory services. Java provides two JNDI packages for the naming and directory services: javax.naming package javax.naming.directory package Collaborate