Java RMI: by Tanmoy Barman
Java RMI: by Tanmoy Barman
by Tanmoy Barman
Cont: barmantanmoy.47@gmail.com
Discussion
Definition.
Scenario.
Local Vs. Remote Object
Goals of RMI.
Architecture of RMI. Architecture of RMI.
How it wors!
RMI "s. #OR$A.
Other Remote object %echnolo&ies.
Define
RMI 'Remote Method Invocation( re)resents a *istribute* Object
A))lication. It allows a ja"a )ro&ram runnin& on one +VM ' i.e.
client( to in"oe metho*s on another +VM'i.e. Ser"er(.
%herefore RMI re)resents a #lient an* Ser"er.
+a"a RMI is )ro"i*e* in the java.rmi )aca&e. +a"a RMI is )ro"i*e* in the java.rmi )aca&e.
Scenario
#onsi*er the follow scenario ,
- De"elo)er A writes a ser"ice that )erforms some useful function.
He re&ularl. u)*ates this ser"ice/ a**in& new features an*
im)ro"in& e0istin& ones.
- De"elo)er $ wishes to use the ser"ice )ro"i*e* b. De"elo)er A. - De"elo)er $ wishes to use the ser"ice )ro"i*e* b. De"elo)er A.
Howe"er/ it1s incon"enient for A to su))l. $ with an u)*ate
e"er. time.
+a"a RMI )ro"i*es a "er. eas. solution2 Since RMI can *.namicall.
loa* new classes/ De"elo)er $ can let RMI han*le u)*ates
automaticall. for him. De"elo)er A )laces the new classes in a web
*irector./ where RMI can fetch the new u)*ates as the. are re3uire*.
Scenario
Client
S
E
Remote method Invocation
Developer A
Client
E
R
V
E
R
JVM
JVM
Developer B
Local Vs. Remote Object
Althou&h we woul* lie remote objects to beha"e e0actl. the same as
local object/ that is im)ossible for se"eral reasons,
- 4etwors can be unreliable.
- Resources ma. not be accessible.
- References on one machine 'memor. a**resses( ha"e no - References on one machine 'memor. a**resses( ha"e no
meanin& on another machine.
oals of RMI
Minimi5e *ifference between worin& with local an*
remote Objects.
Minimi5e #om)le0it..
6reser"e %.)e Safet..
Distribute* Garba&e #ollection.
Arc!itecture
Arc!itecture
RMI architecture consists of,7
- Application layer.
- ro!y layer"#t$b and %&eleton'. - ro!y layer"#t$b and %&eleton'.
- RR("Remote Re)erence (ayer'.
- Tran%port layer.
Arc!itecture
Application Layer
- It8s a res)onsible for the actual lo&ic 'im)lementation( of the
client an* ser"er a))lications.
- Generall. at the ser"er si*e class contain im)lementation lo&ic
an* also a))l. the reference to the a))ro)riate object as )er the an* also a))l. the reference to the a))ro)riate object as )er the
re3uirement of the lo&ic in a))lication.
Proxy Layer
- It8s also calle* the #t$b*#&eleton layer. A Stub class is a client
si*e )ro0. han*les the remote objects which are &ettin& from the
reference. A Seleton class is a ser"er si*e )ro0. that set the
reference to the objects which are communicates with the Stub.
Arc!itecture
Remote Reference Layer (RRL)
- It8s a res)onsible for mana&e the references ma*e b. the client to
the remote object on the ser"er so it is a"ailable on both +VM
'#lient an* Ser"er(.
- %he #lient si*e RRL recei"es the re3uest for metho*s from the - %he #lient si*e RRL recei"es the re3uest for metho*s from the
Stub that is transferre* into b.te stream )rocess calle*
seriali5ation 'Marshalin&( an* then these *ata are sen* to the
Ser"er si*e RRL.
- %he Ser"er si*e RRL *oin& re"erse )rocess an* con"ert the
binar. *ata into object. %his )rocess calle* *eseriali5ation 'or
9nmarshalin& (an* then sent to the Seleton class.
Arc!itecture
Transport Layer
- It8s also calle* the :Connection layer. It8s a res)onsible for the
mana&in& the e0istin& connection an* also settin& u) new
connections. So it is a wor lie a lin between the RRL on the
#lient si*e an* the RRL on the Ser"er si*e.
"o# it #or$s%
%he RMI Re&istr. is a namin& ser"ice.
RMI ser"er )ro&rams use this ser"ice to bin* the remote ja"a object
with the names usin& +,aming.rebind"'-.
#lients e0ecutin& on local or remote machines retrie"e the remote
objects b. their name re&istere* with the RMI re&istr. usin& objects b. their name re&istere* with the RMI re&istr. usin&
+,aming.loo&$p"'-an* then e0ecute metho*s on the objects.
;<== is the *efault RMI )ort.
"o# it #or$s%
Client
S
E
R
V
E
R
Communicate directly by invoking
methods on the remote object
E
R
RMI
Re&istr'
RMI Vs. COR(A
RMI
- S)ecifie* to onl. ja"a %echnolo&..
- Interfaces s)ecifie* internall. in ja"a.
- Distribute* Garba&e collection is a"ailable inte&rate* - Distribute* Garba&e collection is a"ailable inte&rate*
with local collectors.
- Object are )asse* an* returne* as )arameters.
- It is free of cost.
RMI Vs. COR(A )cont*.+
#OR$A
- S)ecifie* to an. lan&ua&e.
- Interfaces *efine* e0ternall. throu&h IDL'Interfaces
Definition Lan&ua&e( .
- 4o *istribute* Garba&e collection is a"ailable.
- #ost mone. accor*in& to the "en*or.
Ot!er Remote Object ,ec!nolo&ies
C.RBA
- #ommon Object Re3uest $roer Architecture
- Desi&ne* for intero)erabilit. between *ifferent lan&ua&es as well
as *ifferent architectures.
/C.M or C.M
- Distribute* #om)onent Object Mo*el
- Intero)erabilit. between *ifferent machines an* lan&ua&e as
lon& as the. are >intel.
THANK YOU