Skip to content

Commit 5de4ca6

Browse files
committedSep 17, 2015
Correct example Application.cfc files
1 parent 0e45fe8 commit 5de4ca6

File tree

2 files changed

+81
-28
lines changed

2 files changed

+81
-28
lines changed
 

‎Application.cfc

+40-14
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,61 @@
11
component {
2+
// copy this to your application root to use as your Application.cfc
3+
// or incorporate the logic below into your existing Application.cfc
4+
25
// you can provide a specific application name if you want:
36
this.name = hash( getBaseTemplatePath() );
7+
48
// any other application settings:
59
this.sessionManagement = true;
6-
this.mappings[ '/framework' ] =
7-
getDirectoryFromPath( getBaseTemplatePath() ) & 'framework';
810

9-
// create your FW/1 application:
10-
request._framework_one = new framework.one( {
11-
trace = true,
12-
base = getDirectoryFromPath( CGI.SCRIPT_NAME )
13-
.replaceFirst( getContextRoot(), '' ) & 'introduction'
14-
} );
11+
// set up per-application mappings as needed:
12+
this.mappings[ '/framework' ] = getDirectoryFromPath( getBaseTemplatePath() ) & 'framework';
13+
// this.mappings[ '/app' ] expandPath( '../path/to/app' );
14+
15+
function _get_framework_one() {
16+
if ( !structKeyExists( request, '_framework_one' ) ) {
17+
18+
// create your FW/1 application:
19+
request._framework_one = new framework.one( {
20+
trace = true,
21+
base = getDirectoryFromPath( CGI.SCRIPT_NAME )
22+
.replaceFirst( getContextRoot(), '' ) & 'introduction'
23+
} );
24+
25+
// you can specify FW/1 configuration as an argument:
26+
// request._framework_one = new framework.one({
27+
// base : '/app',
28+
// trace : true
29+
// });
30+
31+
// if you need to override extension points, use
32+
// MyApplication.cfc for those and then do:
33+
// request._framework_one = new MyApplication({
34+
// base : '/app',
35+
// trace : true
36+
// });
37+
38+
}
39+
return request._framework_one;
40+
}
1541

1642
// delegation of lifecycle methods to FW/1:
1743
function onApplicationStart() {
18-
return request._framework_one.onApplicationStart();
44+
return _get_framework_one().onApplicationStart();
1945
}
2046
function onError( exception, event ) {
21-
return request._framework_one.onError( exception, event );
47+
return _get_framework_one().onError( exception, event );
2248
}
2349
function onRequest( targetPath ) {
24-
return request._framework_one.onRequest( targetPath );
50+
return _get_framework_one().onRequest( targetPath );
2551
}
2652
function onRequestEnd() {
27-
return request._framework_one.onRequestEnd();
53+
return _get_framework_one().onRequestEnd();
2854
}
2955
function onRequestStart( targetPath ) {
30-
return request._framework_one.onRequestStart( targetPath );
56+
return _get_framework_one().onRequestStart( targetPath );
3157
}
3258
function onSessionStart() {
33-
return request._framework_one.onSessionStart();
59+
return _get_framework_one().onSessionStart();
3460
}
3561
}

‎examples/Application.cfc

+41-14
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,62 @@
11
component {
2+
// copy this to your application root to use as your Application.cfc
3+
// or incorporate the logic below into your existing Application.cfc
4+
25
// you can provide a specific application name if you want:
3-
this.name = 'fw1-examples';
6+
this.name = 'fw1-examples';
7+
48
// any other application settings:
59
this.sessionManagement = true;
10+
11+
// set up per-application mappings as needed:
612
this.mappings[ '/framework' ] = expandPath( '../framework' );
13+
// this.mappings[ '/app' ] expandPath( '../path/to/app' );
14+
15+
function _get_framework_one() {
16+
if ( !structKeyExists( request, '_framework_one' ) ) {
717

8-
// create your FW/1 application:
9-
request._framework_one = new framework.one( {
10-
SESOmitIndex = true,
11-
diLocations = "model, controllers, beans, services", // to account for the variety of D/I locations in our examples
12-
// that allows all our subsystems to automatically have their own bean factory with the base factory as parent
13-
trace = true
14-
} );
18+
// create your FW/1 application:
19+
request._framework_one = new framework.one( {
20+
SESOmitIndex = true,
21+
diLocations = "model, controllers, beans, services", // to account for the variety of D/I locations in our examples
22+
// that allows all our subsystems to automatically have their own bean factory with the base factory as parent
23+
trace = true
24+
} );
25+
26+
// you can specify FW/1 configuration as an argument:
27+
// request._framework_one = new framework.one({
28+
// base : '/app',
29+
// trace : true
30+
// });
31+
32+
// if you need to override extension points, use
33+
// MyApplication.cfc for those and then do:
34+
// request._framework_one = new MyApplication({
35+
// base : '/app',
36+
// trace : true
37+
// });
38+
39+
}
40+
return request._framework_one;
41+
}
1542

1643
// delegation of lifecycle methods to FW/1:
1744
function onApplicationStart() {
18-
return request._framework_one.onApplicationStart();
45+
return _get_framework_one().onApplicationStart();
1946
}
2047
function onError( exception, event ) {
21-
return request._framework_one.onError( exception, event );
48+
return _get_framework_one().onError( exception, event );
2249
}
2350
function onRequest( targetPath ) {
24-
return request._framework_one.onRequest( targetPath );
51+
return _get_framework_one().onRequest( targetPath );
2552
}
2653
function onRequestEnd() {
27-
return request._framework_one.onRequestEnd();
54+
return _get_framework_one().onRequestEnd();
2855
}
2956
function onRequestStart( targetPath ) {
30-
return request._framework_one.onRequestStart( targetPath );
57+
return _get_framework_one().onRequestStart( targetPath );
3158
}
3259
function onSessionStart() {
33-
return request._framework_one.onSessionStart();
60+
return _get_framework_one().onSessionStart();
3461
}
3562
}

0 commit comments

Comments
 (0)
Please sign in to comment.