You are on page 1of 18

IS2103

DISTRIBUTED COMPUTING

User Interface

Business Logic

Database a abase Access Control

Dumb Terminal

Mainframe

Database

Presentation (1st Tier)

Business Logic (2nd Tier)

Backend (3rd Tier)

Windows GUI

Database

Personal Computer Java GUI

Network Computer

Database

Servlets

Java Web Server


4

ModelViewControllerPattern
Consistsofthreekindsofobjects Applicationobjects(Model) Screenpresentationobjects(View) Objectsmanagingthewayuserinterfacereactstouser input(Controller) BeforeMVC,userinterfacedesignstendedtolump

theseobjectstogether MVCdecouples d l them h toincrease i flexibility fl ibili and dreuse

DistributedObjectArchitecture
Basedonanetworkcommunicationlayer y Thereare3parts:
Businessobject Stub Skeleton

10

10

11

11

RMI

RemoteObject: AddServer

RMI

JVM 1

JVM 2

Client

Server

12

12

Client
1. Client invokes a business method

Network (RMI Protocol)


2. Communicate method invoked to Skeleton

Middle Tier
3. Skeleton invoke method on Business Object

RMI Loop p
STUB

SKELETON

BUSINESS OBJECT

5. Return results to Client

4. Communicate return values to Stub

13

Terms
Marshalling convertsobjectsintoabytestreamand

unmarshalling g reversesthep process converting gabyte y stream toanobject Objectserialization:theabilitytoconvertanobjectintoa stream t of fb bytes t th that tcanl later t be b converted t dback b ki into t acopy oftheoriginalobject Astub isaclientsideobjectthatrepresentstheremote object.Astubhasthesamelistofmethodsthattheremote objectexposestootherobjects Askeleton residesontheserversideandtakescareofall detailspertainingtotheremotenatureoftheserverside object j sothattheactualserversideobject j doesnothaveto worryabouthowtohandlethenetworklevelcommunication.
14

14

FindingObjectsinRMI
Usenamingordirectoryservice Needtofirstfindthenamingordirectoryservice Anaming gordirectory yservice isusually yrunonahost

listeningonacertainportnumber Theclienthastoknowthehostandportnumbersof thenamingordirectoryservicebeforeitcanlocate theremoteobject RMIimplementsitsownnamingservicewhichisa registry ofnamesmappedtoremoteobjects


15

15

StepsinDevelopingRMIApplications
DefinetheremoteinterfacefortheAddServerobject ImplementtheremoteinterfacewithAddServerImpl class Writeaclientapplicationtoinvoketheadd()methodofthe

AddServer Generatestubsandskeletons
rmic addRmi.AddServerImpl p

Writeaserverapplication Starttheregistry
start rmiregistry

Runtheserverapplication Runthe h client l application l


16

16

RunServerandClientApplications
RunServerApplication:
java addRmi.AddServerApp

RunClientApplication:
java addRmi.AddClientApp 127.0.0.1 3 4

Outputs:
First number is: 3 Second number is: 4 R Result l is: i 7.0 7 0
17

17

IS2103

18

You might also like