Using the COM+ Shared Property Manager, Part 2By 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
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.
SharedPropertyGroup is a simply a namespace for the
have multiple shared properties, which are referred and retrieved by name or by its position. The
following provides the declaration for Shared Property Group:
The Shared Property allows us to Store or retrieve a value. The Shared Property can be accessed only from within a Shared Property Group.
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
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 value
TRUE, if the Shared Property already exists, otherwise it returns
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
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
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.
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,
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.
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.