在application.cfc中创建FW/1服务 [英] Creating FW/1 Service in application.cfc

查看:142
本文介绍了在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服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆