Using the COM+ Shared Property Manager, Part 2
By Ramesh Balaji
In Part 1 we looked at the basic problem at hand - developing an efficient three-tiered Web site. In our quest, though, we encountered a slight problem - too many database accesses led to decreased performance. To remedy this problem, we looked at using the COM+ Shared Property Manager from a high-level view. In this part, we'll dig into the COM+ Shared Property Manager and look at some source code!
To use the COM+ Shared Property feature we need to make sure that we set the references to
"COM+ Services Type Library" which is implemented in \Winnt\System32\COMSVCS.DLL.
As stated earlier, that Shared Property Group prevents naming collisions by setting unique namespaces
for Shared Properties.
So to create a SharedPropertyGroup, we need to have a SharedPropertyGroupManager.
Dim objSharedGroupMgr As COMSVCSLib.SharedPropertyGroupManager
|
The SharedPropertyGroup is a simply a namespace for the SharedProperty. The
SharedPropertyGroup can
have multiple shared properties, which are referred and retrieved by name or by its position. The
following provides the declaration for Shared Property Group:
Dim objSharedPropertyGroup As COMSVCSLib.SharedPropertyGroup
|
The Shared Property allows us to Store or retrieve a value. The Shared Property can be accessed only from within a Shared Property Group.
Dim objSharedProperty As COMSVCSLib.SharedProperty
|
Now that we've looked at declaring the needed variables, let's examine the object creation process.
|
The first statement is rather simple - it creates an instance of the SharedPropertyGroupManager.
In the second statement, we create a SharedPropertyGroup. Let's examine every parameter in the
Shared Property Group.
- The First Parameter,
Automobile, represents the name of the Shared Property Group.
- The Second Parameter specifies the type of lock for the Shared Property. The
LockSetGetparameter, when specified, makes sure that no two clients can read or write to the property at the same time.
- The Third Parameter specifies the lifetime of the Shared Property. The
Processparameter, when specified, allows the Shared Property to remain until the process, which it is running, is terminated.
- The Fourth Parameter indicates whether the Shared Property already exists or not. The
fExistswill return a valueTRUE, if the Shared Property already exists, otherwise it returnsFALSE.
Let's now see the creation of Shared Property, which is the fundamental area of storage.
|
Let's keenly look at the Shared Property name, which is stored in the variable strProductName.
For every product Name in the Product Line, we need to have a Shared Property. Only in this procedure
we need to access the database and store the values in the Shared Property, which is named against the
product.
For rest of the procedure, the values can be retrieved from the Shared Property itself, instead of
connecting to the database and retrieving from it, which increases the performance.
I am going to skip few lines of code where we create a connection to the database and store the results of the product in the disconnected recordset. Once we obtain the recordset for the first time, we store the recordset to the Shared Property named against the product using this simple statement.
objSharedProperty.Value = objRecordset.
|
Presentation Layer
If we look at the code in the presentation layer, it 's rather simple since all we need to do
is create the instance of our Business Layer component, prjCOM.clsCOMSharedProperty.
In our ASP page we simply pass the Product Line and Product names in the
GetAutoMobileFeatures method, which returns the recordset from the Shared Property.
|
Conclusion
In this article we examined how to make use of COM+ Shared Property feature.
If you are planning to implement the feature in your development process, make sure you have
sufficient memory in your production environment.
Happy Programming!
Related Articles:



