Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / July 2005

Tip: Looking for answers? Try searching our database.

Stateless objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveL - 24 Jul 2005 11:12 GMT
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
Johannes Passing - 25 Jul 2005 17:11 GMT
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

> Hi,
> If I have a class installed in COM+, which has class level private
[quoted text clipped - 12 lines]
>
> Steve
SteveL - 28 Jul 2005 10:20 GMT
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

> If both users call CoCreateInstance, both will get their own instance of
> this class - regardless of whether object pooling is enabled or not.
[quoted text clipped - 24 lines]
>>
>> Steve
Johannes Passing - 28 Jul 2005 20:38 GMT
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

> Thanks Johannes,
> What if the users are calling a web service that just instantiates the
[quoted text clipped - 47 lines]
>>>
>>>Steve

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.