Title: COM
1COM
- ???
- http//www.icst.pku.edu.cn/CompCourse
2??
- COM??
- COM??
- COM??
- COM??
- COM??
3??COM??
COM??
COM??
IXxx p p-gt
4??COM??????
COM??
5COM?COM
COM
6COM????
- ?????????????Web??
- ??????
- ????????????????
- ???????
- ????????
- ?????????????
- ??????????????
- ?transaction?security?event?
7COM????
- ??????
- ?????????????????
- ?????????????????
- COM?COM??????
- ???COM runtime library
- ???MTS(Microsoft Transaction Server)
- ?????????
- ?????runtime??
- ???????????????(?????)
- COM??COM,??????????
8COM????????
- ??????????????????????,????????
- ?????????
- ???????????????
- ????COM????
- ?????????
9COMinterception??
???????????
Stub
RPC??
10COM????
- COM????
- COM Application ??????
- COM Components ??????
- COM Objects
- COM Application
- ????
- Server Application,DllHost.exe
- Library Application,???????,????
- ???????,???????
- COM Components?COM?????
- COM Objects?COM?????
11COM????
- Component Services snap-in
12????COM??
- ?????,??????COM?
- ????COM??
- COM runtime services???COM?????
- ?????????
- ??interceptor,???
- ??????????,??????
- COM????????????????????
13COM???????
- ??DLL?????
- ?????
- DllRegisterServer?DllUnregisterServer
- ???typelib
- typelib?????dll?,????????
14COM Catalog(COM??)
- COM??????????
- COM Registration Database
- ????????????COM Catalog
- COM Administration Library,????
- ????snap-in??????????????????
- ??????COMAdminCatalog??????????
- ProgIDCOMAdmin.COMAdminCatalog
15COMAdminCatalog????
16COMAdminCatalog??????
- Dim Catalog As new COMAdminCatalog
- Dim Applications As COMAdminCatalogCollection
- Dim Components As COMAdminCatalogCollection
- Dim AppObject As COMAdminCatalogObject
- ' get the Applications collection and populate it
- Set Applications Catalog.GetCollection("Applicat
ions") - Applications.Populate
- ' get the correct application, My Application
- For Each AppObject in Applicationss
- If AppObject.Name "My Application" Then Exit
For - Next
- ' get the Components collection for My
Application - Set Components Applications.GetCollection(
"Components" , AppObject.Key )
17COM Context(COM??)
- ??????COM??
- COM?????,??context
- ??????????????
- ??????????????
- ????????????????
- ????????
- CoGetObjectContext
- GetObjectContext
18COM??(?)
- ????????
- IObjectContext
- IGetContextProperties
- IObjectContextInfo
- IContextState
- ISecurityCallContext
- ??????
- ??ASP??
19COM???
- ??????????????????
- Authentication ??(??)
- Authentication Level
- SSP/SSPI ????
- NTLM/Kerberos
- CoInitializeSecurity
- ????????
20COM???(??)
- ??(Authorization)
- Role-based
- ???????????
- ???????ISecurityCallContext?IObjectControl???
- IsSecurityEnabled
- IsCallerInRole
- ????ISecurityProperty
21COM???(??)
- ???????(identity)
- DCOM???????????? ????
- ???????????????
- ???????????
- trusted server model
- impersonation/dele-gation model
22COM????STA?MTA
??
STA
MTA
STA
23COM????TNA
- TNA(Thread neutral apartment)
- ?????,????,??????????
- TNA????
- ThreadingModelNeutral
- ?????????????????
- ???,??????????
- TNA?????Free?Both??
- STA????,?????UI???
24??(synchronization)
- ??serialization
- STA???????,MTA?TNA??????
- COM???activity-based synchronization
- activity???????????????
- ?????????
- ??activity????????????
- ???????????????
25Transaction(??)
- ???????????????
- ???????????????????
- ?????????????
- ??????,????????
- ????????????
- ??????????????,?????????????????????,??????????
??????????????
26???????
- DTC(Distributed Transaction Coordinator)
- ?????DTC??,DTC???????
- ?????
- ?????
- ????committing?aborting
27COM????
- COM runtime??????DTC
- ???DTC???
- IObjectContextSetComplete
- IObjectContextSetAbortComplete
- ???????
28Bank??
29?????
(1) ?????MoveMoney???Perform??
?? AccountA?? T1 (????)
(2) MoveMoney??AccountA??
?? MoveMoney?? T1 (?????)
?? AccountB?? T1 (??????)
(3) MoveMoney??AccountB??
30????
(2) Account????ADO???SQL Server
(1) ??Post
?? AccountA?? T1 (????)
?? MoveMoney?? T1 (?????)
(4) Account???? SQL Server??
?? AccountB?? T1 (??????)
DTC??
(5) SQL Server???????
SQL Server??? ?? ??
??ID ???? ?-100 T1 ?????? ?100 T1
(3) SQL Server??????T1?
SQL Server COM RM
31COM RM
- COM RM(Resource Manager)
- ?????????????????,?????????????
- ???????,RM??????????
- ????????,RM?????????
- ??????????MSMQ
- DTC???????
- ?????????,????
- ????RM?????????,??????
- ????DTC??RM????
32?????(ACID)
- Atomicity
- ??????????,?????
- Consistency
- ?????
- Isolation
- ??????????????
- Durability
- ???????????
33COM?????(?)
34COM?????(?)
35COM?????(?)
uuid(04CF0B76-1989-11D0-B917-0080C7394688),
helpstring("Account Class"), TRANSACTION_REQUIR
ED coclass CAccount default interface
IAccount uuid(04CF0B7B-1989-11D0-B917-0
080C7394688), helpstring("MoveMoney
Class"), TRANSACTION_REQUIRED coclass
CMoveMoney default interface
IMoveMoney
36????
37????????
- ?????
- transaction-vote bit???
- deactivate-on-return bit????,?????
- ???????????
- IObjectContext
- IContextState
38Transaction and Just-In-Time activation
39JIT activation???
- ???? ????
- ????????
- ????????????????,??????????(???????)
- ????????
- ???????
- ???????
- ???????
40??????
- ???
- ??????IObjectControl??
- Activate
- Deactivate
- CanBePooled
- ?????????
- ???????STA
- ????
- ??????????
41???????(compensating resource manager)
- ????
- Undo,????????
- ???????
- RM????
- CRM
- ???COM?????CRM?????
- ??
- CRM Worker??????,???CRM Clerk
- CRM Clerk?????????,??DTC
- CRM compensator??????????
- DTC????????
42????(Queued Components)
- ???????,
- ???????
- ?????,????????????
- ????????????
- ???off-line??email,????outbox?,??on-line,????????
- ????????(????????),???????????????
- ????????????????????,????????????
- ????
- COM????????????????
43QC??
???
QC.Recorder
QC.Player
??
?? MSMQ
44MSMQ??
45QC???
- ??????
- ?????????Queue??,??????
- ?????????
- ???MSMQ??????
- ??QC??????MQ???
- ????????
46QC???
47QC?????
48????
Dim Ship As Object Set Ship GetObject("queue/ne
wVBShipProj.VBShip") Ship.CustomerID
1111 Ship.OrderID 2222 Ship.LineItem 12,
"Drummers drumming" Ship.LineItem 11, "Pipers
piping" Ship.LineItem 10, "Lords a
leaping" Ship.LineItem 9, "Ladies
dancing" Ship.LineItem 8, "Maids a
milking" Ship.LineItem 7, "Swans a
swimming" Ship.LineItem 6, "Geese a
laying" Ship.LineItem 5, "Gold rings" Ship.LineIte
m 4, "Calling birds" Ship.LineItem 3, "French
hens" Ship.LineItem 2, "Turtledoves" Ship.LineItem
1, "A partridge in a pear tree" Ship.Process
49QC???
- ????
- ????out?in,out?retval
- ????????????
- ??????????????????????????,??,?????????
- ?????????????,??????QC.Recorder???????
- ??????
- ????
- ??????????
- ????????QC
- ???????QC???????
- ????????????????????
50QC???(?)
- QC??????
- MSMQ??????RM
- ????QC??????
- ?????QC??????
- QC????
- ????????????
- ??????????
51QC?Moniker
- ??Moniker??QC??,??
- GetObject(queue/newVBShipProj.VBShip)
- ??????????,???????????
- queue????
- GetObject(queueComputerNameSomeMachine/newVBSh
ipProj.VBShip) - new????
- GetObject(newVBShipProj.VBShip)
52COM????
- ????????????
- publisher???
- subscriber???
- ????
- ???
- ????? tightly coupled event
- COM???loosely coupled event model
53COM??????
COM??
1 ??
2 ??
???
?????
3 ??
5 ??subscriber??
Publisher
Subscriber
????
4 ??
IFoo e1() e2() ...
IFoo e1() e2() ...
6 ????????subscriber
7 ????
54???????
55Subscriber????subscription
56Publisher????
' Create the event class object Dim foo As New
StockEventCls ' Call the event class object's
method that ' fires the StockPriceChanged
event. Private Sub Command1_Click() Call
foo.StockPriceChanged(Text1.Text,
CCur(Text2.Text)) End Sub ' Call the event class
object's method that ' fires the NewStockListed
event. Private Sub Command2_Click() Call
foo.NewStockListed(Text1.Text) End Sub
57Subscriber????
' The subscriber must implement the interface
on ' which it wants to receive calls from the
event object Implements StockEventCls ' Pop up
message box telling user of ' NewStockListed
event Private Sub StockEventCls_NewStockListed(By
Val Symbol As String) MsgBox "New Stock "
Symbol " has started trading", vbOKOnly,
_ "VB Event Subscriber" End Sub ' Pop up
message box telling user of ' StockPriceChanged
event Private Sub StockEventCls_StockPriceChanged
(ByVal Symbol As String, _ ByVal Price As
Currency) MsgBox "The market price of stock "
Symbol " is now _ Str(Price),
vbOKOnly, "VB Event Subscriber" End Sub
58subscription
- ????
- persistent
- transient
Set oCOMAdminCatalog CreateObject("COMAdmin.
COMAdminCatalog.1") 'Get the
TRANSIENTSUBSCRIPTIONS collection Set oTSCol
oCOMAdminCatalog.GetCollection("TransientSubscri
ptions") Set oSubscription oTSCol.Add
Set objvar objref oSubscription.Value("Subsc
riberInterface") objref oSubscription.Value(
"EventCLSID") clsid oSubscription.Value("Nam
e") "TransientSubscription"
oTSCol.SaveChanges
59????
- ????????
- ???QC??,???????????
- ??QC??,??????????????
- ????????????????,??????????
- ??????????
- ???????
- ????????
60???????
Publisher
Subscriber
????
61????????????
- ????????
- ??????
- ????????,??????,???????,?????????????????
- ??????
- ???COM????
- ?????????????
62COM????????????
1
Client
Source
Connection point
Sink object
2
Publisher
Event object
Subscriber
63COM?????
- IMDB(In-Memory Database)
- ????,????????
- CLB(Component Load Balancing)
- ???Application Center Server?
- Windows 2000 Advanced Server???
- ?clustering service????high-availability and
scalability
64CLB?????
65COM???????
- COM?Active Directory Service
- COM?Security Sevices
- Kerberos?PKI
- COM?Data Access Services
- COM?DTC
- COM?MSMQ
- COM?Web Services
66COM??
- ??????,??????
- ??????????
- ??????,???????????ATL
- Attributed Programming
- ?????
- COM?????,??????????????,????????????????,????????
?????? - ?COM?????????????????
67Visual Studio .NET?COM???
68Attributed Programming
69????
- ?Understanding COM(????)
- ??????COM
- ?????Windows 2000?????
- ????MSDN-Library