So when you create your object, you have it check for an instance of itself in the local scope, and create a new one if one doesn't exist and pass it back? For some reason, it isn't quite 'clicking' with me... If you use createObject in your application to create an instance of the singleton class, how do you prevent another createObject call from creating another, unique instance of the class? Or can you only ensure there's only one instance per scope? Maybe it's the fact that CF makes us use a pseudo constructor that's throwing me off...
On Apr 7, 2005 8:35 PM, Darryl Lyons <[EMAIL PROTECTED]> wrote: > That's pretty much the method we use here too. We pass in the arguments to > the init() method as well. > > Darryl Lyons > http://dangermoose.blogspot.com > > [EMAIL PROTECTED] wrote on 08/04/2005 09:38:05 AM: > > > Do you mean something just like (real cheap n' nasty version)- > > > > <cfscript> > > function getSingleton() > > { > > if(NOT structKeyExists(instance, "singleton")) > > { > > instance.singleton = createObject("component", > "singleton").init(); > > } > > > > return instance.singleton; > > } > > </cfscript> > > > > Lide that? or you asking something more complicated here? > > > > On Apr 8, 2005 12:31 AM, Ken Dunnington <[EMAIL PROTECTED]> > wrote: > > > > > > > > Just to start yet another tangent :) can anyone point me to a good > > > reference on using Singleton in CF? Again, thanks for all the input. > > > > > -- > > E: [EMAIL PROTECTED] > > W: www.compoundtheory.com > > ICQ: 3094740 > > > > > > ---------------------------------------------------------- > > 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). > > > > An archive of the CFCDev list is available at > > www.mail-archive.com/[email protected] > > > > > > To unsubscribe from this email please forward this email to [EMAIL PROTECTED] > > This email message is confidential and may be privileged. Unauthorised use, > copying or distribution of any part of this email > including attachments is prohibited. If you are not the intended recipient > please forward the email to [EMAIL PROTECTED] > and delete the original. > > ABN AMRO Morgans Limited and its associates hold or may hold securities in > the companies/trusts mentioned herein. Any general > advice included in this email has been prepared without taking into account > your objectives, financial situation or needs. Before > acting on the advice, you should consider its appropriateness or discuss with > one of our investment advisors. > > To the extent permitted by law we exclude (and where the law does not permit > an exclusion, limit to the extent permitted by law) all > liability for any direct, indirect and consequential costs, losses, damages > and expenses incurred in any way (including but not limited > to that arising from negligence), connected with any use or access to this > email or any reliance on information contained in this email > or any attachments. > > ABN AMRO Morgans Limited (ABN 49 010 669 726 AFSL 235410) A Participant of > ASX Group A Principal Member of the > Financial Planning Association > > > ---------------------------------------------------------- > 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). > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > > -- It's a metaphor for life itself. For that matter, everything in life is a metaphor for life. Except life. Life is probably a metaphor for metaphor. -- James Lileks ---------------------------------------------------------- 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). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
