160 likes | 341 Views
RMI. Russell Johnston Communications II. What is RMI?. Remote Method Invocation. Overview. Why use RMI? What does RMI do for you? What else can RMI do for you? How does RMI compare to RPC? How does RMI work? How do you implement RMI? Applications of RMI. Why use RMI?.
E N D
RMI Russell Johnston Communications II
What is RMI? • Remote Method Invocation
Overview • Why use RMI? • What does RMI do for you? • What else can RMI do for you? • How does RMI compare to RPC? • How does RMI work? • How do you implement RMI? • Applications of RMI
Why use RMI? • RMI makes IPC and Client/Server programming simpler • RMI makes distributed and parallel computing simpler • Platform independence
What does RMI do for you? • Data marshalling and external representation • Transparent parameter passing • When combined with JNDI, true location transparency • When combined with CORBA, language independence and connectivity to legacy systems
What else can RMI do for you? • Distributed garbage collection • Security (authentication support) • Activation (transparent object disk swapping / memory paging)
How does RMI compare to RPC? • Object oriented vs. procedure oriented • Registry vs. portmapper • URL vs. program number • Rmic vs. rpcgen • Interface class vs. *.x file • Serialization vs. XDR • CORBA vs. Versioning
How does RMI work? • Architecture • Data marshalling and external representation • Transparent parameter passing
Architecture • Client (interface) • Stub • Network • Skeleton • Remote object
Data marshalling and external representation • Object serialization • Primitive data types are automatically serializable • Objects implement java.lang.Serializable • Transient • Size • Resources that need to be reconstructed • Insecure data • Recursion • Java data representation is portable by design
RMI Transparent Parameter Passing • Copy-by-value (serialization) • Copy-by-reference (reference to another remote object)
How do you implement RMI? • Create an interface which extends java.rmi.Remote. Every method in the interface must throw java.rmi.RemoteException • Create the remote object which implements the interface and extends java.rmi.server.UnicastRemoteObject
Implementation (cont.) • Generate the stub and skeleton via rmic. • Create the server which will bind the RMI service the registry • Create the client which will get the remote object via Naming.lookup() and manipulate the remote object via the interface
Implementation (cont.) • Run • Start the registry via rmiregistry • Start the server • Start the client
Applications of RMI • EJB • EJB Object • Home Object • Parallel distributed GA