logging in or signing up RMI - Basics panki007_india Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 1669 Category: Education License: All Rights Reserved Like it (1) Dislike it (0) Added: August 17, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Remote Method Invocation : Remote Method Invocation RMI RMI : 2 RMI The Java Remote Method Invocation (RMI) system allows an object running in one Java Virtual Machine (VM) to invoke methods on an object running in another( remote ) Java VM. RMI provides for remote communication between programs written in the Java programming language RMI Applications : 3 RMI Applications RMI applications are often comprised of two separate programs: a server and a client. A typical server application creates some remote objects, makes references to them accessible, and waits for clients to invoke methods on these remote objects. A typical client application gets a remote reference to one or more remote objects in the server and then invokes methods on them. RMI Applications Contd., : 4 RMI Applications Contd., RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application. Distributed Object Applications : 5 Distributed Object Applications 1. Locate remote objects: An application can register its remote objects with RMI's simple naming facility, the rmiregistry the application can pass and return remote object references as part of its normal operation 2. Communicate with remote objects 3. Load class bytecodes for objects that are passed around: RMI Distributed Application : 6 RMI Distributed Application RMI Architecture : 7 RMI Architecture It consist of three layers The stubs / skeletons Remote reference Transport Layer When a client invokes a remote method request , it starts at the top with the stub on the client side. RMI Architecture : 8 RMI Architecture Application Application RMI Client Stubs RRL Transport Layer RMI Server Skeleton RRL Transport Layer Virtual Connection Network Connection Advantages : 9 Advantages One of the central and unique features of RMI is its ability to download the bytecodes (or simply code) of an object's class if the class is not defined in the receiver's virtual machine . RMI passes objects by their true type, so the behavior of those objects is not changed when they are sent to another virtual machine. This allows new types to be introduced into a remote virtual machine, thus extending the behavior of an application dynamically. Remote Interfaces, Objects, and Methods : 10 Remote Interfaces, Objects, and Methods A distributed application built using Java RMI is made up of interfaces and classes. The interfaces define methods, and the classes implement the methods defined in the interfaces and, perhaps, define additional methods as well. In a distributed application some of the implementations are assumed to reside in different virtual machines. Objects that have methods that can be called across virtual machines are remote objects. Remote Object Characteristics : 11 Remote Object Characteristics An object becomes remote by implementing a remote interface which has the following characteristics. A remote interface extends the interface java.rmi.Remote. Each method of the interface declares java.rmi.RemoteException in its throws clause, in addition to any application-specific exceptions. Stubs for RMI : 12 Stubs for RMI RMI treats a remote object differently from a non remote object when the object is passed from one virtual machine to another. Rather than making a copy of the implementation object in the receiving virtual machine, RMI passes a remote stub for a remote object. The stub acts as the local representative, or proxy, for the remote object and basically is, to the caller, the remote reference. Stubs for RMI : 13 Stubs for RMI The caller invokes a method on the local stub, which is responsible for carrying out the method call on the remote object. A stub for a remote object implements the same set of remote interfaces that the remote object implements. This allows a stub to be cast to any of the interfaces that the remote object implements. Slide 14: 14 However, this also means that only those methods defined in a remote interface are available to be called in the receiving virtual machine. Marshalling It is the process of assembling and disassembling parameters to and from remote objects and methods Remote Reference Layer : 15 Remote Reference Layer This is responsible for maintaining an independent reference protocol that is not specific to any stub or skeleton. The RRL deals with the lower level transport interface and is responsible for providing a stream to the stub / skeleton layer. The RRL uses a server - side and a client - side component to communicate via the transport layer. The communication between client and server side components is handled by Transport layer. The Transport Layer : 16 The Transport Layer The transport layer consists of 4 abstractions An endpoint used to reference the address space that contains the JVM A channel is a pathway between two address spaces. A connection is an abstraction for transferring data( arguments and return values ) between the client and server. The transport abstraction is responsible for setting up a channel between a local address space and a remote end point . This is also responsible for accepting incoming connections to the address space containing abstraction. The Transport Layer Contd., : 17 The Transport Layer Contd., The transport layer sets up connections , manages existing connections and handles remote objects residing in its address space. When the transport layer receives a request from the client - side RRL , it locates the RMI server for the remote object that is being requested. Then the transport layer establishes a socket connection to the server. Next the transport layer passes the established connection to the client - side RRL and adds a reference to the remote object to the internal table . Steps in Creating an application that accesses remote objects : 18 Steps in Creating an application that accesses remote objects 1. Define Interfaces for the remote classes. 2. Create and compile implementation classes for the remote classes. 3. Create stub and skeleton classes using rmic . 4. Create and compile a server application. 5. Start the RMI registry and the server application. 6. Create and compile a client program to access the remote objects. 7. Test the Clients. java.rmi : 19 java.rmi The java.rmi package contains the core interfaces and classes that define the functionality of Java RMI system . Every remote class must be described by an interface. The Client - side stubs implement these interfaces. The stub classes are created using the rmic utility. rmic requirements : 20 rmic requirements The rmic has the following requirements . The interfaces must be public . The interfaces must extend the Remote interface Each method must throw RemoteException The stub and implementation code must reside in a package. You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
RMI - Basics panki007_india Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 1669 Category: Education License: All Rights Reserved Like it (1) Dislike it (0) Added: August 17, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Remote Method Invocation : Remote Method Invocation RMI RMI : 2 RMI The Java Remote Method Invocation (RMI) system allows an object running in one Java Virtual Machine (VM) to invoke methods on an object running in another( remote ) Java VM. RMI provides for remote communication between programs written in the Java programming language RMI Applications : 3 RMI Applications RMI applications are often comprised of two separate programs: a server and a client. A typical server application creates some remote objects, makes references to them accessible, and waits for clients to invoke methods on these remote objects. A typical client application gets a remote reference to one or more remote objects in the server and then invokes methods on them. RMI Applications Contd., : 4 RMI Applications Contd., RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application. Distributed Object Applications : 5 Distributed Object Applications 1. Locate remote objects: An application can register its remote objects with RMI's simple naming facility, the rmiregistry the application can pass and return remote object references as part of its normal operation 2. Communicate with remote objects 3. Load class bytecodes for objects that are passed around: RMI Distributed Application : 6 RMI Distributed Application RMI Architecture : 7 RMI Architecture It consist of three layers The stubs / skeletons Remote reference Transport Layer When a client invokes a remote method request , it starts at the top with the stub on the client side. RMI Architecture : 8 RMI Architecture Application Application RMI Client Stubs RRL Transport Layer RMI Server Skeleton RRL Transport Layer Virtual Connection Network Connection Advantages : 9 Advantages One of the central and unique features of RMI is its ability to download the bytecodes (or simply code) of an object's class if the class is not defined in the receiver's virtual machine . RMI passes objects by their true type, so the behavior of those objects is not changed when they are sent to another virtual machine. This allows new types to be introduced into a remote virtual machine, thus extending the behavior of an application dynamically. Remote Interfaces, Objects, and Methods : 10 Remote Interfaces, Objects, and Methods A distributed application built using Java RMI is made up of interfaces and classes. The interfaces define methods, and the classes implement the methods defined in the interfaces and, perhaps, define additional methods as well. In a distributed application some of the implementations are assumed to reside in different virtual machines. Objects that have methods that can be called across virtual machines are remote objects. Remote Object Characteristics : 11 Remote Object Characteristics An object becomes remote by implementing a remote interface which has the following characteristics. A remote interface extends the interface java.rmi.Remote. Each method of the interface declares java.rmi.RemoteException in its throws clause, in addition to any application-specific exceptions. Stubs for RMI : 12 Stubs for RMI RMI treats a remote object differently from a non remote object when the object is passed from one virtual machine to another. Rather than making a copy of the implementation object in the receiving virtual machine, RMI passes a remote stub for a remote object. The stub acts as the local representative, or proxy, for the remote object and basically is, to the caller, the remote reference. Stubs for RMI : 13 Stubs for RMI The caller invokes a method on the local stub, which is responsible for carrying out the method call on the remote object. A stub for a remote object implements the same set of remote interfaces that the remote object implements. This allows a stub to be cast to any of the interfaces that the remote object implements. Slide 14: 14 However, this also means that only those methods defined in a remote interface are available to be called in the receiving virtual machine. Marshalling It is the process of assembling and disassembling parameters to and from remote objects and methods Remote Reference Layer : 15 Remote Reference Layer This is responsible for maintaining an independent reference protocol that is not specific to any stub or skeleton. The RRL deals with the lower level transport interface and is responsible for providing a stream to the stub / skeleton layer. The RRL uses a server - side and a client - side component to communicate via the transport layer. The communication between client and server side components is handled by Transport layer. The Transport Layer : 16 The Transport Layer The transport layer consists of 4 abstractions An endpoint used to reference the address space that contains the JVM A channel is a pathway between two address spaces. A connection is an abstraction for transferring data( arguments and return values ) between the client and server. The transport abstraction is responsible for setting up a channel between a local address space and a remote end point . This is also responsible for accepting incoming connections to the address space containing abstraction. The Transport Layer Contd., : 17 The Transport Layer Contd., The transport layer sets up connections , manages existing connections and handles remote objects residing in its address space. When the transport layer receives a request from the client - side RRL , it locates the RMI server for the remote object that is being requested. Then the transport layer establishes a socket connection to the server. Next the transport layer passes the established connection to the client - side RRL and adds a reference to the remote object to the internal table . Steps in Creating an application that accesses remote objects : 18 Steps in Creating an application that accesses remote objects 1. Define Interfaces for the remote classes. 2. Create and compile implementation classes for the remote classes. 3. Create stub and skeleton classes using rmic . 4. Create and compile a server application. 5. Start the RMI registry and the server application. 6. Create and compile a client program to access the remote objects. 7. Test the Clients. java.rmi : 19 java.rmi The java.rmi package contains the core interfaces and classes that define the functionality of Java RMI system . Every remote class must be described by an interface. The Client - side stubs implement these interfaces. The stub classes are created using the rmic utility. rmic requirements : 20 rmic requirements The rmic has the following requirements . The interfaces must be public . The interfaces must extend the Remote interface Each method must throw RemoteException The stub and implementation code must reside in a package.