110 likes | 299 Views
COM/DCOM Implementation. Basics of: Object creation and access Object Reuse Interface referencing. 4 Basic Problems. Basic interoperability – ensuring different vendor components can interoperate Version Control – upgrading separate components without upgrading entire system
E N D
COM/DCOM Implementation • Basics of: • Object creation and access • Object Reuse • Interface referencing
4 Basic Problems • Basic interoperability – ensuring different vendor components can interoperate • Version Control – upgrading separate components without upgrading entire system • Language independence – different components can be developed in different languages • Transparency – transparency across processes
Creating an Object • Invoke an API to create the new object - CoCreateInstance • COM locates object implementation and initiates the server process • Object created and pointer to interface returned • Object has to be initialized once it is created - load data from file, stream or any other data store. • Alternatively, use monikers.
Accessing Objects • In-process server - client and server execute in the same process. • Local Object Proxy - lightweight Remote Procedure Call. • Remote Object Proxy - DCOM is used for this. Requires marshalling and unmarshalling of data
Object Reuse • Two forms: • Containment - one object holds an exclusive reference to another (outer object holds and inner object) But performance problems can arise due to hierarchies in containment. • Aggregation - defined in DCOM. Need collaboration between inner and outer objects. Mainly used for nested constructions. • Both have to maintain transparency.
Interface referencing • Specified by IDL, have a unique IID. • Provides a small set of methods. • COM objects can implement multiple interfaces. • They can be derived from other interfaces using concept of inheritance - most inherit from IUnknown, also from IDispatch and IPersist.
Interface referencing (contd..) • IUnknown has three methods: • QueryInterface • Addref • Release • Addref and Release are reference counting methods.
Interface referencing (contd..) • QueryInterface - determines if interface is supported by object (at runtime) • If it is, pointer to the interface is returned. , else returns an error. • Invoked when application needs a function of an object. • This mechanism is provided by the Component Object library
Object Creation in DCOM • Enhanced version of mechanism in COM - allows objects to be created on different machines. • Library to needs to know server name (on which object to be created) and CLSID. • 2 mechanisms for providing clients to indicate server name for object creation: • Fixed configuration in system registry • Remote server name can be explicitly defined • Alternatively, use monikers.
Interface referencing (DCOM) • DCOM has made an extension to definition of a new primitive data type. This is the interface reference to OBJREF. • Variations: • NULL • STANDARD • CUSTOM • HANDLER