在application.cfc中创建FW/1服务

编程入门 行业动态 更新时间:2024-10-26 15:13:55
本文介绍了在application.cfc中创建FW/1服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在application.cfc中创建呼叫服务

I am trying to create call a service in 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");

文档说

有时您需要直接访问Bean工厂(例如对于 获取瞬变),而您可以在自己的内部获取它 通过variables.fw.getBeanFactory()设置控制器 通过声明属性beanFactory注入的bean工厂; (可以是 同时在控制器和服务中使用),则您可以致电 variables.beanFactory.getBean() whenevr [sic]您需要一个瞬变.

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;.前提是DI/1正在管理该CFC,这将通过variables.settingService使该服务可用.

Well, if you're using DI/1 with FW/1, you can set accessors="true" in your Application.cfc and then define property settingService;. This will make the service available, via variables.settingService, providing that DI/1 is managing that CFC.

您的示例调用将变为:application.stSetting = variables.settingService.loadIni("standard.ini");

Your example call could then become: application.stSetting = variables.settingService.loadIni("standard.ini");

更多推荐

在application.cfc中创建FW/1服务

本文发布于:2023-11-13 12:17:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:application   cfc   FW

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!