1
- <!--- --------------------------------------------------------------------
1
+ /**
2
2
********************************************************************************
3
3
Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4
- www.coldbox.org | www.luismajano.com | www.ortussolutions.com
4
+ www.coldboxframework.com | www.luismajano.com | www.ortussolutions.com
5
5
********************************************************************************
6
-
7
- Author : Luis Majano
8
- Date : 10/16/2007
9
- Description :
10
- This is the Application.cfc for usage withing the ColdBox Framework.
11
- Make sure that it extends the coldbox object:
12
- coldbox.system.Coldbox
13
-
14
- So if you have refactored your framework, make sure it extends coldbox.
15
- ----------------------------------------------------------------------->
16
- < cfcomponent output = " false" >
17
- < cfsetting enablecfoutputonly = " yes" >
18
-
19
- <!--- APPLICATION CFC PROPERTIES --->
20
- < cfset this .name = hash ( getCurrentTemplatePath () )>
21
- < cfset this .sessionManagement = true >
22
- < cfset this .sessionTimeout = createTimeSpan (0 ,0 ,30 ,0 )>
23
- < cfset this .setClientCookies = true >
24
-
25
- <!--- COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP --->
26
- < cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath (getCurrentTemplatePath ())>
27
- <!--- The web server mapping to this application. Used for remote purposes or static purposes --->
28
- < cfset COLDBOX_APP_MAPPING = " " >
29
- <!--- COLDBOX PROPERTIES --->
30
- < cfset COLDBOX_CONFIG_FILE = " " >
31
- <!--- COLDBOX APPLICATION KEY OVERRIDE --->
32
- < cfset COLDBOX_APP_KEY = " " >
33
-
34
- <!--- on Application Start --->
35
- < cffunction name = " onApplicationStart" returnType = " boolean" output = " false" >
36
- < cfscript >
37
- // Load ColdBox Bootstrap
38
- application .cbBootstrap = new coldbox .system .Coldbox ( COLDBOX_CONFIG_FILE , COLDBOX_APP_ROOT_PATH , COLDBOX_APP_KEY , COLDBOX_APP_MAPPING );
39
- application .cbBootstrap .loadColdbox ();
40
- return true ;
41
- < / cfscript >
42
- < / cffunction >
43
-
44
- <!--- on Request Start --->
45
- < cffunction name = " onRequestStart" returnType = " boolean" output = " true" >
46
- <!--- ************************************************************* --->
47
- < cfargument name = " targetPage" type = " string" required = " true" / >
48
- <!--- ************************************************************* --->
49
- <!--- BootStrap Reinit Check --->
50
- < cfif not structKeyExists ( application , " cbBootstrap" ) or application .cbBootStrap .isfwReinit ()>
51
- < cflock name = " coldbox.bootstrap_#hash ( getCurrentTemplatePath () ) #" type = " exclusive" timeout = " 5" throwontimeout = " true" >
52
- < cfset structDelete ( application , " cbBootStrap" )>
53
- < cfset onApplicationStart ()>
54
- < / cflock >
55
- < / cfif >
56
- <!--- On Request Start via ColdBox --->
57
- < cfset application .cbBootstrap .onRequestStart ( arguments .targetPage )>
58
-
59
- < cfreturn true >
60
- < / cffunction >
61
-
62
- <!--- on Application End --->
63
- < cffunction name = " onApplicationEnd" returnType = " void" output = " false" >
64
- <!--- ************************************************************* --->
65
- < cfargument name = " appScope" type = " struct" required = " true" >
66
- <!--- ************************************************************* --->
67
- < cfset arguments .appScope .cbBootstrap .onApplicationEnd ( argumentCollection = arguments )>
68
- < / cffunction >
69
-
70
- <!--- on Session Start --->
71
- < cffunction name = " onSessionStart" returnType = " void" output = " false" >
72
- < cfset application .cbBootstrap .onSessionStart ()>
73
- < / cffunction >
74
-
75
- <!--- on Session End --->
76
- < cffunction name = " onSessionEnd" returnType = " void" output = " false" >
77
- <!--- ************************************************************* --->
78
- < cfargument name = " sessionScope" type = " struct" required = " true" >
79
- < cfargument name = " appScope" type = " struct" required = " false" >
80
- <!--- ************************************************************* --->
81
- < cfset appScope .cbBootstrap .onSessionEnd ( argumentCollection = arguments )>
82
- < / cffunction >
83
-
84
- <!--- OnMissing Template --->
85
- < cffunction name = " onMissingTemplate" access = " public" returntype = " boolean" output = " true" hint = " I execute when a non-existing CFM page was requested." >
86
- < cfargument name = " template" type = " string" required = " true" hint = " I am the template that the user requested." / >
87
- < cfreturn application .cbBootstrap .onMissingTemplate ( argumentCollection = arguments )>
88
- < / cffunction >
89
-
90
- < / cfcomponent >
6
+ */
7
+ component {
8
+ // Application properties
9
+ this .name = hash ( getCurrentTemplatePath () );
10
+ this .sessionManagement = true ;
11
+ this .sessionTimeout = createTimeSpan (0 ,0 ,30 ,0 );
12
+ this .setClientCookies = true ;
13
+
14
+ // Mappings Imports
15
+ import coldbox .system .* ;
16
+
17
+ // COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP
18
+ COLDBOX_APP_ROOT_PATH = getDirectoryFromPath ( getCurrentTemplatePath () );
19
+ // The web server mapping to this application. Used for remote purposes or static purposes
20
+ COLDBOX_APP_MAPPING = " " ;
21
+ // COLDBOX PROPERTIES
22
+ COLDBOX_CONFIG_FILE = " " ;
23
+ // COLDBOX APPLICATION KEY OVERRIDE
24
+ COLDBOX_APP_KEY = " " ;
25
+
26
+ // application start
27
+ public boolean function onApplicationStart (){
28
+ application .cbBootstrap = new coldbox .system .Bootstrap ( COLDBOX_CONFIG_FILE , COLDBOX_APP_ROOT_PATH , COLDBOX_APP_KEY , COLDBOX_APP_MAPPING );
29
+ application .cbBootstrap .loadColdbox ();
30
+ return true ;
31
+ }
32
+
33
+ // request start
34
+ public boolean function onRequestStart (String targetPage ){
35
+
36
+ // Bootstrap Reinit
37
+ if ( not structKeyExists (application ," cbBootstrap" ) or application .cbBootStrap .isfwReinit () ){
38
+ lock name = " coldbox.bootstrap_#this .name #" type = " exclusive" timeout = " 5" throwonTimeout = true {
39
+ structDelete ( application , " cbBootStrap" );
40
+ onApplicationStart ();
41
+ }
42
+ }
43
+
44
+ // Process ColdBox Request
45
+ application .cbBootstrap .onRequestStart ( arguments .targetPage );
46
+
47
+ return true ;
48
+ }
49
+
50
+ public void function onSessionStart (){
51
+ application .cbBootStrap .onSessionStart ();
52
+ }
53
+
54
+ public void function onSessionEnd ( struct sessionScope , struct appScope ){
55
+ arguments .appScope .cbBootStrap .onSessionEnd ( argumentCollection = arguments );
56
+ }
57
+
58
+ public boolean function onMissingTemplate ( template ){
59
+ return application .cbBootstrap .onMissingTemplate ( argumentCollection = arguments );
60
+ }
61
+
62
+ }
0 commit comments