Title: MICROSOFT COM
1MICROSOFT COM
(COMPONENT OBJECT MODEL)
Develpment Methodologies
Presented By LAILA ROHANI
2CONTENTS
- MIDLs
- Creating a simple COM object
- Interface Design Issues
- Implementing COM in VB and VC
- Java COM Integration Model
- COM Threading Models
- Conclusion
- References
3MICROSOFT INTERFACE DEFINITION LANGUAGE
- Language independent
- Declaration language
- NOT a programming language
- Syntax ? similar to C ? MUCH MORE!!!
- Type library
- Not mandatory
4 object, uuid (122323FAGAd098776)
Interface IFindSum IUnknown import
unknown.idl HRESULT SumOfNumbers (inlong
Inum, inlong Inum2, out, retval long
sum)
- IUnknown
- QueryInterface
- AddRef
- Release
5CREATING A SIMPLE COM OBJECT
CLIENT
calls API functions
CoCreateInstance
CoGetClassObject (class factory)
locate
SCM
Class object
search
Windows Registry Location (HKEY_CLASSES_ROOT\CLSID
)
Internal db
returns interface pointer
IClassFactory
releases
CreateInstance
6DESIGN ISSUES
- Naming
- Factoring
- Contract Strictness
- Success Codes
- Use of Unions
- By-value parameters
- Passing Interface Pointers
- Callbacks
- Enumerators
- In-process OR Out-process
7COM IN VC AND VB
8Fax Service Client API
9CoCreateInstance
VC
FaxServer object
IFaxServerConnect
IFaxServerDisconnect
GetPorts
CreateDocument
GetJobs
IunknownRelease
FaxDoc
FaxPorts
FaxJobs
Send
GetRoutingMethods
GetStatus
FaxRoutingMethods
getItem
FaxStatus
FaxRoutingMethod
10CreateObject
VB
Connect
Disconnect
FaxServer object
GetPorts
CreateDocument
GetJobs
FaxDoc
FaxJobs
FaxPorts
Send
GetStatus
GetRoutingMethods
FaxStatus
FaxRoutingMethods
11JAVA COM INTEGRATION MODEL
- MS VJ
- no new keywords
- Special tools for integration
- Java Type Library Wizard
- automates java class wrappers creation
- Java TLB
- converts type library function into java .class
files - JavaReg
- register Java classes
12(No Transcript)
13- external object java object
- Garbage Collection ? not concerned with keeping
tracks - of unusable objects
public class DooHickey static int counter
0 DooHickey() new MessageBox("DooHickey,
from Visual J") public int Sum(int x, int
y) return x y public void
Greet(String message) counter new
MessageBox(message " - Strike " counter)
if(counter 3) counter 0 throw
new com.ms.com.ComFailException("You're out!")
14Create an IDL file
(vjwidget.idl)
Compile into TLB using MkTypLib utility
(vjwidget.tlb)
Generate class wrappers
(DooHickey.class IDooHickey.class)
Set output directory (windir\java\lib)
Modify codes for implementing interface
Register the java class (UUID)
15COM THREADING MODELS
- What is a thread???
- What is an apartment???
- thread lt gt apartment
- objects are created in an apartment
- one specific instance one apartment
- model cannot be changed
16- 4 Types
- Single Threaded Apartments
- Multi Threaded Apartments
- Mixed Threading Model
- Thread Neutral Apartments
17SINGLE THREADED APARTMENTS
- one thread
- initialized by CoInitialize
- At a time, only one thread can be executed from
callers - message queue (serially)
- window messaging system
- DEADLOCKS!!!
18MULTI THREADED APARTMENTS
- Free threading apartments
- Windows NT
- No message queue
- multiple threads can access a single object
- sharing the apartment
- Protect object / class ???
19MIXED THREADED APARTMENTS
- One MTA
- Many STA
- STA ? calls are synchronized by Windows
- MTA ? No synchronization
20THREAD NEUTRAL APARTMENTS
- Almost same as MTA
- Each class instance ? single thread
- Thread executes a method in COM
- New object is created
- Current thread is suspended
- New thread is created to handle new object
- Thread obtains an apartment wide lock
21CONCLUSION
- Makes life easier in interfacing
- Encapsulation
- Language friendly ?
- Mobility
- Resusability
22REFERENCES
- www.microsoft.com
- msdn.microsoft.com
- www.idevresource.com
- www.devarticles.com
- www.peterindia.com
- my.execpc.com/gopalan
- wireless instant voice messaging using the
internet by - Carlos A. Rivera, 2002
- Operating Systems Design and Implementation,
Andrew - Tanenbaum and Albert S. WoodHull