anchor.diff:  		<cfelse>
   			<cfset appContext = createObject("component","coldspring.context.DefaultApplicationContext").init(bf)/>
   		</cfif> --->
  -		<!--- <cfset appContext = createObject("component","coldspring.context.DefaultApplicationContext").init(bf)/> --->
  +		<!--- <cfset appContext = createObject("component", "coldspring.context.DefaultApplicationContext").init(bf)/> --->
   		
   		<!--- If necessary setup the parent bean factory --->
  -		<!--- todo: we discussed supplying a scope for retrieving the app contexts, but we're passing in application explicitly --->
  -		<cfif len(parentBeanFactoryKey) and bfUtils.namedFactoryExists('application', parentBeanFactoryKey)>
  +		<cfif len(parentBeanFactoryKey) and bfUtils.namedFactoryExists(parentBeanFactoryScope, parentBeanFactoryKey)>
   			<!--- OK, this time we're gonna try to use the new ApplicationContextUtils --->
  -			<cfset bf.setParent(bfUtils.getNamedFactory('application', parentBeanFactoryKey))/>
  +			<cfset bf.setParent(bfUtils.getNamedFactory(parentBeanFactoryScope, parentBeanFactoryKey))/>
   			<!--- <cfset bf.setParent(application[getParameter("parentBeanFactoryKey")].getBeanFactory())/> --->
   		</cfif>
   		
  -		<cfif getParameter('configFilePathIsRelative','false')>
  -			<cfset serviceDefXmlLocation = expandPath(serviceDefXmlLocation) />
  -		</cfif>
  -		
  -		<!--- load the bean defs --->
  -		<cfset bf.loadBeansFromXmlFile(serviceDefXmlLocation,true)/>
  -
  -		<!--- put bean factory back into property mgr --->
  -		<cfset setProperty('beanFactoryName',localBeanFactoryKey) />
  -		<cfset setProperty(localBeanFactoryKey,bf)/>
  -		
  +		<!--- Expand path for relative and mapped config file paths --->
  +		<cfif getParameter("configFilePathIsRelative", FALSE)>
  +			<cfset serviceDefXmlLocation = ExpandPath(serviceDefXmlLocation) />
  +		</cfif>
  +		
  +		<!--- Load the bean defs --->
  +		<cfset bf.loadBeansFromXmlFile(serviceDefXmlLocation, TRUE)/>
  +
  +		<!--- Put a bean factory reference into Mach-II property manager --->
  +		<cfset setProperty("beanFactoryName", localBeanFactoryKey) />
  +		<cfset setProperty(localBeanFactoryKey, bf) />
  +		
  +		<!--- Put a bean factory reference into the application if required --->
   		<cfif placeFactoryInApplicationScope>
  -			<cfset bfUtils.setNamedFactory('application', localBeanFactoryKey, bf)>
  -		</cfif>
  -		
  -		<cfif getParameter('resolveMachiiDependencies','false')>
  +			<cfset bfUtils.setNamedFactory("application", localBeanFactoryKey, bf) />
  +		</cfif>
  +		<cfif placeFactoryInServerScope>
  +			<cfset bfUtils.setNamedFactory('server', localBeanFactoryKey, bf)>
  +		</cfif>
  +		
  +		<!--- Resolve Mach-II dependences if required --->
  +		<cfif getParameter("resolveMachiiDependencies", FALSE)>
   			<cfset resolveDependencies() />
   		</cfif>
   		
  -	</cffunction>
  -	
  -	<cffunction name="resolveDependencies" returntype="void" access="private" output="false">
  -		
  -		<cfset var beanFactory = getProperty(getProperty('beanFactoryName')) />
  +		<!--- Place bean references into the Mach-II properties if required --->
  +		<cfif Len(getParameter("beansToMachIIProperties", ""))>
  +			<cfset referenceBeansToMachIIProperties(getParameter("beansToMachIIProperties")) />
  +		</cfif>		
  +	</cffunction>
  +	
  +	<!---
  +	PROTECTED FUNCTIONS
  +	--->
  +	<cffunction name="resolveDependencies" access="private" returntype="void" output="false"
  +		hint="Resolves Mach-II dependencies.">
  +		
  +		<cfset var beanFactory = getProperty(getProperty("beanFactoryName")) />
   		<cfset var targets = StructNew() />
   		
   		<cfset var targetObj = 0 />
   		<cfset var targetIx = 0 />
   		
  -		<cfset var md = '' />
  +		<cfset var md = "" />
   		<cfset var functionIndex = 0 />
   		
  -		<cfset var setterName = '' />
  -		<cfset var beanName = '' />
  -		<cfset var access = '' />
  -
  +		<cfset var setterName = "" />
  +		<cfset var beanName = "" />
  +		<cfset var access = "" />
  +		
  +		<!--- Get listeners/filters/plugin targets --->
   		<cfset targets.data = ArrayNew(1) />
   		<cfset getListeners(targets) />
   		<cfset getFilters(targets) />
   		<cfset getPlugins(targets) />
   		
   		<cfloop from="1" to="#ArrayLen(targets.data)#" index="targetIx">
  +			<!--- Get this iteration target object for easy use --->
   			<cfset targetObj = targets.data[targetIx] />
  -			<!--- look for autowirable collaborators for any SETTERS --->
  -			<cfset md = getMetaData(targetObj) />	
  +			
  +			<!--- Look for autowirable collaborators for any SETTERS --->
  +			<cfset md = GetMetaData(targetObj) />
  +			
   			<cfif StructKeyExists(md, "functions")>
   				<cfloop from="1" to="#arraylen(md.functions)#" index="functionIndex">
   					<!--- first get the access type --->
  -					<cfif structKeyExists(md.functions[functionIndex],'access')>
  +					<cfif StructKeyExists(md.functions[functionIndex], "access")>
   						<cfset access = md.functions[functionIndex].access />
   					<cfelse>
  -						<cfset access = 'public' />
  +						<cfset access = "public" />
   					</cfif>
  +					
   					<!--- if this is a 'real' setter --->
  -					<cfif left(md.functions[functionIndex].name,3) eq "set" 
  -							  and arraylen(md.functions[functionIndex].parameters) eq 1 
  -							  and (access is not 'private')>
  +					<cfif Left(md.functions[functionIndex].name, 3) EQ "set" 
  +							  AND Arraylen(md.functions[functionIndex].parameters) EQ 1 
  +							  AND (access IS NOT "private")>
  +						
   						<!--- look for a bean in the factory of the params's type --->	  
  -						<cfset setterName = mid(md.functions[functionIndex].name,4,len(md.functions[functionIndex].name)-3) />
  +						<cfset setterName = Mid(md.functions[functionIndex].name, 4, Len(md.functions[functionIndex].name)-3) />
   						
  +						<!--- Get bean by setter name and if not found then get by type --->
   						<cfif beanFactory.containsBean(setterName)>
   							<cfset beanName = setterName />
   						<cfelse>
   							<cfset beanName = beanFactory.findBeanNameByType(md.functions[functionIndex].parameters[1].type) />
   						</cfif>
  -						<!--- if we found a bean, call the target object's setter --->
  -						<cfif len(beanName)>
  +						
  +						<!--- If we found a bean, put the bean by calling the target object's setter --->
  +						<cfif Len(beanName)>
   							<cfinvoke component="#targetObj#"
   									  method="set#setterName#">
   								<cfinvokeargument name="#md.functions[functionIndex].parameters[1].name#"
  
positive.code: 		</cfloop>
  		
  	</cffunction>
  	
  	<cffunction name="getListenerNamesForColdSpring" returntype="array" access="public" output="false">
  		<cfreturn StructKeyArray(variables.listeners) />
  	</cffunction>
  		
  	<cffunction name="getListeners" returntype="void" access="private" output="false">
  		<cfargument name="targets" type="struct" required="true" />
  		<cfset var listenerManager = getAppManager().getListenerManager() />
  		<cfset var listenerNames = 0 />
  		<cfset var i = 0 />
  		
  		<cfif StructKeyExists(listenerManager,"getListenerNames")>
  			<cfset listenerNames = listenerManager.getListenerNames() />
  		<cfelse>
  			<!--- inject a method I need into the manager and use it to get the listener names --->
  			<cfset listenerManager['getListenerNamesForColdSpring'] = variables['getListenerNamesForColdSpring'] />
  			<cfset listenerNames = listenerManager.getListenerNamesForColdSpring() />
  			<!--- get rid of my mayhem --->
  			<cfset StructDelete(listenerManager,'getListenerNamesForColdSpring') /> 
  		</cfif>
  		
  		<!--- append each retrieved listener to the targets array (in struct) --->
  		<cfloop from="1" to="#ArrayLen(listenerNames)#" index="i">
  			<cfset ArrayAppend(targets.data, listenerManager.getListener(listenerNames[i])) />
  		</cfloop>
  		
  	</cffunction>
  	
  	<cffunction name="getFilterNamesForColdSpring" returntype="array" access="public" output="false">
  		<cfreturn StructKeyArray(variables.filters) />
  	</cffunction>
  		
  	<cffunction name="getFilters" returntype="void" access="private" output="false">
  		<cfargument name="targets" type="struct" required="true" />
  		<cfset var filterManager = getAppManager().getFilterManager() />
  		<cfset var filterNames = 0 />
  		<cfset var i = 0 />
  		
  		<cfif StructKeyExists(filterManager,"getFilterNames")>
  			<cfset filterNames = filterManager.getFilterNames() />
  		<cfelse>
  			<cfset filterManager['getFilterNamesForColdSpring'] = variables['getFilterNamesForColdSpring'] />
  			<cfset filterNames = filterManager.getFilterNamesForColdSpring() />
  			<cfset StructDelete(filterManager,'getFilterNamesForColdSpring') /> 
  		</cfif>
  		<!--- append each retrieved filter to the targets array (in struct) --->
  		<cfloop from="1" to="#ArrayLen(filterNames)#" index="i">
  			<cfset ArrayAppend(targets.data, filterManager.getFilter(filterNames[i])) />
  		</cfloop>
  		
  	</cffunction>
  	
  	<cffunction name="getPluginNamesForColdSpring" returntype="array" access="public" output="false">
  		<cfreturn StructKeyArray(variables.plugins) />
  	</cffunction>
  		
  	<cffunction name="getPlugins" returntype="void" access="private" output="false">
  		<cfargument name="targets" type="struct" required="true" />
  		<cfset var pluginManager = getAppManager().getPluginManager() />
  		<cfset var pluginNames = 0 />
  		<cfset var i = 0 />
  		
  		<cfif StructKeyExists(pluginManager,"getPluginNames")>
  			<cfset pluginNames = pluginManager.getPluginNames() />
  		<cfelse>
  			<cfset pluginManager['getPluginNamesForColdSpring'] = variables['getPluginNamesForColdSpring'] />
  			<cfset pluginNames = pluginManager.getPluginNamesForColdSpring() />
  			<cfset StructDelete(pluginManager,'getPluginNamesForColdSpring') /> 
  		</cfif>
  		
  		<!--- append each retrieved plugin to the targets array (in struct) --->
  		<cfloop from="1" to="#ArrayLen(pluginNames)#" index="i">
  			<cfset ArrayAppend(targets.data, pluginManager.getPlugin(pluginNames[i])) />
  		</cfloop>
  		
  	</cffunction>
  </cfcomponent>
negative.code: <!---
  License:
  Copyright (c) 2005, David Ross, Chris Scott, Kurt Wiersma, Sean Corfield
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
  	http://www.apache.org/licenses/LICENSE-2.0
    
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  		
  $Id: ColdspringPlugin.cfc,v 1.10 2006/12/11 02:23:30 wiersma Exp $
  
  Description:
  A Mach-II plugin that provides easy ColdSpring integration with Mach-II applications.
  
  Usage:
  <plugin name="coldSpringPlugin" type="coldspring.machii.ColdspringPlugin">
  	<parameters>
  		<!-- Name of a Mach-II property name that will hold a reference to the ColdSpring beanFactory
  			Default: 'beanFactory' -->
  		<parameter name="beanFactoryPropertyName" value="serviceFactory"/>
  
  		<!-- Name of a Mach-II property name that holds the path to the ColdSpring config file 
  			default: 'ColdSpringComponentsLocation' -->
  		<parameter name="configFilePropertyName" value="ColdspringComponentRelativePath"/>
  		
  		<!-- Flag to indicate whether supplied config path is relative (mapped) or absolute 
  			Default: FALSE (absolute path) -->
  		<parameter name="configFilePathIsRelative" value="true"/>
  		
  		<!-- Flag to indicate whether to resolve dependencies for listeners/filters/plugins 
  			Default: FALSE -->
  		<parameter name="resolveMachIIDependencies" value="false"/>
  		
  		<!-- indicate a scope to pull in a parent bean factory from 
  			 default: application -->
  		<parameter name="parentBeanFactoryScope" value="application"/>
  		
  		<!-- Indicate a key to pull in a parent bean factory from the application scope
  			Default: FALSE -->
  		<parameter name="parentBeanFactoryKey" value="serviceFactory"/>
  			
  		<!-- Indicate whether or not to place the bean factory in the application scope 
  			 Default: FALSE -->
  		<parameter name="placeFactoryInApplicationScope" value="false" />
  
  		<!-- Indicate whether or not to place the bean factory in the server scope 
  			 Default: FALSE -->
  		<parameter name="placeFactoryInServerScope" value="false" />
  		
  		<!--- List of bean names and coresponding Mach-II property names for injecting back into Mach-II
  			Default: '' --->
  		<parameter name="beansToMachIIProperties" value="beanName1=machIIpropertyName1,beanName2=machIIpropertyName2" />
  		
  	</parameters>
  </plugin>
  
  The [beanFactoryPropertyName] parameter value is the name of the Mach-II property name 
  that will hold a reference to the ColdSpring beanFactory. This parameter 
  defaults to "beanFactory" if not defined.
  
  The [configFilePropertyName] paramater value is the name of Mach-II property name that
  hold the path of the ColdSpring configuration file. The value of the Mach-II property can 
  be an relative, ColdFusion mapped or absolute path. If you are using a relative or mapped
  path, be sure to set the [configFilePathIsRelative] parameter to TRUE or the plugin will
  not find your configuration file. This parameter defaults to "ColdSpringComponentsLocation" 
  if not defined.
  
  The [configGilePathIsRelative] parameter value defines if the configure file is an relative
  (including ColdFusion mapped) or absolute path. If you are using a relative or mapped
  path, be sure to set the [configFilePathIsRelative] parameter to TRUE or the plugin will
  not find your configuration file.
  - TRUE (for relative or mapped configuration file paths)
  - FALSE (for absolute configuration file paths)
  
  The [resolveMachIIDependencies] parameter value indicates if the plugin to "automagically"
  wire Mach-II listeners/filters/plugins.  This parameter defaults to FALSE if not defined.
  - TRUE (resolves all Mach-II dependencies)
  - FALSE (does not resolve Mach-II dependencies)
  
  The [parentBeanFactoryKey] parameter values defines a key to pull in a parent bean factory
  from the application scope.  This parameter defaults to FALSE if not defined.
  
  The [beansToMachIIProperties] parameter holds a special list of bean names and coresponding
  Mach-II property names. This parameter will inject the specified beans in the Mach-II property
  manager as the bean factory has been loaded.  In the past, a seperate plugin has to be written 
  to accomplish this task. This should be used for framework required "utility" objects that you 
  want to be managed by ColdSpring such as UDF, i18n or session facade objects. Do not use this 
  feature to inject your model objects into the Mach-II property manager.
  
  The format of this list should be a comma delimited list name/value pairs consisting of the bean 
  name and corresponding Mach-II property name. Example:
  beanName1=machIIpropertyName1,beanName2=machIIpropertyName2
  
  --->
  <cfcomponent
  	name="ColdspringPlugin"
  	extends="MachII.framework.Plugin"
  	hint="A Mach-II plugin for easy ColdSpring integration"
  	output="false">
  
  	<!---
  	INITALIZATION / CONFIGURATION
  	--->
  	<cffunction name="configure" access="public" returntype="void" output="false"
  		hint="I initialize this plugin during framework startup.">
  		
  		<!--- Default vars --->
  		<cfset var appContext = 0 />
  		<cfset var bf = 0 />
  		<cfset var p = 0 />
  		
  		<!--- Get the Mach-II property manaager --->
  		<cfset var pm = getAppManager().getPropertyManager() />
  	
  		<!--- Determine the location of the bean def xml file --->
  		<cfset var serviceDefXmlLocation = pm.getProperty(getParameter("configFilePropertyName", "ColdSpringComponentsLocation")) />
  		
  		<!--- Get all properties to pass to bean factory --->
  		<cfset var props = pm.getProperties() />
  		
  		<!--- todo: Defaults set via mach-ii params --->
  		<cfset var defaults = StructNew() />
  		
  		<!--- Locating and storing bean factory (from properties/params) --->
  		<cfset var bfUtils = CreateObject("component", "coldspring.beans.util.BeanFactoryUtils").init() />
  		<cfset var parentBeanFactoryKey = getParameter("parentBeanFactoryKey", "") />
  		
  		<cfset var localBeanFactoryKey = getParameter("beanFactoryPropertyName", bfUtils.DEFAULT_FACTORY_KEY) />
  		<cfset var placeFactoryInApplicationScope = getParameter("placeFactoryInApplicationScope", FALSE) />
  		
  		<cfset var placeFactoryInServerScope = getParameter('placeFactoryInServerScope','false') />
  		<cfset var parentBeanFactoryScope = getParameter('parentBeanFactoryScope', 'application')>
  				
  		
  		<!--- Evaluate any dynamic properties --->
  		<cfloop collection="#props#" item="p">
  			<cfif IsSimpleValue(props[p]) AND Left(props[p], 2) EQ "${" AND Right(props[p], 1) EQ "}">
  				<cfset props[p] = Evaluate(Mid(props[p], 3, Len(props[p]) -3)) />
  			</cfif>
  		</cfloop>
  		
  		<!--- Create a new bean factory and appContext --->
  		<cfset bf = CreateObject("component", "coldspring.beans.DefaultXmlBeanFactory").init(defaults, props)/>
  		
  		<!--- if we're using an application scoped factory, retrieve the appContext from app scope
  		<cfif placeFactoryInApplicationScope and bfUtils.namedContextExists('application', localBeanFactoryKey)>
  