Application.cfc
Определяет переменные уровня приложения и обработчики событий (функции, вызываемые при различных событиях жизненного цикла приложения).
component { this.name="myApp"; }
Application.cfc
this.name string
this.loginStorage string
По умолчанию: cookie
cookie
cookiesession
this.clientManagement boolean
По умолчанию: false
false
truefalse
this.clientStorage string
По умолчанию: registry
registry
cookieregistrydatasource_name
this.setClientCookies boolean
По умолчанию: true
true
truefalse
this.sessionManagement boolean
По умолчанию: false
false
truefalse
this.sessionTimeout numeric
this.applicationTimeout numeric
this.setDomainCookies boolean
По умолчанию: false
false
truefalse
this.scriptProtect string
noneallformurlcookiecgiform,urlform,url,cookieform,url,cookie,cgi
this.secureJSONPrefix string
this.secureJSON boolean
truefalse
this.customTagPaths string
this.mappings struct
this.welcomeFileList string
this.serverSideFormValidation boolean
truefalse
this.googleMapKey string
this.datasource string
this.s3 struct
this.ormEnabled boolean
По умолчанию: false
false
this.ormSettings struct
this.smtpServerSettings struct
this.timeout numeric
this.debuggingIPAddresses string
this.enableRobustException boolean
this.enableNullSupport boolean
По умолчанию: false
false
truefalse
this.sessioncookie.httpOnly boolean
По умолчанию: true
true
this.sessioncookie.secure boolean
По умолчанию: false
false
this.sessioncookie.domain string
По умолчанию: false
false
this.sessioncookie.timeout string
По умолчанию: 30 years
30 years
this.sessioncookie.disableUpdate boolean
По умолчанию: false
false
this.sessioncookie.samesite string
StrictLaxNone
this.authcookie.samesite string
StrictLaxNone
this.javaSettings.loadPaths array
this.javaSettings.loadColdFusionClassPath boolean
По умолчанию: false
false
this.javaSettings.reloadOnChange boolean
По умолчанию: false
false
this.wsChannels array
По умолчанию: false
false
this.sameFormFieldsAsArray boolean
По умолчанию: false
false
this.compileExtForInclude string
По умолчанию: cfm,cfml
cfm,cfml
this.security.antiSamyPolicy string
this.strictNumberValidation boolean
По умолчанию: true
true
this.inMemoryFileSystem.enabled boolean
this.inMemoryFileSystem.size numeric
this.datasources struct
this.serialization.preserveCaseForStructKey boolean
По умолчанию: false
false
this.serialization.preserveCaseForQueryColumn boolean
По умолчанию: false
false
this.serialization.serializeQueryAs string
По умолчанию: row
row
rowcolumnstruct
this.customSerializer numeric
this.locale string
По умолчанию: en_US
en_US
this.timezone string
America/ChicagoAmerica/New_YorkUTC
this.sessionType string
cfmljee
this.sessionStorage string
По умолчанию: memory
memory
this.localMode string
По умолчанию: classic
classic
classicmodern
this.scopeCascading string
По умолчанию: standard
standard
standardstrictsmall
this.typeChecking boolean
this.compression boolean
По умолчанию: false
false
this.passArrayByReference boolean
По умолчанию: false
false
true: массивы в этом приложении будут передаваться по ссылке, а не по значению. truefalse
this.searchImplicitScopes boolean
По умолчанию: true
true
false: выполняется поиск только в областях variables, local и arguments.true: поведение по умолчанию и поведение до CF2016. Поиск выполняется во всех областях в следующем порядке: local, arguments, thread local, query, thread, variables, cgi, cffile, url, form, cookie, client. truefalse
this.blockedExtForFileUpload string
* (пока не поддерживается в Lucee), чтобы запретить все расширения, или использовать пустую строку, чтобы разрешить все расширения (как в предыдущем поведении). Если параметр не указан, приоритет имеют значения, заданные в ColdFusion Administrator. this.security.samlsettings.idp array
this.security.samlsettings.sp array
Ссылки дополнительная информация об Application.cfc
- Изучаем CF за неделю: Application.cfc — руководство, показывающее, как использовать Application.cfc
- Функция onServerStart — объяснение того, как реализована функция onServerStart
- Флаги JVM для cfinclude в CF2018u11+ — [CF2018+] -Dcoldfusion.application.recur_resolve.include=true // cfinclude внутри Application.cfc будет корректно разрешать пути относительно подключаемого файла
- SAML в ColdFusion CF2021+ — [CF2021+] Подробная информация об использовании служб SAML в ColdFusion.
Пример очень простого скрипта
component {
this.name = "AppName";
this.datasource = "AppDataSource";
this.sessionManagement = true;
function onApplicationStart() {
application.config="xyz";
}
} В этом примере используются getCurrentTemplatePath и getDirectoryFromPath, чтобы динамически получить каталог, в котором находится текущий файл Application.cfc, а затем определить несколько отображений относительно него. Не используйте expandPath в Application.cfc, поскольку путь будет рассчитываться относительно пути текущего шаблона, а не пути к Application.cfc.
component {
this.name = "AppName";
this.appBasePath = getDirectoryFromPath(getCurrentTemplatePath());
this.mappings["/components"] = this.appBasePath & "components";
this.mappings["/frameworks"] = this.appBasePath & "frameworks";
} Для создания канала WebSocket достаточно указать атрибут name. Также для канала можно задать пользовательский CFC-обработчик канала. Если он не указан, вызывается ChannelListener.cfc из каталога wwwroot/CFIDE/websocket (Использование обработчиков каналов).Примечание: Хотя можно использовать любое количество подканалов, указывать их не нужно, так как они создаются динамически (с помощью точечной нотации). Чтобы подписаться на каналы, создайте объект WebSocket с помощью тега cfwebsocket в шаблоне CFM.
component {
this.name = "AppName";
this.wschannels = [{name=channelName, cfclistener=channel_listener_CFC}];
} В этом примере показано, как сопоставлять каталоги, расположенные уровнем выше Application.cfc (корня веб-сайта), а также как обрабатывать приложение, которое потребуется развернуть в нескольких операционных системах (Mac, Unix, Windows) из-за различий в средах разработки. С помощью Find определяется, какие разделители путей использовать — прямые или обратные косые черты, а с помощью ListDeleteAt из пути удаляется текущий каталог. Затем на основе этой информации можно сформировать пути для отображений и пользовательских тегов.
component {
this.name = "AppName";
this.currentPath = getDirectoryFromPath( getCurrentTemplatePath() );
this.delim = find("/", this.currentPath) ? "/" : "\";
this.basePath = listDeleteAt(this.currentPath, listLen(this.currentPath, this.delim), this.delim);
this.mappings["/components"] = this.basePath & this.delim & "components";
this.mappings["/frameworks"] = this.basePath & this.delim & "frameworks";
this.customtagpaths = this.basePath & this.delim & "customtags";
}
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/application%2Dcfc