You need to use the onApplicationStart method. It is run once per
application startup. You can then remove the CFIF around the code.
Also, you can combine the cfobject, cfset into one line:
<cfset application.xr = createObject("component", "xr")>
On Mon, Feb 2, 2009 at 1:03 PM, Kevin Lemke <[email protected]> wrote:
>
> I have an application that is using an application.cfc with the following
> code at its top:
>
> <cfcomponent>
> <CFSET This.name = "XR">
> <CFSET This.SESSIONMANAGEMENT = "true">
> <CFSET This.CLIENTMANAGEMENT = "true">
> <CFSET This.CLIENTSTORAGE = "cookie">
> <CFSET This.LOGINSTORAGE = "session">
> <CFSET This.APPLICATIONTIMEOUT = "#CreateTimeSpan(0,18,0,0)#">
> <CFSET This.SESSIONTIMEOUT = "#CreateTimeSpan(0,0,20,0)#">
> <cfset THIS.mappings["/MyMap"]="D:\inetpub\wwwroot\xr">
> <!--- See if the application component needs to be created --->
> <CFIF NOT IsDefined("application.xr")>
> <!--- Create the component --->
> <CFOBJECT name="xr" component="xr">
> <CFSET application.xr = xr>
> </CFIF>
>
> ........
>
> I then invoke the component within my web pages as follows:
>
> <CFINVOKE component="#application.xr#" method="imageXML"
> returnvariable="listingsstr" imagepath="#coffeepath#" imageURL="../coffee">
>
> and everything works fine.
>
> However, I was under the assumption that the component would be created and
> persist for 18 hours, as specified in my
>
> <CFSET This.APPLICATIONTIMEOUT = "#CreateTimeSpan(0,18,0,0)#">
>
> But, it is executing the code inside
>
> <CFIF NOT IsDefined("application.xr")> .... </CFIF>
>
> each time the application.cfc is run.
>
> Am I doing something wrong or do I not understand how this should work? I
> thought it would make sense to only instansiate the compnent once every 18
> hours and let everybody invoke it. Instead I get it instansiated only for
> the one webpage and a new one is instansiated again, even for the same user a
> few seconds later.
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318755
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4