No, you have a single instance and multiple references to it, where each reference is method-specific. You'll need to create a messageHandler instance inside each method and use it, rather than a global instance of it. I.e. change getMH to return a newly created instance instead of a shared instance. Since you're returning the data inside the messageHandler, there is no need for it to live longer than a single method invocation anyway, aside from the cost of instantiating them all the time, but that can be mostly mitigated by pooling. And that instantiation cost really isn't all that large, so I wouldn't even consider it until load testing indicates it's a bottleneck, and then you can consider pooling.
cheers, barneyb On 10/25/05, Ryan Guill <[EMAIL PROTECTED]> wrote: > Hey guys, > > i just had a thought and need to know exactly how this works. > > I have a component that I am using in composition in some of my other > components. I have a messageHandler, which an object is being created > of in all of my daos. In every method that runs, it inits() or resets > the object, the method uses the messageHandler methods, it then > returns the information stored in the message handler. then the next > method that runs will init() and reset it again and the process > repeats. > > I am createing an object out of the messageHandler in every dao when > the dao object is created and then the same messageHandler object is > being reused over and over. I am bringing it into each method like so > <cfset VAR mh = getMH() /> and getMH() just returns the reference to > the object. > > So my question is this: since i am using VAR inside each of the > methods, is it really creating it locally? My worry is that it is not > even still, and so if one method of my dao starts to run, and another > method starts to run before the first one is completed will the init() > of the second method clear out the data of the first ones instance? > > If so, then the only way I see around this is to create the > messageHandler object for each method, or put exclusive locks in every > method. I hope this really isnt the case... > > thanks, > -- > Ryan Guill > BlueEyesDevelopment > [EMAIL PROTECTED] > www.ryanguill.com > (270) 217.2399 > got google talk? Chat me at [EMAIL PROTECTED] > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
