bernielewis-rmi
TRANSCRIPT
-
8/8/2019 BernieLewis-RMI
1/18
Remote Method Invocation in Java
Bennie Lewis
EEL 6897
-
8/8/2019 BernieLewis-RMI
2/18
AGENDA
Introduction
What is RMI
The Goals of RMI
The RMI system architecture
How RMI works
Distributed garbage collection
Security
Conclusion
Questions
-
8/8/2019 BernieLewis-RMI
3/18
IntroductionRMI
Javas RMI is an alternative to low level sockets. A
remote method invocation is a form of the RPC that isavailable on other systems. Instead of creating objects
on local machines you create some of the objects onother machines an you communicate with those
objects as you would normally would with local objects
-
8/8/2019 BernieLewis-RMI
4/18
WHAT IS RMI
RMI is a core package of the JDK 1.1 and above that canbe used to develop distributed application.
It enables software developers to write distributed
applications in which the methods of remote objects canbe invoked from other JVMs
-
8/8/2019 BernieLewis-RMI
5/18
The Goals of RMI
Support seamless remote invocations on objects in
different java virtual machines.
Support callbacks from servers to clients.
Integrate the distributed object model into the Java
language in a natural way while retaining most of the Java
languages object semantics. Make differences between the distributed object model
and the local java object model apparent.
Make writing reliable distributed applications as simple aspossible.
Preserve the safety provided by the java sun real timeenvironment.
-
8/8/2019 BernieLewis-RMI
6/18
The RMI system architecture
The RMI system is built in three layers
The stub/skeleton layer
The remote reference layer
The transport layer
-
8/8/2019 BernieLewis-RMI
7/18
The stub/skeleton layer
The stub/skeleton layer is the interface between theapplication layer and he rest of the system. When a serverapplication is developed. Stubs and skeletons are
generated using the RMI rmic compiler, which generatesproxy classes from the servers bytecodes The stub/skeleton
layer transmits data to the remote reference layer via theabstraction of marshal streams which use objects
serialization. Therefore. This layer does not deal with thespecifics of any transport.
-
8/8/2019 BernieLewis-RMI
8/18
The remote reference layer
The remote reference layer is a middle layer between thestub/skeleton layer and the transport layer. This layer isresponsible for providing the ability to support varying
remote reference or invocation protocols independent ofthe client stubs and server skeletons.
-
8/8/2019 BernieLewis-RMI
9/18
The Transport layer
The transport layer is the low-layer that ships marshalstreams between different address spaces. The transportlayer is responsible for setting up connections to remote
address spaces, managing connections, listening forincoming calls, maintaining a table of remote objects that
reside in the same address space, setting up aconnections to this dispatcher.
-
8/8/2019 BernieLewis-RMI
10/18
How RMI works
When a client invokes an object implementation from theserver the three layers of RMI come in the play. The mostimportant layer to the programmer is the stub/skeleton
layer. RMI comes with an rmic compiler that generatesstubs and skeletons from user defined remote interfaces.
Basically, stubs are client proxies and skeletons are server-side entities. Stubs will allow clients to communicate with
the other layers of the system. This is done automatically asyou will have to in inherit from RMI classes.
-
8/8/2019 BernieLewis-RMI
11/18
Example package RMI.hello;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager; import java.rmi.server.UnicastRemoteObject;
public class RMIserver extends UnicastRemoteObject implements Hello
{
public RMIserver() throws RemoteException
{
super();
}
public String sayHello()
{
return "Bennie Lewis Hello World!";
}
public static void main(String args[])
{
if(System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
try
{
RMIserver obj = new RMIserver();
Naming.rebind("//localhost/HelloServer",obj);
System.out.println("HelloServer bound in registry");
}
catch(Exception e)
{
System.out.println("RMIserver err: " + e.getMessage());
e.printStackTrace();
}
}
}
-
8/8/2019 BernieLewis-RMI
12/18
Example cont. package RMI.hello;
import java.applet.Applet;
import java.awt.Graphics;
import java.rmi.Naming;
import java.rmi.RemoteException;
public class RMIclient extends Applet
{
String message = "blank";
Hello obj = null;
public void init()
{
try {
obj = (Hello)Naming.lookup("//" + getCodeBase().getHost() + "/HelloServer");
message = obj.sayHello();
}
catch(Exception e)
{
System.out.println("HelloApplet exception:" + e.getMessage());
e.printStackTrace();
}
} public void paint(Graphics g)
{
g.drawString(message,25,50);
}
}
-
8/8/2019 BernieLewis-RMI
13/18
Example cont.
package RMI.hello;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote
{ String sayHello() throws RemoteException;
}
-
8/8/2019 BernieLewis-RMI
14/18
Distributed Garbage Collection
When stand-alone applications are developed using java,objects that are no longer referenced by any client areautomatically deleted. This is a desirable feature when
developing distributed applications. The RMI systemprovides a distributed garbage collector that
automatically deletes remote objects that are no longerreferenced by any client.
-
8/8/2019 BernieLewis-RMI
15/18
Security
There are a number of security issues that you should beaware of when developing mission-critical systems in RMI.
There is no authentication; a client just requests and object
(stub), and the server supplies it. Subsequentcommunication is assumed to b from the same client.
There is no access control to the objects
There are no security checks on the RMI registry itself; anycallerIs allowed to make request.
There is no version control between the stubs and the
skeletons, making it possible for client to use a down-levelstub to access a more recent skeleton breaking release-to-
release binary compatibility
-
8/8/2019 BernieLewis-RMI
16/18
Conclusion RMI is an alternative to low level sockets
RMI is a core package of the JDK 1.1 and above that canbe used to develop distributed application.
The RMI system is built in three layers The stub/skeleton
layer, The remote reference layer, The transport layer
-
8/8/2019 BernieLewis-RMI
17/18
References
Qusay H. Mahmoud,(1999). Distributed Programming withJava. Greenwich CT: Manning Publications Co.
http://java.sun.com/javase/technologies/core/basic/rmi/i
ndex.jsp
-
8/8/2019 BernieLewis-RMI
18/18
Questions