Platform SDK: Transaction Server |
ISharedPropertyGroupManager Interface
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
The ISharedPropertyGroupManager interface is used to create shared property groups and to obtain access to existing shared property groups.
Remarks
The header file for the ISharedPropertyGroupManager interface is mtxspm.h. You must also link mtxguid.lib to your project to use this interface.
You can access the ISharedPropertyGroupManager interface by creating an instance of the SharedPropertyGroupManager by using either IObjectContext::CreateInstance or CoCreateInstance. It makes no difference which you use.
CreateInstance method of the ObjectContext object. It makes no difference which you use.
The Shared Property Manager is a resource dispenser that you can use to share state among multiple objects within a server process. You can't use global variables in a distributed environment because of concurrency and name collision issues. The Shared Property Manager eliminates name collisions by providing shared property groups, which establish unique name spaces for the shared properties they contain. The Shared Property Manager also implements locks and semaphores to protect shared properties from simultaneous access, which could result in lost updates and could leave the properties in an unpredictable state.
Shared properties can be shared only by objects running in the same process. If you want instances of different components to share properties, you have to install the components in the same MTS package. Because there is a risk that administrators will move components from one package to another, it's safest to limit the use of a shared property group to instances of components that are defined in the same DLL.
It's also important for components sharing properties to have the same activation attribute. If two components in the same package have different activation attributes, they generally won't be able to share properties. For example, if one component is configured to run in a client's process and the other is configured to run in a server process, their objects will usually run in different processes, even though they're in the same package.
You should always instantiate the SharedPropertyGroupManager, SharedPropertyGroup, and SharedProperty objects from MTS objects rather than from a base client. If a base client creates shared property groups and properties, the shared properties are inside the base client's process, not in a server process. This means MTS objects can't share the properties unless the objects, too, are running in the client's process (which is generally not a good idea).
Note When you set the isolation mode to LockMethod, the Shared Property Manager requires access to the calling object's ObjectContext. You can't use this isolation mode to create a shared property group from within an object's constructor or from a non-MTS object because ObjectContext isn't available during object construction and a non-MTS object doesn't have an ObjectContext.
The ISharedPropertyGroupManager interface exposes the following methods and properties.
Method | Description |
---|---|
CreatePropertyGroup | Creates a new SharedPropertyGroup with a string name as an identifier. If a group with the specified name already exists, CreatePropertyGroup returns a reference to the existing group. |
get_Group | Returns a reference to an existing shared property group, given a string name by which it can be identified. |
get__NewEnum | Returns a reference to an enumerator that iterates through a list of all the shared property groups in a given process. |
See Also