COM - PowerPoint PPT Presentation

About This Presentation
Title:

COM

Description:

Title: ( ) Author: panaimin Last modified by: PanAimin Created Date: 4/14/2001 1:17:13 PM Document presentation format: – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 70
Provided by: pana180
Category:
Tags: net | com | serialization

less

Transcript and Presenter's Notes

Title: COM


1
COM
  • ???
  • http//www.icst.pku.edu.cn/CompCourse

2
??
  • COM??
  • COM??
  • COM??
  • COM??
  • COM??

3
??COM??
COM??
COM??
IXxx p p-gt
4
??COM??????
COM??
5
COM?COM
COM
6
COM????
  • ?????????????Web??
  • ??????
  • ????????????????
  • ???????
  • ????????
  • ?????????????
  • ??????????????
  • ?transaction?security?event?

7
COM????
  • ??????
  • ?????????????????
  • ?????????????????
  • COM?COM??????
  • ???COM runtime library
  • ???MTS(Microsoft Transaction Server)
  • ?????????
  • ?????runtime??
  • ???????????????(?????)
  • COM??COM,??????????

8
COM????????
  • ??????????????????????,????????
  • ?????????
  • ???????????????
  • ????COM????
  • ?????????

9
COMinterception??
???????????
Stub
RPC??
10
COM????
  • COM????
  • COM Application ??????
  • COM Components ??????
  • COM Objects
  • COM Application
  • ????
  • Server Application,DllHost.exe
  • Library Application,???????,????
  • ???????,???????
  • COM Components?COM?????
  • COM Objects?COM?????

11
COM????
  • Component Services snap-in

12
????COM??
  • ?????,??????COM?
  • ????COM??
  • COM runtime services???COM?????
  • ?????????
  • ??interceptor,???
  • ??????????,??????
  • COM????????????????????

13
COM???????
  • ??DLL?????
  • ?????
  • DllRegisterServer?DllUnregisterServer
  • ???typelib
  • typelib?????dll?,????????

14
COM Catalog(COM??)
  • COM??????????
  • COM Registration Database
  • ????????????COM Catalog
  • COM Administration Library,????
  • ????snap-in??????????????????
  • ??????COMAdminCatalog??????????
  • ProgIDCOMAdmin.COMAdminCatalog

15
COMAdminCatalog????
16
COMAdminCatalog??????
  • 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 )

17
COM Context(COM??)
  • ??????COM??
  • COM?????,??context
  • ??????????????
  • ??????????????
  • ????????????????
  • ????????
  • CoGetObjectContext
  • GetObjectContext

18
COM??(?)
  • ????????
  • IObjectContext
  • IGetContextProperties
  • IObjectContextInfo
  • IContextState
  • ISecurityCallContext
  • ??????
  • ??ASP??

19
COM???
  • ??????????????????
  • Authentication ??(??)
  • Authentication Level
  • SSP/SSPI ????
  • NTLM/Kerberos
  • CoInitializeSecurity
  • ????????

20
COM???(??)
  • ??(Authorization)
  • Role-based
  • ???????????
  • ???????ISecurityCallContext?IObjectControl???
  • IsSecurityEnabled
  • IsCallerInRole
  • ????ISecurityProperty

21
COM???(??)
  • ???????(identity)
  • DCOM???????????? ????
  • ???????????????
  • ???????????
  • trusted server model
  • impersonation/dele-gation model

22
COM????STA?MTA
??
STA
MTA
STA
23
COM????TNA
  • TNA(Thread neutral apartment)
  • ?????,????,??????????
  • TNA????
  • ThreadingModelNeutral
  • ?????????????????
  • ???,??????????
  • TNA?????Free?Both??
  • STA????,?????UI???

24
??(synchronization)
  • ??serialization
  • STA???????,MTA?TNA??????
  • COM???activity-based synchronization
  • activity???????????????
  • ?????????
  • ??activity????????????
  • ???????????????

25
Transaction(??)
  • ???????????????
  • ???????????????????
  • ?????????????
  • ??????,????????
  • ????????????
  • ??????????????,?????????????????????,??????????
    ??????????????

26
???????
  • DTC(Distributed Transaction Coordinator)
  • ?????DTC??,DTC???????
  • ?????
  • ?????
  • ????committing?aborting

27
COM????
  • COM runtime??????DTC
  • ???DTC???
  • IObjectContextSetComplete
  • IObjectContextSetAbortComplete
  • ???????

28
Bank??
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
31
COM RM
  • COM RM(Resource Manager)
  • ?????????????????,?????????????
  • ???????,RM??????????
  • ????????,RM?????????
  • ??????????MSMQ
  • DTC???????
  • ?????????,????
  • ????RM?????????,??????
  • ????DTC??RM????

32
?????(ACID)
  • Atomicity
  • ??????????,?????
  • Consistency
  • ?????
  • Isolation
  • ??????????????
  • Durability
  • ???????????

33
COM?????(?)
34
COM?????(?)
35
COM?????(?)
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

38
Transaction and Just-In-Time activation
  • ????????JIT activation??

39
JIT 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????????????????

43
QC??
???
QC.Recorder
QC.Player
??
?? MSMQ
44
MSMQ??
45
QC???
  • ??????
  • ?????????Queue??,??????
  • ?????????
  • ???MSMQ??????
  • ??QC??????MQ???
  • ????????

46
QC???
47
QC?????
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
49
QC???
  • ????
  • ????out?in,out?retval
  • ????????????
  • ??????????????????????????,??,?????????
  • ?????????????,??????QC.Recorder???????
  • ??????
  • ????
  • ??????????
  • ????????QC
  • ???????QC???????
  • ????????????????????

50
QC???(?)
  • QC??????
  • MSMQ??????RM
  • ????QC??????
  • ?????QC??????
  • QC????
  • ????????????
  • ??????????

51
QC?Moniker
  • ??Moniker??QC??,??
  • GetObject(queue/newVBShipProj.VBShip)
  • ??????????,???????????
  • queue????
  • GetObject(queueComputerNameSomeMachine/newVBSh
    ipProj.VBShip)
  • new????
  • GetObject(newVBShipProj.VBShip)

52
COM????
  • ????????????
  • publisher???
  • subscriber???
  • ????
  • ???
  • ????? tightly coupled event
  • COM???loosely coupled event model

53
COM??????
COM??
1 ??
2 ??
???
?????
3 ??
5 ??subscriber??
Publisher
Subscriber
????
4 ??
IFoo e1() e2() ...
IFoo e1() e2() ...
6 ????????subscriber
7 ????
54
???????
55
Subscriber????subscription
56
Publisher????
' 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
57
Subscriber????
' 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
58
subscription
  • ????
  • 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????
  • ?????????????

62
COM????????????
1
Client
Source
Connection point
Sink object
2
Publisher
Event object
Subscriber
63
COM?????
  • IMDB(In-Memory Database)
  • ????,????????
  • CLB(Component Load Balancing)
  • ???Application Center Server?
  • Windows 2000 Advanced Server???
  • ?clustering service????high-availability and
    scalability

64
CLB?????
65
COM???????
  • COM?Active Directory Service
  • COM?Security Sevices
  • Kerberos?PKI
  • COM?Data Access Services
  • COM?DTC
  • COM?MSMQ
  • COM?Web Services

66
COM??
  • ??????,??????
  • ??????????
  • ??????,???????????ATL
  • Attributed Programming
  • ?????
  • COM?????,??????????????,????????????????,????????
    ??????
  • ?COM?????????????????

67
Visual Studio .NET?COM???
68
Attributed Programming
69
????
  • ?Understanding COM(????)
  • ??????COM
  • ?????Windows 2000?????
  • ????MSDN-Library
Write a Comment
User Comments (0)
About PowerShow.com