|
I was wondering if someone can see why I can’t seem to
get my singleton from the following function? <cffunction access="private"
name="getInstance"
output="false"
returntype="Object"
displayname="Get
Instance" hint="Returns
an instance of the object, gets it from the persistent scope if the class is a
singleton."> <cfscript> var
mySingletonPath = ""; //
Check if this object is a singleton if
( isSingleton() ) { mySingletonPath
= getSingletonScope() & ".hash" & getClassPathAsHash() &
".hash" & hash( getMetaData( this ).name ); //
Check if the singleton is instantiated if
( NOT isDefined( mySingletonPath ) ) { setInstanceVariable(
variableName = "initialized", value = true ); setClassVariable(
variableName = "hash" & hash( getMetaData( this ).name ), value =
this, scope = getSingletonScope() ); } //
Return the Singleton //getClassVariable(
variableName = "hash" & hash( getMetaData( this ).name ), scope =
getSingletonScope() ).dumpInstance();abort(); return
getClassVariable( variableName = "hash" & hash( getMetaData( this
).name ), scope = getSingletonScope() ); } setInstanceVariable(
variableName = "initialized", value = true ); //
Return a new instance of this object return
this; </cfscript> </cffunction> Let’s say if I set a variable in the object with a value
of “1”, instantiate the object, change the value to “2”
save the object and instantiate it again, and then call dumpInstance() I expect
the value to be “1” not “2”. When I uncomment the following line it outputs the expected
result, i.e. an instance variable with the value “1” //getClassVariable( variableName = "hash" &
hash( getMetaData( this ).name ), scope = getSingletonScope()
).dumpInstance();abort(); But when I later dump it from the file that instantiates the
object it outputs “2” FormProcess = new ( "com.pacificMomentum.data.FormProcess"
).init(); FormProcess.dumpInstance();abort(); PS. dumpInstance() is one of my own methods which dumps instance
variables BTW. The init() method in the object returns getInstance() BTW
i.e. return getInstance(); ________________________________ Shelco Searches & Services An Authorised ASIC Information Broker Ph: + 61 7 3236 2605 You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/ |
