Java RMI
Java RMI
Client Server
Socket 2 Server
Application Socket
5 Applicaiton
1 6 4 3
Service
Client
Client Object
We take the responsibility to design the socket and server socket, and
while socket designing the socket, we give the information where the
server socket is running. This results in increase of Application
development time.
Role of Socket Application (proxy)
1) Takes the request from the client.
2) Converts the request into server socket understandable format or
serializable format
3) Gives the request to the server socket
4) Collects the response from the server socket
5) Deserialize the response.
6) Finally gives the response to the client.
Program: //Interface
Public interface MyRemote extends java.rmi.Remote
{
String sayHai() throws java.rmi.RemoteException;
}
//Save it as MyRemote .java
//Implementation Class
How to write Implementation class
1) Here the primary requirement is to make the remote object network
enabled.
Your class should extend java.rmi.server.Unicast.Remoteobject
Then declare a constructor to a class, and the constructor should
throw (java.rmi.RemoteException)
//Registry Application
When we bind the remote object into the rmi registry, we
expect remote object into the rmi registry, rather we get stub
instance.
Java.rmi.Naming.bind(“lalith”,mi);
System.out.println(“Object is binded into RMI registry”);
}
}
//Save as MyRegistry.java
RMI Architecture
Client Server
property
Stub Instance 4 Skeleton
instance stub
7
5
3 8 6
RO
Client
Stub instance