目前,在application.cfc中,我扩展了Fusebox5.5框架。然后在下面的OnRequestStart方法中,我根据特定条件设置熔断盒模式。
问题是,有时,无论我做了什么更改,fusebox xml文件都不会重新解析。如果我使用url变量fusebox.parse=true&fusebox.loadclean=true&fusebox.password=xxx强制重新解析,那么文件将再次解析。
它几乎就像是Fusebox仍然处于生产模式,尽管当我转储FUSEBOX_PARAMETERS.mode时,它显示“开发-完全加载”。
这可能是什么原因造成的?在下面的代码中,熔丝盒模式的操作方式是正确的,还是应该在其他地方进行这种设置(显然除了fusebox.xml之外)?
任何帮助都是最好的。谢谢
<cffunction name="onRequestStart">
<cfset variables.server_type = "Development" />
<cfswitch expression="#variables.server_type#">
<cfcase value="development">
<cfset FUSEBOX_PARAMETERS.mode = "development-circuit-load" />
<cfset FUSEBOX_PARAMETERS.debug = true />
<cfset request.component_reload = true />
</cfcase>
<cfdefaultcase>
<cfset FUSEBOX_PARAMETERS.mode = "production" />
<cfset FUSEBOX_PARAMETERS.debug = false />
<cfset request.component_reload = false />
</cfdefaultcase>
</cfswitch>
<cfif (StructKeyExists(attributes, "fusebox.loadapp") AND attributes.fusebox.password EQ application.fusebox.password) OR FUSEBOX_PARAMETERS.mode NEQ application.fusebox.mode>
<cfset this.onApplicationStart() />
</cfif>
<cfset superReturn = super.onRequestStart(arguments.1) />
</cffunction>发布于 2011-05-08 21:10:13
看,FUSEBOX_PARAMETERS存储在application作用域中,默认情况下它们包含在巨大的容器application.fusebox中。Fusebox设置是在调用super.onApplicationStart()时填充的,因此在onRequestStart中修改它们没有意义。
我建议将cfswitch代码移到定义应用程序设置的组件主体中。
在onRequestStart中,您可以强制应用程序重新启动以重新读取设置,可能如下所示:
<cfif StructKeyExists(attributes, "fusebox.loadapp") AND attributes["fusebox.password"] EQ application.fusebox.password>
<cfset this.onApplicationStart() /
</cfif>请注意,fusebox.loadapp不是内置的Fusebox属性,它只适用于你的应用程序,只是为了方便起见像其他人一样加了前缀。这样你就可以重读你的应用程序的单例了。
https://stackoverflow.com/questions/5927234
复制相似问题