"Advance Java programming" refers to the practice of utilizing advanced concepts and features of the Java programming language to develop complex and sophisticated applications. This includes topics such as multithreading, networking, database connectivity, GUI programming, web development, and mor...
Unit 8: RMI and CORBA (3 Hrs.)
Introduction of RMI:
RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in
one system (JVM) to access/invoke an object running on another JVM. RMI is used to build
distributed applications; it provides remote communication between Java programs. It is
provided in the package java.rmi.
Remote Method Invocation (RMI) is an application programming interface (API) in
the Java programming language and development environment. It allows objects on one
computer or Java Virtual Machine (JVM) to interact with objects running on a different JVM in a
distributed network. Another way to say this is that RMI provides a way to create distributed
Java applications through simple method calls.
RMI Architecture:
In an RMI application, we write two programs, a server program (resides on the server) and
a client program (resides on the client).
Inside the server program, a remote object is created and reference of that object is made
available for the client (using the registry).
The client program requests the remote objects on the server and tries to invoke its
methods.
The RMI architecture consists of four layers:
Notes by Santosh Bhatt Page 1
, 1. Application Layer: This layer is the actual systems i.e. client and server which are involved
in communication. The java program on the client side communicates with the java program on
the server-side.
2. Proxy Layer: This layer contains the client stub and server skeleton objects.
Stub is an object that resides on the client machine and it acts as a proxy for the remote
object. It is like a gateway for the client program. When the client calls on the stub
object, the stub forwards this request to a remote object (Skeleton) via RMI
infrastructure which is then executed on the server.
The server object which resides in a server machine is known as Skeleton. Stub
communicates with server application with the help of an intermediate Skeleton object.
The responsibility of the skeleton object is to send parameters to method implementation
and send the return values back to the client.
3. Remote Reference Layer: This layer is responsible to maintain the session during the method
call. i.e. It manages the references made by the client to the remote server object. This layer is
also responsible for handling duplicated objects. The invocation semantics of the RMI
connection is defined and supported by this layer.
4. Transport Layer: The transport layer is responsible for setting up communication between
the two machines. This layer uses standard TCP/IP protocol for connection. The actual
transportation of data is performed through this layer.
Steps of Writing RMI Programs:
Below is the 6 - six steps to write the RMI program in java.
Creation of remote interface
Provide the implementation of the remote interface
Compile the implementation class and create the stub and skeleton objects using the rmic
tool
Start the registry service by rmi registry tool
Write and start the remote application
Write and start the client application
1. First Define the java remote interface
First thing to do is create an interface to describe the techniques that can be invoked by distant
clients. This interface should extend the Remote interface and throw the RemoteException inside
the interface using the method prototype.
// Creating a Search interface
import java.rmi.*;
public interface MySearch extends Remote
{
// Declaring the method prototype
Notes by Santosh Bhatt Page 2
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller santoshbhatt. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.99. You're not tied to anything after your purchase.