GROUP MEMBERS
MD. SHAHRIAR ANWAR (09.02.04.088)
NASHIYED ARAFUL HAQUE (09.02.04.078)
Remote Method Invocation
(RMI)
Overview
 Introduction of RMI
 Uses of RMI
 Interfaces and Classes
 RMI Architecture
 RMI Application Overview
 Remo...
What is RMI?
 Remote Method Invocation (RMI), allows one host
to run programs on another host that is running a
program o...
Why We Need RMI?
Let’s think a scenario -
 Suppose you’re an owner of a large company. You’re
company have branches all o...
Interface and Classes in Package java.rmi
RemoteObject
RemoteServer
Activatable UnicastRemoteobject
Remote
Interface Class...
RMI Architecture
 The server must first bind its name to
the registry
 The client lookup the server name in
the registry...
The Stubs and Skeleton
RMI Client Stubs Skeleton RMI Server
Call
Return
 A client invokes a remote method, the call is fi...
RMI Application Overview
 RMI applications consist of two separate programs, a
server and a client.
 Server program crea...
Remote Object
 An object with methods that may be invoked from
a different Java virtual machine than the one
running on a...
Remote interfaces, Objects and Methods
Remote Object
 Objects with methods that can be invoked across
Java virtual machin...
Remote Interface Explained
 Let’s take a sample code snippet
import java.rmi.*;
public interface HomeWork extends Remote ...
Remote Interface Explained (cont…)
 Java program running on your workstation (e.g. JVM on
you.com) could look up the curr...
A Short RMI Example
 What this program does?
 This is a simple program which pass two integers to Server
through RMI and...
SumInterface.java
SumImpl.java
RMIServer.java
RMIClient.java
Compiling and Running from Terminal
Compiling …
After compiling following classes are generated …
Generating Stubs and Starting RMI Registry
Generating Stubs and Starting RMI Registry …
After generating Stubs directory l...
Starting Server and Client
Open a new Terminal and start the server …
Open another new Terminal and start the Client … (Yo...
References
 http://www.javacoffeebreak.com/articles/javarmi/ja
varmi.html
 http://docs.oracle.com/javase/7/docs/platform...
Remote method invocation
Upcoming SlideShare
Loading in …5
×

Remote method invocation

467 views
384 views

Published on

It's a presentation on Java Remote Method Invocation.

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
467
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
28
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Slide dekhebolleihobe
  • Remote method invocation

    1. 1. GROUP MEMBERS MD. SHAHRIAR ANWAR (09.02.04.088) NASHIYED ARAFUL HAQUE (09.02.04.078) Remote Method Invocation (RMI)
    2. 2. Overview  Introduction of RMI  Uses of RMI  Interfaces and Classes  RMI Architecture  RMI Application Overview  Remote Object and Interface Explained  A short demonstration of RMI application
    3. 3. What is RMI?  Remote Method Invocation (RMI), allows one host to run programs on another host that is running a program on a remote host from a local machine. In Brief:  It’s a core JAVA API  Enables programs calling methods in objects running on different host even though both program exists in two physically different hosts.
    4. 4. Why We Need RMI? Let’s think a scenario -  Suppose you’re an owner of a large company. You’re company have branches all over the country.  Now if one of your company branch need to get services/data from head office, how they’ll do it? Answer is : RMI We’ll show you how that work and what it does
    5. 5. Interface and Classes in Package java.rmi RemoteObject RemoteServer Activatable UnicastRemoteobject Remote Interface Classes
    6. 6. RMI Architecture  The server must first bind its name to the registry  The client lookup the server name in the registry to establish remote references.  The Stub serializing the parameters to skeleton, the skeleton invoking the remote method and serializing the result back to the stub.
    7. 7. The Stubs and Skeleton RMI Client Stubs Skeleton RMI Server Call Return  A client invokes a remote method, the call is first forwarded to stub.  The stub is responsible for sending the remote call over to the serverside skeleton  The stub opening a socket to the remote server, marshaling the object parameters and forwarding the data stream to the skeleton.  A skeleton contains a method that receives the remote calls, unmarshals the parameters, and invokes the actual remote object implementation.
    8. 8. RMI Application Overview  RMI applications consist of two separate programs, a server and a client.  Server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects.  Client program obtains a remote reference to one or more remote objects on a server and then invokes methods on them.
    9. 9. Remote Object  An object with methods that may be invoked from a different Java virtual machine than the one running on a different computer.  Each remote object implements one or more remote interfaces that declare which methods of the remote object can be invoked by the foreign system.
    10. 10. Remote interfaces, Objects and Methods Remote Object  Objects with methods that can be invoked across Java virtual machines are called remote objects  Remote Object implements Remote Interface  A Remote Interface extends java.rmi.Remote interface  Each method of the interface declares java.rmi.RemoteException in its throws clause
    11. 11. Remote Interface Explained  Let’s take a sample code snippet import java.rmi.*; public interface HomeWork extends Remote { public String giveMeYourHomeWork( ) throws RemoteException; }
    12. 12. Remote Interface Explained (cont…)  Java program running on your workstation (e.g. JVM on you.com) could look up the current HomeWork object in the RMI registry at remote virtual machine (e.g. JVM on yourfriend.com).  The registry would send it a reference to the object running in remote (yourfriend.com 's) virtual machine.  Your program could then use this reference to invoke the giveMeYourHomeWork( ) method.  The giveMeYourHomeWork( ) method would execute on the server in remote machine not on your local machine. However, it would return the String value back to your local program running in your local machine.
    13. 13. A Short RMI Example  What this program does?  This is a simple program which pass two integers to Server through RMI and invoke remote method from Client to calculate their Sum.  There are 3 classes and 1 interface  SumInterface  SumImpl  RMIServer  RMIClient
    14. 14. SumInterface.java
    15. 15. SumImpl.java
    16. 16. RMIServer.java
    17. 17. RMIClient.java
    18. 18. Compiling and Running from Terminal Compiling … After compiling following classes are generated …
    19. 19. Generating Stubs and Starting RMI Registry Generating Stubs and Starting RMI Registry … After generating Stubs directory looks like …
    20. 20. Starting Server and Client Open a new Terminal and start the server … Open another new Terminal and start the Client … (You’ll get result immediately)
    21. 21. References  http://www.javacoffeebreak.com/articles/javarmi/ja varmi.html  http://docs.oracle.com/javase/7/docs/platform/rmi /spec/rmi-arch2.html  http://en.wikipedia.org/wiki/Java_remote_method _invocation  http://docs.oracle.com/javase/7/docs/api/java/rmi/ package-summary.html

    ×