Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
14Activity
0 of .
Results for:
No results containing your search query
P. 1
RMI

RMI

Ratings: (0)|Views: 176|Likes:
Published by api-26355935

More info:

Published by: api-26355935 on Oct 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

W
WW
W
W
WW
WR
RR
R
R
RR
RI
II
I
I
II
IT
TT
T
T
TT
TE
EE
E
E
EE
EA
AA
A
A
AA
AP
PP
P
P
PP
PR
RR
R
R
RR
RO
OO
O
O
OO
OG
GG
G
G
GG
GR
RR
R
R
RR
RA
AA
A
A
AA
AM
MM
M
M
MM
MT
TT
T
T
TT
TO
OO
O
O
OO
OI
II
I
I
II
IM
MM
M
M
MM
MP
PP
P
P
PP
PL
LL
L
L
LL
LE
EE
E
E
EE
EM
MM
M
M
MM
ME
EE
E
E
EE
EN
NN
N
N
NN
NT
TT
T
T
TT
TR
RR
R
R
RR
RM
MM
M
M
MM
MI
II
I
I
II
II
II
I
I
II
IN
NN
N
N
NN
NJ
JJ
J
J
JJ
JA
AA
A
A
AA
AV
VV
V
V
VV
VA
AA
A
A
AA
AF
FF
F
F
FF
FO
OO
O
O
OO
OR
RR
R
R
RR
R
(
((
(
(
((
(I
II
I
I
II
I)
))
)
)
))
)
A
AA
A
A
AA
AS
SS
S
S
SS
SI
II
I
I
II
IN
NN
N
N
NN
NG
GG
G
G
GG
GL
LL
L
L
LL
LE
EE
E
E
EE
EC
CC
C
C
CC
CL
LL
L
L
LL
LI
II
I
I
II
IE
EE
E
E
EE
EN
NN
N
N
NN
NT
TT
T
T
TT
T
(
((
(
(
((
(I
II
I
I
II
II
II
I
I
II
I)
))
)
)
))
)
M
MM
M
M
MM
MU
UU
U
U
UU
UL
LL
L
L
LL
LT
TT
T
T
TT
TI
II
I
I
II
IP
PP
P
P
PP
PL
LL
L
L
LL
LE
EE
E
E
EE
EC
CC
C
C
CC
CL
LL
L
L
LL
LI
II
I
I
II
IE
EE
E
E
EE
EN
NN
N
N
NN
NT
TT
T
T
TT
TS
SS
S
S
SS
S
I
II
I
I
II
IN
NN
N
N
NN
NT
TT
T
T
TT
TR
RR
R
R
RR
RO
OO
O
O
OO
OD
DD
D
D
DD
DU
UU
U
U
UU
UC
CC
C
C
CC
CT
TT
T
T
TT
TI
II
I
I
II
IO
OO
O
O
OO
ON
NN
N
N
NN
N:
::
:
:
::
:

RMI is one of the core Java APIs since version 1.1. It provides a framework for distributed computing. With RMI, separate parts of a single program can exist in multiple Java environments on multiple machines. To the client and server, the program operates much like it is local to their environment and within a single memory space.

There are many cases where a distributed environment is beneficial. As applications grow large and complex they are more manageable, more performant, and more robust when they are distributed among multiple machines. Resources can be physically located where they make the most sense. Dedicated machines can be configured optimally to perform specialized operations. Heavy processing can be allocated to the best-suited hardware, centralized data servers can handle data processing, and web servers can just serve web pages. A large application can distribute the workload and achieve better efficiency and data isolation. RMI is a proven framework to design and implement a distributed application in a Java environment. Due to the multi-platform nature of Java, RMI is probably the best choice of API for this type of application.

The client is defined as the application, which uses a remote object, and the server is defined as the machine which hosts the remote object. Communication is two way. Below is the standard simple diagram showing the relationship.

To both the client and server, the application appears to be local even though it is actually distributed among multiple Java environments. This is achieved by implementing interfaces, which define the methods, which can be invoked. The interfaces define the contract between the objects. What is actually passed back and forth are primitive data types (passed by value), remote references (objects which implement java.Remote), or copies of local objects (objects which implement java.io.Serializable). As one would expect, changes to the remote reference results in changes to the object; changes to the copy do not.

Remote objects are listed in ther mire g ist ry of the server. A client will query the rmiregistry for an object by its handle and will receive a reference to the remote object. The client then invokes methods on the remote object. What actually is happening is that the client is invoking methods locally on the stub, which carries out the interaction. Likewise on the server side, the server interacts with the skeleton. The operations of the Remote Reference Layer and the Transport Layer are hidden from both sides. This allows different implementations of the Java Virtual Machine, which may be on different platforms, to integrate seamlessly.

When the resources become large, extensive processing is required, or resources exist in multiple physical locations, then distributed objects are the way to go. The advantages include all of the power words that are commonly tossed around: scalability, maintainability, reliability, availability, extensibility, and manageability.

It provides an efficient network environment as the resources are only transmitted as needed and do not have to be loaded locally to each individual client. They can also be managed locally. The transmissions are much smaller than sending a complete formatted page for each query. This benefit would be magnified if the resources are large or need to be updated regularly.

C
CC
C
C
CC
CO
OO
O
O
OO
OD
DD
D
D
DD
DE
EE
E
E
EE
E(
((
(
(
((
(S
SS
S
S
SS
SI
II
I
I
II
IN
NN
N
N
NN
NG
GG
G
G
GG
GL
LL
L
L
LL
LE
EE
E
E
EE
EC
CC
C
C
CC
CL
LL
L
L
LL
LI
II
I
I
II
IE
EE
E
E
EE
EN
NN
N
N
NN
NT
TT
T
T
TT
T)
))
)
)
))
):
::
:
:
::
:
RandomQuote.java
import java.rmi.*;
public interface RandomQuote extends Remote

{
public String getQuote() throws RemoteException;
public String getQuotes(int n) throws RemoteException;

}QuoteServer.java
import java.net.*;
import java.rmi.*;
public class QuoteServer

{
public static void main(String[] args)
{

try
{
QuoteServerImpl q = new QuoteServerImpl();
Naming.rebind("quotes", q); // sets the handle
System.out.println("QuoteServer started and "+"awaiting
connections.");

}catch (RemoteException er)
{System.out.println("Exception in QuoteServer.main: " + er);
}catch (Exception err)
{System.out.println("Exception occurred: " + err);
}

}
}
QuoteServerImpl.java

import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.io.*;
import java.util.*;

public class QuoteServerImpl implements RandomQuote

{
ArrayList quotes = new ArrayList();
ArrayList chosen = new ArrayList();
String resources = "quote_r.txt"; //full path to your resources!!

public QuoteServerImpl() throws RemoteException

Activity (14)

You've already reviewed this. Edit your review.
1 hundred reads
murthy_oct24 liked this
shabsae liked this
Apoorv Naik liked this
Ghanshyam Sharma liked this
dilip4u liked this
rizeky liked this
sharatn liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->