在 application.cfc 中创建 FW/1 服务
Creating FW/1 Service in application.cfc
我正在尝试在 application.cfc
中创建呼叫服务
原始代码看起来像
现在
void function setupApplication() {
...
application.objCCFRO = new model.services.setting();
application.stSetting = application.objCCFRO.loadini("standard.ini");
我正在尝试将其转换为
application.stSetting = variables.beanFactory.getBean( "settingService" ).loadIni("standard.ini");
文档说
sometimes you need access to the bean factory directly (such as for
obtaining a transient) and whilst you can get at it inside your
controllers via variables.fw.getBeanFactory()
it’s better to have the
bean factory injected by declaring property beanFactory; (which can be
used in both controllers and services), then you can call
variables.beanFactory.getBean()
whenevr [sic] you need a transient.
当我运行setupApplication()
时我需要一个瞬变
嗯,如果您使用 DI/1 和 FW/1,您可以在 Application.cfc 中设置 accessors="true"
,然后定义 property settingService;
。这将通过 variables.settingService
提供服务,前提是 DI/1 正在管理该 CFC。
您的示例调用可以变为:application.stSetting = variables.settingService.loadIni("standard.ini");
我正在尝试在 application.cfc
中创建呼叫服务原始代码看起来像
现在
void function setupApplication() {
...
application.objCCFRO = new model.services.setting();
application.stSetting = application.objCCFRO.loadini("standard.ini");
我正在尝试将其转换为
application.stSetting = variables.beanFactory.getBean( "settingService" ).loadIni("standard.ini");
文档说
sometimes you need access to the bean factory directly (such as for obtaining a transient) and whilst you can get at it inside your controllers via
variables.fw.getBeanFactory()
it’s better to have the bean factory injected by declaring property beanFactory; (which can be used in both controllers and services), then you can callvariables.beanFactory.getBean()
whenevr [sic] you need a transient.
当我运行setupApplication()
嗯,如果您使用 DI/1 和 FW/1,您可以在 Application.cfc 中设置 accessors="true"
,然后定义 property settingService;
。这将通过 variables.settingService
提供服务,前提是 DI/1 正在管理该 CFC。
您的示例调用可以变为:application.stSetting = variables.settingService.loadIni("standard.ini");