Previous | Table of Contents | Next |
COM and CORBA have different notions of what object identity means. The impact of the differences between the two object models
affects the transparency of presenting CORBA objects as COM objects or COM objects as CORBA objects. The following sections
discuss the issues involved in mapping identities from one system to another. They also describe the architectural mechanics
of identity mapping and binding.
17.6.1.1 CORBA Object Identity and Reference Properties
CORBA defines an object as a combination of state and a set of methods that explicitly embodies an abstraction characterized
by the behavior of relevant requests. An object reference is defined as a name that reliably and consistently denotes a particular
object. A useful description of a particular object in CORBA terms is an entity that exhibits a consistency of interface,
behavior, and state over its lifetime. This description may fail in many boundary cases, but seems to be a reasonable statement
of a common intuitive notion of object identity.
Other important properties of CORBA objects include the following:
• Objects have opaque identities that are encapsulated in object references.
• Object identities are unique within some definable reference domain, which is at least as large as the space spanned by an ORB instance.
• Object references reliably denote a particular object; that is, they can be used to identify and locate a particular object for the purposes of sending a request.
• Identities are immutable, and persist for the lifetime of the denoted object.
• Object references can be used as request targets irrespective of the denoted object’s state or location; if an object is passively stored when a client makes a request on a reference to the object, the ORB is responsible for transparently locating and activating the object.
• There is no notion of “connectedness? between object reference and object, nor is there any notion of reference counting.
• Object references may be externalized as strings and reinternalized anywhere within the ORB’s reference domain.
• Two object references may be tested for equivalence (that is, to determine whether both references identify the same object instance), although only a result of TRUE for the test is guaranteed to be reliable.
17.6.1.2 COM Object Identity and Reference Properties
The notion of what it means to be “a particular COM object? is somewhat less clearly defined than under CORBA. In practice,
this notion typically corresponds to an active instance of an implementation, but not a particular persistent state. A COM
instance can be most precisely defined as “the entity whose interface (or rather, one of whose interfaces) is returned by
an invocation of IClassFactory::CreateInstance.?
The following observations may be made regarding COM instances:
• COM instances are either initialized with a default “empty? state (for example, a document or drawing with no contents), or they are initialized to arbitrary states; IClassFactory::CreateInstance has no parameters for describing initial state.
• The only inherently available identity or reference for a COM instance is its Unknown pointer. COM specifies an invariant that two interface references refer to the same object if QueryInterface (IID IUnknown) returns the same pointer when applied to both interfaces.6 Individual COM class types may establish a strong notion of persistent identity (for example, through the use of Monikers), but this is not the responsibility of the COM model itself.
• The identity and management of state are generally independent of the identity and life cycle of COM class instances. Files that contain document state are persistent, and are identified within the file system’s name space. A single COM instance of a document type may load, manipulate, and store several different document files during its lifetime; a single document file may be loaded and used by multiple COM class instances, possibly of different types. Any relationship between a COM instance and a state vector is either an artifact of a particular class’s implementation, or the user’s imagination.
17.6.2 Binding and Life Cycle
The identity-related issues previously discussed emerge as practical problems in defining binding and life cycle management
mechanisms in the Interworking models. Binding refers to the way in which an existing object in one system can be located
by clients in the other system and associated with an appropriate View. Life cycle, in this context, refers to the way objects
in one system are created and destroyed by clients in the other system.
17.6.2.1 Lifetime Comparison
The in-memory lifetime of COM (including Automation) objects is bounded by the lifetimes of its clients. That is, in COM,
when there are no more clients attached to an object, it is destroyed. COM objects are reference-counted and as such are susceptible
to certain problems: most notably, circular reference counts (where two objects hold references to each other and thus neither
can die) and dangling servers (where a client has crashed without releasing its references).
Detecting circular reference counts is not handled by COM and is currently left up to the application code. To help detect
dangling servers, COM has added support in the infrastructure for client machines to ping server machines. If the ping is
not received by the server within a negotiated time period, the client will be assumed dead and its references released.
6. This invariant appears to be true in DCOM as well as COM. A combination of IPID and OXID is used to create a unique identity
for remote IUnknown pointers.
The CORBA Life Cycle model decouples the lifetime of the clients from the lifetime of the active (in-memory) representation
of the persistent server object. The CORBA model allows clients to maintain references to CORBA server objects even when the
clients are no longer running. Server objects can deactivate and remove themselves from memory whenever they become idle.
This behavior allows resources (such as memory and networking addresses) to be released from active use for long-lived (but
generally idle) services. The advantage of this model is that it does not require pinging or maintaining reference counts.
The disadvantage is that it requires the application to explicitly decide when an object has been made obsolete and its references
should become invalid. Activation and deactivation in COM can, to some degree, be accomplished using Monikers (persistent
interface references). However, unlike CORBA, the client must be programmed to explicitly use this alternate form of binding
to allow the server the opportunity to pacify its state.
In both the COM and CORBA lifecycle models, it is possible for a client to have an invalid reference to a server object. This
can occur in COM because a server has crashed, or in CORBA because the target of the reference was explicitly destroyed. Thus,
in both models, applications should be written to check for error codes indicating invalid references.
17.6.2.2 Binding Existing CORBA Objects to COM Views
COM and Automation have limited mechanisms for registering and accessing active objects. A single instance of a COM class
can be registered in the active object registry. COM or Automation clients can obtain an IUnknown pointer for an active object
with the COM GetActiveObject function or the Automation GetObject function. The most natural way for COM or Automation clients
to access existing CORBA objects is through this (or some similar) mechanism.
Interworking solutions can, if desirable, create COM Views for any CORBA object and place them in the active object registry,
so that the View (and thus, the object) can be accessed through GetActiveObject or GetObject.
The resources associated with the system registry are limited; some interworking solutions will not be able to map objects
efficiently through the registry. This specification defines an interface, ICORBAFactory, which allows interworking solutions
to provide alternate location and registration mechanisms7 through which CORBA objects can be made available to COM and Automation
clients in a way that is similar to OLE’s native mechanism (GetObject). This interface is described fully in
Section 17.7.3, “ICORBAFactory Interface,? on page 17-24.
7. For example, using ICORBAFactory, an interworking solution can provide an active object registry that is distributed, federated,
and fault-tolerant.
17.6.2.3 Binding COM Objects to CORBA Views
As described in Section 17.6.1, “Object Identity Issues,? on page 17-19, COM class
instances are inherently transient. Clients typically manage COM and Automation objects by creating new class instances and
subsequently associating them with a desired stored state. Thus, COM objects are made available through factories. The
SimpleFactory OMG IDL interface (described in Section 17.7.1, “SimpleFactory
Interface,? on page 17-23) is designed to map onto COM class factories, allowing
CORBA clients to create (and bind to) COM objects. A single CORBA SimpleFactory maps to a single COM class factory. The manner
in which a particular interworking solution maps SimpleFactories to COM class factories is not specified. Moreover, the manner
in which mapped SimpleFactory objects are presented to CORBA clients is not specified.
17.6.2.4 COM View of CORBA Life Cycle
The SimpleFactory interface (Section 17.7.1, “SimpleFactory Interface,? on
page 17-23) provides a create operation without parameters. CORBA SimpleFactory
objects can be wrapped with COM IClassFactory interfaces and registered in the Windows registry. The process of building,
defining, and registering the factory is implementation-specific.
To allow COM and Automation developers to benefit from the robust CORBA lifecycle model, the following rules apply to COM
and Automation Views of CORBA objects. When a COM or Automation View of a CORBA object is dereferenced and there are no longer
any clients for the View, the View may delete itself. It should not, however, delete the CORBA object that it refers to. The
client of the View may call the LifeCycleObject::remove operation (if the interface is supported) on the CORBA object to remove
it. Otherwise, the lifetime of the CORBA object is controlled by the implementation-specific lifetime management process.
COM currently provides a mechanism for client-controlled persistence of COM objects (equivalent to CORBA externalization).
However, unlike CORBA, COM currently provides no general-purpose mechanism for clients to deal with server objects, such as
databases, which are inherently persistent; that is, they store their own state -- their state is not stored through an outside
interface such as IPersistStorage. COM does provide monikers, which are conceptually equivalent to CORBA persistent object
references. However, monikers are currently only used for OLE graphical linking. To enable COM developers to use CORBA objects
to their fullest extent, the specification defines a mechanism that allows monikers to be used as persistent references to
CORBA objects, and a new COM interface, IMonikerProvider, that allows clients to obtain an IMoniker interface pointer from
COM and Automation Views. The resulting moniker encapsulates, stores, and loads the externalized string representation of
the CORBA reference managed by the View from which the moniker was obtained. The IMonkierProvider interface and details of
object reference monikers are described in
Section 17.7.2, “IMonikerProvider Interface and Moniker Use,? on page 17-23.
17.6.2.5 CORBA View of COM/Automation Life Cycle
Initial references to COM and Automation objects can be obtained in the following way: COM IClassFactories can be wrapped
with CORBA SimpleFactory interfaces. These SimpleFactory Views of COM IClassFactories can then be installed in the naming
service or used via factory finders. The mechanisms used to register or dynamically look up these factories is beyond the
scope of this specification.
All CORBA Views for COM and Automation objects support the LifeCycleObject interface. In order to destroy a View for a COM
or Automation object, the remove method of the LifeCycleObject interface must be called. Once a CORBA View is instantiated,
it must remain active (in memory) for the lifetime of the View unless the COM or Automation objects supports the IMonikerProvider
interface. If the COM or Automation object supports the IMonikerProvider interface, then the CORBA View can safely be deactivated
and reactivated provided it stores the object’s moniker in persistent storage between activations. Interworking solutions
are not required to support deactivation and activation of CORBA View objects, but are enabled to do so by the IMonikerProvider
interface.