I just want to add a tip ...
In the real world you will need sometimes to run multiple instances of your
app on the server, you may want to
have different databases, diferent roots and paths, this will happen also
for test/deploy situations.
Since SERVER scope is accessible by the entire server, if you want to have
multiple instances of your application on the same server
you will also want multiple configuration sets.
It would be nice to build a structure so you may handle the different
instances, something like:
<cffunction name="init">
<cfargument name="aplicationName">
<cfif NOT structKeyExists(server,"myCFCConfig")>
<cfset server.myCFCConfig = structNew()>
</cfif>
<cfif NOT
structKeyExists(server.myCFCConfig,"#arguments.aplicationName#")>
DO INSTANCE CONFIG
<cfset server.myCFCConfig[arguments.aplicationName] = StructNew()><!--- or
anything --->
<cfset server.myCFCConfig[arguments.aplicationName].name =
arguments.aplicationName>
</cfif>
<cfset variables.config = server.myCFCConfig[arguments.aplicationName]>
<cfreturn variables>
</cffunction>
You then can have:
<cfdump var="#init("oneApp")#">
<cfdump var="#init("otherApp")#">
And all your apps will be here:
<cfdump var="#server.myCFCConfig#">
Regards,
Marcantonio da Silva
Diretor de Desenvolvimento de Produtos
[EMAIL PROTECTED]
Navita - http://www.navita.com.br
55 (11) 3365-2173 - (11) 9656-4634
----- Original Message -----
From: "Nathan Dintenfass" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 16, 2003 4:27 PM
Subject: RE: [CFCDev] Initialize only once
> Well, at some point you'll need to put something in a persistent memory
> scope if you want it to stick around from request to request (assuming you
> don't want to read it off the file system/network every time). My initial
> suggestion about the server scope was, in fact, to use it internal to the
> CFC. So, something like:
>
> <cffunction name="init">
> <cfif NOT structKeyExists(server,"myCFCConfig")>
> DO CONFIG
> </cfif>
> <cfset variables.config = server.myCFCConfig>
> </cffunction>
>
> Again, this is not really a best practice, but if you really want it to be
> "inside" your CFC you'll need to do something along those lines.
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Bryan F. Hogan
> > Sent: Thursday, October 16, 2003 10:08 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [CFCDev] Initialize only once
> >
> >
> > This would also work, but I'm looking for a way to do it within
> > the CFC and not rely on any outside files or scopes.
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Nathan Dintenfass
> > Sent: Thursday, October 16, 2003 10:06 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: [CFCDev] Initialize only once
> >
> >
> > You could use the server scope -- it still breaks encapsulation to some
> > extent, so it's not really a "best practice", but since you KNOW
> > the server
> > scope will always exist (unlike Application and Session scope) it
> > strikes me
> > as less of a violation of encapsulation.
> >
> > Alternatively, if you want to make things cleaner you could make
> > a separate
> > component that hold configuration info and cache that instance,
> > then feed it
> > to your component when you init().
> >
> >
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email
> > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> > in the message of the email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > by Mindtool, Corporation (www.mindtool.com).
> >
> > An archive of the CFCDev list is available at
> > www.mail-archive.com/[EMAIL PROTECTED]
> >
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]