开发者

Component Level Properties In Application.cfc

If I have component level properties in my application.cfc will they get evaluated every time a page is it or will they only get evaluated when the application is created?

<cfcomponent>
    <cfscript>
        this.name = "WARM2_Demo";
        this.applicationTimeout = CreateTimeSpan(1,0,0,0);
        this.s开发者_运维问答etClientCookies = true;
        this.setDomainCookies = false;
        this.sessionManagement = true;
        this.sessionTimeout = CreateTimeSpan(0,0,30,0);
        this.clientManagement = false;
        this.scriptProtect = true;

        this.appDirectory = getDirectoryFromPath(getCurrentTemplatePath());
        this.fileSeparator = createObject("java","java.lang.System").getProperty("file.separator");

         ....

    </cfscript>

    <cffunction name="OnApplicationStart" returntype="boolean">
        <cfscript>
            setupApplication();
            return true;
        </cfscript>
    </cffunction>

        ....

</cfcomponent>


The pseudo-constructor of Application.cfc is executed every request.

Basically behind the scenes an instance of Application.cfc is created every request, and that instantiation behaves just like any other CFC instantiation: the pseudo-constructor bit - the stuff inside the CFCOMPONENT tags but outwith any CFFUNCTION / function declarations - is run.

After the pseudo-constructor is run, any appropriate event handler / interceptor methods are run, eg: onRequestStart().

NB: you could test this very easily yourself by just outputting something in there. It'll show up on the screen on every request (make it a getTickCount() or createUuid() call so you can see it changing).


evaluated every time a page is requested, I think.

stick them in Application scope in onApplicationStart()

but honestly, fileSeparator?? Just use /, it'll work on Windows and *nix OS just fine. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜