all groups > dotnet component services > july 2005 >
You're in the

dotnet component services

group:

Stateless objects


Stateless objects SteveL
7/24/2005 12:00:00 AM
dotnet component services: Hi,
If I have a class installed in COM+, which has class level private
variables, can the values be exposed to other users of the class if object
pooling is not enabled.

For example class 1 is used by UserA and a private variable is set in the
class. If UserB is using the same class is there a danger that UserB will
be using values set by UserA or do they instantiate their own instance of
the class.

If object pooling is turned off, does this mean that this can never happen
or do I need to completely remove all my class level variables?

Appreciate your help.

Steve

Re: Stateless objects Johannes Passing
7/25/2005 12:00:00 AM
If both users call CoCreateInstance, both will get their own instance of
this class - regardless of whether object pooling is enabled or not.

If you are using pooling, the client may get a recycled instance - thus,
it is your duty to clear all member variables when implementing
IObjectControl to avoid another client retrieving a 'dirty' object.

In any case, you should be very careful with storing data in member
variables if you are using transactions...

/Johannes

[quoted text, click to view]
Re: Stateless objects SteveL
7/28/2005 12:00:00 AM
Thanks Johannes,
What if the users are calling a web service that just instantiates the
object and aren't calling coCreateInstance and the objects in COM+ do not
implement the IObjectControl interface. Long story but basically the only
reason that they are in COM+ is because company standards forced it on us at
the last minute. All our objects inherit from a base class and when we
build in release mode, conditional compilation, the base class inherits from
serviced component. They doesn't use any of the COM+ features, they are
just in there!

i.e.
In a method they are creating the class below:
myClass oClass = new myClass;


class myClass
{
private int _myVar;

}

Could they still get a dirty object?
Steve

[quoted text, click to view]

Re: Stateless objects Johannes Passing
7/28/2005 9:38:45 PM
The same scheme applies - if you do not use object pooling, you will not
receive a recycled (and thus, possibly 'dirty') object. If you do use
pooling, you should implement IObjectControl - or in case of ES,
overwrite ServicedComponent::Activate() and ServicedComponent::Deactivate().

/Johannes

[quoted text, click to view]
AddThis Social Bookmark Button