Component
Naming and GUIDs
Gopalan Suresh Raj
Food for Thought... |
|
|
In C++, Global Namespace Corruption happens when we place names
in global scope and a collision occurs with the same names that
are in use elsewhere within the system being compiled and linked
as a single executable module.
In COM+, the global namespace is the aggregate of all possible
computing devices in the world. Because your COM+ component may
be remotely activated on any system in the world, it is important
that the name given to the component implementation and
interfaces are really unique across all possible execution
environments.
Globally Unique
Identifiers (GUID)
COM+ uses Globally Unique Identifiers (GUIDs) to name Interfaces
and their Implementations. The concept of a GUID was originally
conceived by the Open Software Foundation (OSF) for their
Distributed Computing Environment (DCE). The GUID is a unique
value in both space and time. It is generated on your
development machine by a standard OSF DCE algorithm. It is this
DCE algorithm that allows rapid development of COM+ objects
without requiring use of namespace partitions. COM+ provides a
tool called GUIDGEN that generates a unique GUID based on spacial
and temporal information.
GUIDs are 16-byte extremely long integers. They are defined as a struct in C/C++. The internal representation of a GUID is
shown below:
|
Since this structure is large for an identifier, a datatype is defined in the standard headers that is used to pass GUIDs by value. These datatypes are defined as follows:
|
GUIDs are used to eliminate name
collisions across libraries. Each interface has a GUID called an
Interface ID (IID). Each COM+ implementation has a unique GUID
called the Class ID (CLSID). Both IID and CLSID are typedefs of
GUID and are therefore type compatible with one another.
GUIDs are generated by a tool called GUIDGEN.EXE which is
available in the Windows Platform SDK and is also bundled for
convenience with development tools like Microsoft Visual Studio.
Internally, GUIDGEN calls the COM+ API CoCreateGUID() to generate a unique GUID. You can use the COM API
to dynamically create GUIDs. It is defined as follows:
|
COM also provides functions for comparing GUIDs as follows:
|
Similarly, if you ever need to define a GUID in a C/C++ header file, use the DEFINE_GUID macro as follows:
|
The algorithm used for generating
the GUID is decentralized which means you can generate unique
GUIDs from your local development machine.
The following code snippet shows how GUIDs can be generated
programmatically using Java code in Visual J++.
|
The following code snippet shows how GUIDs can be generated programmatically using Visual Basic.
|
![]() |
click here to go
to My Basic COM+ Tutorial... |
click here to go
to My Advanced COM+/DNA Tutorial HomePage... |
About the Author... |
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He is contributing author to a couple of books "Enterprise Java Computing-Applications and Architecture" and "The Awesome Power of JavaBeans". His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia© site (http://www.execpc.com/~gopalan) or mail him at gopalan@execpc.com. |
This site was developed and is maintained by Gopalan Suresh Raj This page has been visited |
Last Updated : Mar 14,'99 |
Copyright (c) 1997-2000, Gopalan Suresh Raj - All rights reserved. Terms of use. |
All products and companies mentioned at this site are trademarks of their respective owners. |