Hey guys,
I have a super simple demo app here and came across something that is confusing to me. I have set up DI/1 in setupApplication like so:
<cffunction name="setupApplication">
<cfset factory = new framework.ioc("/model")>
<cfset setBeanFactory(factory)>
</cffunction>
Works great! However, when I comment out the DI/1 setup, and make a request with reload=true in the url, I expected the application to reinitialize itself without DI/1 and the code which relies on dependency injection to break. It didn't.
<cffunction name="setupApplication">
<!--- <cfset factory = new framework.ioc("/model")>
<cfset setBeanFactory(factory)> --->
</cffunction>
The beanfactory is still in play. It seems that even though I reloaded the application, the application scope was not reset, so I tried doing something like this to try and force the application scope to reload (so the beanfactory would no longer be available).
<cffunction name="setupRequest">
<cfif structKeyExists(url, "reload") and url.reload>
<cflock scope="application" timeout="30" type="exclusive">
<cfset structClear(application)>
</cflock>
<cfset onApplicationStart()>
</cfif>
</cffunction>
This breaks the application however, throwing:
Element org.corfield.framework is undefined in a Java object of type class coldfusion.runtime.ApplicationScope
So the application scope is cleared, but FW/1 is getting hung up on the application reload(?). I was able to "reset" the application scope in another way by setting running:
<cfset this.applicationTimeout = createTimeSpan(0,0,0,0)>
And this successfully reinitializes the framework without DI/1 - but I'm confused as to why I can't reload the application with a fresh application scope by using structClear(application) and then calling onApplicationStart(). Can anyone shed some light on what's going on here? I seem to have a lack of understanding here either related to how the application scope works or how FW/1 initializes itself (probably both).
Thanks for any insight you can share!
Brian