cop4 - cop - corba
Post on 08-Apr-2018
228 Views
Preview:
TRANSCRIPT
-
8/7/2019 COP4 - COP - Corba
1/46
PHT TRIN PHN MM HNG CU PH(Component Oriented Programming)
KHOA CNG NGH THNG TINB MN CNG NGH PHN MM
-
8/7/2019 COP4 - COP - Corba
2/46
Chng 4: COP & CorbaChng 4: COP & Corba
Gii thiu CORBAKin trc CORBA
Cc thnh phn CORBABt u COP vi HelloCORBACc dch v CORBA
Cc cng c h tr CORBA
-
8/7/2019 COP4 - COP - Corba
3/46
t vn t vn
M hnh web hin nay cho thy th mnh ca mhnh Client Server Xu hng tp trung gii quyt vn m ngun ll Server
Cc phn mm vit trn cc ngn ng khc nhauC cch no c th kt ni Client Server trongkhi mi my trin khai trn mt nn tng ngn ngkhc nhau?
-
8/7/2019 COP4 - COP - Corba
4/46
t vn t vn
C++ Bus Object Delphi Moto Object
Java Passenger Object
? ?
?CORBA
CORBACORBA
-
8/7/2019 COP4 - COP - Corba
5/46
Common Object Request Broker Architecturec to ra bi cng tyc to ra bi cng ty Object Management Group(OMG), c lin quan ti khong trn 800 cng tykhc nhau.
Corba tr gip qu trnh c t cc thnh phn.Corba tr gip qu trnh c t cc thnh phn.Corba h tr tt cho cc ng dng chy trn mCorba h tr tt cho cc ng dng chy trn mhnh Client Server.hnh Client Server.
Vi c t Corba, cc phn mm chy trn server v Client c th trin khai vi nn tng ngn nglp trnh khc nhau: Java, C++, Delphi
Gii thiu CORBAGii thiu CORBA
-
8/7/2019 COP4 - COP - Corba
6/46
Ra i nm 1991. p ng nhu cu xy dng ccm hnh i tng phn tn.Bao gm 2 thnh phn c bn: IDL + APIIDL = Interface Definition LanguageAPI tr gip vic gi hm t xa trong m hnh phntn.H tr BOA (Basic Object Adapter)
CORBA 1.0CORBA 1.0
-
8/7/2019 COP4 - COP - Corba
7/46
Ra i nm 1996.Thay th BOA bng POA (Portable Object Adapter B iu khin i tng di ng)H tr giao thc Internet Inter-ORB Protocol (IIOP)Cho chp nh x t IDL sang C, Java, DelphiCc cng ty phn mm ln ch v h tr k thut:
+ SUN h tr cng c: IDLJ IDLtoJava+ Microsoft h tr cng c DCOM Sau ny c
thay th bi Dotnet Framework.
CORBA 2.0CORBA 2.0
-
8/7/2019 COP4 - COP - Corba
8/46
L phin bn cui cng ca CORBAChnh thc h tr kin trc hng thnh phnTch hp CCM (CORBA Component Model)
OpenCCM, MicoCCM, and EJB 3.0 l nhng cngc gip trin khai cc thnh phn vi CORBA.OpenCCM s c gii thiu trong phn sau.
CORBA 3.0CORBA 3.0
-
8/7/2019 COP4 - COP - Corba
9/46
Kin trc c bn CORBAKin trc c bn CORBA
-
8/7/2019 COP4 - COP - Corba
10/46
Kin trc c bn CORBAKin trc c bn CORBAObject Request Braher (ORB)Object Adapter (OA)Stub and Skeleton
Interface Repository (IR) and ImplementationRepository IRObject References (OR)Interface Definition Language (IDL) and LanguageMapping
-
8/7/2019 COP4 - COP - Corba
11/46
Object Request Broker/Braher (ORB)i tng trung gian x l yu cu.Cha cc th vin v cc x l nh v v kch hotcc i tng t xa.
L tng thp nht gn kt my ch v my trm.nh v i tng, gi cc phng thc c nhngha thng qua giao din.Nhn kt qu tr v t my ch.
ORB c c trn my ch v my trm.
-
8/7/2019 COP4 - COP - Corba
12/46
M hnh ORB
ORB
ORB
ORB
Network
C++CorbaObject
DelphiCorbaObject
JavaCorbaObject
-
8/7/2019 COP4 - COP - Corba
13/46
Kin trc kiu ORB
ORB ORB
Intermidiate class
_Stub
Intermidiate class
_Skel
C++Client
JavaCorbaObject
IIOP
Client Server
-
8/7/2019 COP4 - COP - Corba
14/46
Object Adapter (OA)B iu khin cc i tng.Chu trch nhim np cc thnh phn cho my ch.OA gi cc hm, to lp kch hot i tng thcthi v hy b chng.OA c 2 dng l BOA v POABOA c phin bn 1, c thay th POA phinbn 2.
-
8/7/2019 COP4 - COP - Corba
15/46
Stub and Skeletonc hiu nh l ph t ca my ch v my trm.Stub v Skeleton s c nhim v trao i d liucho nhau.Khi my trm c yu cu, Stub c nhim v sp tmi tham s (l object) v truyn ln my ch.Skeleton trn my ch s gii m i tng ny vx l.
Mt qu trnh ngc li vi qu trnh trn, d liuc tr v cho my trm.Kin trc hin nay ch cn li Stub
I f R i (IR) &
-
8/7/2019 COP4 - COP - Corba
16/46
Interface Repository (IR) &Implementation Repository IR
c hiu l kho d liu giao din v kho trin khaIR bao gm: Thng tin kiu d liu, phng thc vcc tham s c nh ngha thng qua ngn ngIDL.
Implementation Repository ch ra cch thc kchhot cc thnh phn my ch.Implementation Repository ch y cc thng tinv cc thnh phn, cc lp c trong cc thnh
phn v cc i tng.
-
8/7/2019 COP4 - COP - Corba
17/46
Object References (OR)i tng tham chiu.L mt i tng thnh phn ca CORBAOR cha v tr, ch s (id) ca nhng i tng yucu.
My trm cn phi ly c danh sch cc OR.Khi cn thc hin li gi hm, my trm s tm tiOR ca phng thc tng ng.
-
8/7/2019 COP4 - COP - Corba
18/46
Interface Definition Language (IDL)Ngn ng nh ngha giao dinCho php nh ngha giao din thng qua cc tkha.Giao din c ghi di dng file .idl
Cc file idl s c dch (mapping) sang cc ngnng tng ng nh: C++, Java, DelphiJava s dng IDLJ thc thi bin dch IDL sangm Java.IDL s c gii thiu phn sau.
-
8/7/2019 COP4 - COP - Corba
19/46
Bt u CORBA vi HelloCORBABt u CORBA vi HelloCORBACc bc tin hnh:
1. To file hello.idl, nh ngha giao din chung.2. Bin dch IDL thnh file Java, C++3.
Vit li cc thnh phn Server v Client ktha cc Interface4. Bin dch file Java, C++ thnh cc chng
trnh chy trn Server v Client5. Chy dch v trn Server 6. Chy ng dng trn Client
-
8/7/2019 COP4 - COP - Corba
20/46
Mc tiu cn t cMc tiu cn t cTo ra mt ng dng Client Server Cc phng thc xy dng trn Server
+ sayHello: In ra 1 dng Hello+ shutdown: hy b i tng remote
Client gi mt yu cu gi mt hm trn Server Kt qu li gi hm hin th trn Client
-
8/7/2019 COP4 - COP - Corba
21/46
1. To file hello.idl1. To file hello.idlC th son tho file IDL bng cng c son thobt k: notepad, wordpad..Vi NetBean:
+ Download: jbi4corba-0.7.1-netbeans-plugin
+ Menu Tools Plugin Addnew+ Chn cc file c gii nn t file download+ T ca s Project, chn mt project bm chut phi
v chn new IDL File.
-
8/7/2019 COP4 - COP - Corba
22/46
1. To file hello.idl1. To file hello.idlCode: hello.idl
module HelloApp{
interface Hello
{string sayHello();oneway void shutdown();
};};
-
8/7/2019 COP4 - COP - Corba
23/46
2. Bin dch IDL sang Java2. Bin dch IDL sang JavaS dng cng c IDLJ c trong th mc BIN caJavaLnh:
Idlj [option] hello.idl
Option:-fall: Bin dch cho c Client v Server -fclient: Bin dch cho phn Client-fserver: Bin dch cho phn Server
-
8/7/2019 COP4 - COP - Corba
24/46
2. Bin dch IDL sang Java2. Bin dch IDL sang JavaSau khi bin dch, ta c m java:
package HelloApp;public interface Hello{
String sayHello ();void shutdown ();
}
Tuy nhin y ch l kt qu ta mong i
-
8/7/2019 COP4 - COP - Corba
25/46
2. Bin dch IDL sang Java2. Bin dch IDL sang JavaThc t khi bin dch, trnh bin dch IDLC khngch to ra mt file .java.Kt qu to ra khc nhau khi ta a cc Optionkhc nhau.
-fall: _HelloStub, Hello, HelloHelper, HelloHolder,HelloOperations, HelloPOA-fserver: Hello, HelloOperations, HelloPOA-fclient: _HelloStub, Hello, HelloHelper, HelloHolder,
HelloOperations
-
8/7/2019 COP4 - COP - Corba
26/46
2. Bin dch IDL sang Java2. Bin dch IDL sang Java
Idlj fall hello.idl
Idlj fclient hello.idl
Idlj fserver hello.idl
-
8/7/2019 COP4 - COP - Corba
27/46
3. Component Client & Server 3. Component Client & Server Server:
1. Xy dng lp HelloServant Skeleton2. Xy dng lp HelloServer
Client:1. Xy dng lp HelloClient
-
8/7/2019 COP4 - COP - Corba
28/46
3. Component Client & Server 3. Component Client & Server HelloServant.java
-
8/7/2019 COP4 - COP - Corba
29/46
3. Component Client & Server 3. Component Client & Server HelloServer.java
l
-
8/7/2019 COP4 - COP - Corba
30/46
3. Component Client & Server 3. Component Client & Server HelloClient.java
4 Bi d h fil J4 Bi d h fil J
-
8/7/2019 COP4 - COP - Corba
31/46
4. Bin dch cc file Java4. Bin dch cc file JavaTh mc HelloApp c sinh ra thc thi IDLJ
Vi Option fall, HelloApp cha 6 file .javaCopy th mc HelloApp sang D:Copy 3 file: HelloServer.java, HelloClient.java,HelloServant.java sang D:Start Run: g cmd vo Commandt ng dn ti th mc BIN ca Java
path C:\ProgramFiles\Java\jdk1.6.0_17\bin
Thc hin lnh bin dch:javac d:\HelloApp\*.java d:\*.java
5 Ch d h S5 Ch d h S
-
8/7/2019 COP4 - COP - Corba
32/46
5. Chy dch v trn Server 5. Chy dch v trn Server Khi ng Server ORB:
start orbd -ORBInitialPort 1050Thc thi HelloServer vi cc tham s:
+ Port: 1050+ Server IP: Localhost
Lnh trong Commandjava HelloServer -ORBInitialPort 1050 -ORBInitialHost
localhost
5 Ch d h S5 Ch d h t S
-
8/7/2019 COP4 - COP - Corba
33/46
5. Chy dch v trn Server 5. Chy dch v trn Server
5 Ch d t Cli t5 Ch d t Cli t
-
8/7/2019 COP4 - COP - Corba
34/46
5. Chy ng dng trn Client5. Chy ng dng trn ClientThc hin lnh trong Command:
java HelloClient -ORBInitialPort 1050 -ORBInitialHostlocalhost
IDL Expamle
C d h CORBAC d h CORBA
-
8/7/2019 COP4 - COP - Corba
35/46
Cc dch v ca CORBACc dch v ca CORBA
Object Request Broker Object Request Broker
Objec t life
Objec t life
cycle
cycle
Nami ng
Naming
Event
Event
Conc urency
Concurenc y
C
ontr ol
C
ontr ol
Trader
Trade r
Trans actio n
Trans actio n
Query
Query
CORBA SERVICES
NamingNaming
NAMING SERVICENAMING SERVICE
-
8/7/2019 COP4 - COP - Corba
36/46
NAMING SERVICENAMING SERVICE
L dch v cho php truy xut n ccL dch v cho php truy xut n cci tng phn b thng qua tn.i tng phn b thng qua tn.
c nh ngha trong CosNaming.idlc nh ngha trong CosNaming.idl
COSNAMINGCOSNAMING
-
8/7/2019 COP4 - COP - Corba
37/46
COSNAMINGCOSNAMING
Gm c 2 interface ch yuGm c 2 interface ch yu+ NamingComponent+ NamingComponent+ NamingContext+ NamingContext
Lu tr i tng theo kin trc cyLu tr i tng theo kin trc cy
phn cp.phn cp.
NamingComponentNamingComponent
-
8/7/2019 COP4 - COP - Corba
38/46
NamingComponentNamingComponent
L thnh phn cha tn (tn nhn hocL thnh phn cha tn (tn nhn hoctn tp tin)tn tp tin)
C th rng buc tn vi mt i tngC th rng buc tn vi mt i tngcorba bt k.corba bt k.
NamingContextNamingContext
-
8/7/2019 COP4 - COP - Corba
39/46
NamingContextNamingContext
L i tng dng tham chiu nL i tng dng tham chiu nmt NamingComponent hay mtmt NamingComponent hay mtNamingContext khc.NamingContext khc.Ging nh th mc trong h thng file.Ging nh th mc trong h thng file.t tn da vo NamingComponent.t tn da vo NamingComponent.
M HNH LU TR I TNGM HNH LU TR I TNG
-
8/7/2019 COP4 - COP - Corba
40/46
M HNH LU TR I TNGM HNH LU TR I TNGMarketMarket
StockStock
ToysToys
FruitFruitShelf Shelf
BookBook
PanelPanel
ObjectObjectAA
ObjectObjectBB
ObjectObject
CC
i tngi tngNameContextNameContext
i tng
c rn g buc
i t ng
c rn g buc
i tngi tngNameComponentNameComponent
Tn rng buc ca i tngTn rng buc ca i tng
CC HM C BNCC HM C BN
-
8/7/2019 COP4 - COP - Corba
41/46
CC HM C BNCC HM C BNTo NamingContext:To NamingContext:new_context()new_context()
new_bind_context(NameComponent[] path)new_bind_context(NameComponent[] path)Hy NamingContext:Hy NamingContext:
destroy()destroy()Ly v i tng NamingContext:Ly v i tng NamingContext:
resolve_initial_references(ObjectId id)resolve_initial_references(ObjectId id)
resolve(NameComponent[] path)resolve(NameComponent[] path)
CC HM C BNCC HM C BN
-
8/7/2019 COP4 - COP - Corba
42/46
CC HM C BNCC HM C BNTo mt bindTo mt bind
Bind(NameComponent[] path, Object obj)Bind(NameComponent[] path, Object obj) Bind_context(NameComponent[] path,Bind_context(NameComponent[] path,
NameContext nc)NameContext nc)
Rebind(NameComponent[] path, Object obj)Rebind(NameComponent[] path, Object obj)Hy mt bind Hy mt bind
Unbind(NameComponent[] path)Unbind(NameComponent[] path)
Lit k cc binding trong mt contextLit k cc binding trong mt contextList(NameContext nc, BindingList bl,List(NameContext nc, BindingList bl,BindingIterator bt)BindingIterator bt)
Cc cng c h tr CORBACc cng c h tr CORBA
-
8/7/2019 COP4 - COP - Corba
43/46
Cc cng c h tr CORBACc cng c h tr CORBA
CCMCCM
OmniORBOmniORBVisiBroker
Tm tt kin thcTm tt kin thc
-
8/7/2019 COP4 - COP - Corba
44/46
Tm tt kin thcTm tt kin thcCORBA l mt cng ngh - khng nCORBA l mt cng ngh - khng nthun l mt ngn ngthun l mt ngn ngCORBA = IDL + API + ToolCORBA = IDL + API + Tool+ IDL l mt ngn ng trung gian inh ngha+ IDL l mt ngn ng trung gian inh nghainterfaceinterface+ API cng cp giao din h tr kin trc+ API cng cp giao din h tr kin trcClient Server Client Server
+ Tool: CCM, OmniIDL, Visibroker + Tool: CCM, OmniIDL, Visibroker M hnh kin trc ca CORBAM hnh kin trc ca CORBA
Vn t raVn t ra
-
8/7/2019 COP4 - COP - Corba
45/46
Vn t raVn t raNgn ng c t giao din IDLNgn ng c t giao din IDLIDL To C++, C#, DelphiIDL To C++, C#, DelphiTrin khai CORBA vi cc ToolTrin khai CORBA vi cc Tool
-
8/7/2019 COP4 - COP - Corba
46/46
HT CHNG 4
top related