1 / 18

JAVA RMI Java Remote Method Invocation

JAVA RMI Java Remote Method Invocation. Prepared by / Nael Alian University Of Palestine. Remote Method Invocation. Remote method invocation allows applications to call object methods located remotely. sharing resources and processing load across systems.

topaz
Download Presentation

JAVA RMI Java Remote Method Invocation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA RMIJava Remote Method Invocation Prepared by / Nael Alian University Of Palestine

  2. Remote Method Invocation • Remote method invocation allows applications to call object methods located remotely. • sharing resources and processing load across systems. Unlike other systems for remote execution which require that only simple data types or defined structures be passed to and from methods

  3. Remote Method Invocation • RMI allows any Java object type to be used - even if the client or server has never encountered it before. • RMI allows both client and server to dynamically load new object types as required.

  4. Overview • Remote Method Invocation (RMI) facilitates object function calls between Java Virtual Machines (JVMs). • JVMs can be located on separate computers - yet one. • JVM can invoke methods belonging to an object stored in another JVM.

  5. Overview • Methods can even pass objects that a foreign virtual machine has never encountered before, allowing dynamic loading of new classes as required. This is a powerful feature!

  6. Consider the follow scenario : • Developer A writes a service that performs some useful function. He regularly updates this service, adding new features and improving existing ones. • DeveloperB wishes to use the service provided by DeveloperA. However, it's inconvenient for A to supply B with an update every time.

  7. So how we can solve this problem? • Java RMI provides a very easy solution! Since RMI can dynamically load new classes, Developer B can let RMI handle updates automatically for him. Developer A places the new classes in a web directory, where RMI can fetch the new updates as they are required.

  8. RMI Figure 1 - Connections made when client uses RMI

  9. RMI • Figure 1 shows the connections made by the client when using RMI. Firstly, the client must contact an RMI registry, and request the name of the service. Developer B won't know the exact location of the RMI service, but he knows enough to contact Developer A's registry. This will point him in the direction of the service he wants to call..

  10. RMI • Developer A's service changes regularly, so Developer B doesn't have a copy of the class. • Not to worry, because the client automatically fetches the new subclass from a webserver where the two developers share classes. • The new class is loaded into memory, and the client is ready to use the new class. This happens transparently for Developer B - no extra code need to be written to fetch the class.

  11. Remote and Local Method Invocations C Local invocation Local invocation A A Remote invocation Remote invocation B E D Local invocation

  12. Idea • Distribute objects across different machines to take advantage of hardware and dedicated software . • Developer builds network service and install it on specified machine . • User requests an instance of class using URL syntax .

  13. Idea • User uses object as though it were a regular, local object • Network connections happen automatically behind the scenes. • Java “Serialization” lets you pass complex data structures over the network without writing code to pares and reconstruct them

  14. RMI Operations • Stub Operation • Package identifier of remote object. • Package method identifier. • Marshall parameters. • Send package to server skeleton. • Skeleton Operation • Unmarshall Parameters. • Calls return value or exception • Marshall method return • Send package to client stub

  15. Steps for creating a RMI Application • Implementation: • Define the remote interface • Implement the remote interface • Implement the server • Implement the client • Deployment: • Start the Java RMI registry • Start the server • Run the client

  16. Defining the Remote Interface • Extends the interface java.rmi.Remote. • Methods must throw java.rmi.RemoteException (communication failure or a protocol error) • Arguments and return types must be one of: • primitive data type • a remote object • an Object that implements java.io.Serializable • Many of the core classes, including the classes in the packages • java.lang and java.util, implement the Serializable interface

  17. Next ….. Example Code

More Related