







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Advanced programming prepared for the next
Typology: Lecture notes
1 / 13
This page cannot be seen from the preview
Don't miss anything!








Chapter 5 RMI (Remote Method Invocation) The RMI (Remote Method Invocation) is an API that provides a mechanism to create distributed application in java. The RMI allows an object to invoke methods on an object running in another JVM. The RMI provides remote communication between the applications using two objects stub and skeleton. Understanding stub and skeleton RMI uses stub and skeleton object for communication with the remote object. A remote object is an object whose method can be invoked from another JVM. Let's understand the stub and skeleton objects: stub The stub is an object, acts as a gateway for the client side. All the outgoing requests are routed through it. It resides at the client side and represents the remote object. When the caller invokes method on the stub object, it does the following tasks:
If any application performs these tasks, it can be distributed application. .
java.rmi.Remote) throws java.rmi.RemoteException, java.net.MalformedURLException; object to the new name. public static java.lang.String[] list(java.lang.String) throws java.rmi.RemoteException, java.net.MalformedURLException; It returns an array of the names of the remote objects bound in the registry. In this example, we are binding the remote object by the name sonoo.
Meaningful example of RMI application with database Consider a scenario, there are two applications running in different machines. Let's say MachineA and MachineB, machineA is located in United States and MachineB in India. MachineB want to get list of all the customers of MachineA application. Let's develop the RMI application by following the steps. 1) Create the table First of all, we need to create the table in the database. Here, we are using Oracle10 database.
_4) Compile the class rmic tool and start the registry service by rmiregistry tool
In the Java 2 SDK, an stub protocol was introduced that eliminates the need for skeletons.