Wow... I get on a plane and then all of a sudden Sean bombs this list.
I haven't had a chance to read through everything, but:
duck-typing support - fine, good, it doesn't make much of a difference
to those who aren't using it
walking the inheritance tree when searching metadata - this has
several implications that have been discussed in the past - my biggest
concern is autowiring - mixing autowiring and inherited methods seems
dangerous... if you've explicitly defined the <property/> or
<constructor-arg/> then I don't have a problem with it using an
"inherited setter" to push in a dependency... but doesn't that work
already? Inheriting an init() is another case where I'm not sure
whether to support that or not - I'm of the opinion that all CFC's
should have an init() no matter what - sure we support ones that don't
but I'm not sure we should be calling init() if it doesn't exist in
the concrete CFC.
regardless, we should probably refactor the metadata "gathering" into
a separate utility class, then we can only have to tweak this in one
place in the future. thoughts on that?
Well, I came up short on a jump yesterday and have a sore ankle, knee,
groin, back, and neck. Heading back out for revenge now... :)
-Dave
On 3/5/06, Sean Corfield <[EMAIL PROTECTED]> wrote:
> On 3/5/06, Sean Corfield <[EMAIL PROTECTED]> wrote:
> > I'll code it up for one of the situations and test it, post a patch
> > here for review and then move on to all the other places.
>
> Please review the patch below. It seems to work given my limited
> testing but I want other eyes on it before I start to implement it in
> other parts of ColdSpring. Again, it looks worse than it is due to
> indentation changes.
>
> Index: ProxyFactoryBean.cfc
> ===================================================================
> RCS file: /coldspring/coldspring/aop/framework/ProxyFactoryBean.cfc,v
> retrieving revision 1.9
> diff -u -r1.9 ProxyFactoryBean.cfc
> --- ProxyFactoryBean.cfc 14 Feb 2006 21:03:29 -0000 1.9
> +++ ProxyFactoryBean.cfc 6 Mar 2006 02:54:18 -0000
> @@ -122,6 +122,7 @@
> <cffunction name="createProxyInstance" access="private"
> returntype="any" output="true">
> <cfset var methodAdviceChains = StructNew() />
> <cfset var md = getMetaData(variables.target)/>
> + <cfset var functionSeen = structNew() />
> <cfset var functionIx = 0 />
> <cfset var functionName = '' />
> <cfset var advisorIx = 0 />
> @@ -133,32 +134,43 @@
> <!--- first we need to build the advisor chain to search for
> pointcut matches --->
> <cfset buildAdvisorChain() />
>
> - <!--- now we'll loop through the target's methods and search
> for
> advice to add to the advice chain --->
> - <cfloop from="1" to="#arraylen(md.functions)#"
> index="functionIx">
> -
> - <cfset functionName = md.functions[functionIx].name />
> -
> - <cfif not ListFindNoCase('init', functionName)>
> - <cfloop from="1"
> to="#ArrayLen(variables.advisorChain)#" index="advisorIx">
> - <cfif
> variables.advisorChain[advisorIx].matches(functionName)>
> - <!--- if we found a mathing
> pointcut in an advisor, make sure
> this method has an adviceChain started --->
> - <cfif not
> StructKeyExists(methodAdviceChains, functionName)>
> - <cfset
> methodAdviceChains[functionName] =
> CreateObject('component','coldspring.aop.AdviceChain').init() />
> + <cfloop condition="structKeyExists(md,'extends')">
> + <cfif structKeyExists(md,'functions')>
> + <!--- now we'll loop through the target's
> methods and search for
> advice to add to the advice chain --->
> + <cfloop from="1"
> to="#arraylen(md.functions)#" index="functionIx">
> +
> + <cfset functionName =
> md.functions[functionIx].name />
> +
> + <cfif not
> structKeyExists(functionSeen,functionName)>
> +
> + <cfset
> functionSeen[functionName] = true />
> +
> + <cfif not
> ListFindNoCase('init', functionName)>
> + <cfloop from="1"
> to="#ArrayLen(variables.advisorChain)#"
> index="advisorIx">
> + <cfif
> variables.advisorChain[advisorIx].matches(functionName)>
> + <!---
> if we found a mathing pointcut in an advisor, make
> sure this method has an adviceChain started --->
> + <cfif
> not StructKeyExists(methodAdviceChains, functionName)>
> +
> <cfset methodAdviceChains[functionName] =
> CreateObject('component','coldspring.aop.AdviceChain').init() />
> +
> </cfif>
> +
> <cfset advice = variables.advisorChain[advisorIx].getAdvice() />
> + <!---
> and duplicate the advice to this method's advice chain
> +
> <cfset methodAdviceChains[functionName].addAdvice(
> +
>
> variables.aopProxyUtils.clone(variables.advisorChain[advisorIx].getAdvice())
> ) /> --->
> + <!---
> add the advice to this method's advice chain' --->
> +
> <cfset methodAdviceChains[functionName].addAdvice(advice) />
> + </cfif>
> + </cfloop>
> + <!--- now freeze the
> method invocation chain for this method
> + <cfset
> methodAdviceChains[functionName].buildInterceptorChain() /> --->
> + <!--- so here's where
> we'll inject intercept methods --->
> + <cfset
> variables.aopProxyUtils.createUDF(md.functions[functionIx],
> aopProxyBean) />
> </cfif>
> - <cfset advice =
> variables.advisorChain[advisorIx].getAdvice() />
> - <!--- and duplicate the
> advice to this method's advice chain
> - <cfset
> methodAdviceChains[functionName].addAdvice(
> -
> variables.aopProxyUtils.clone(variables.advisorChain[advisorIx].getAdvice())
> ) /> --->
> - <!--- add the advice to this
> method's advice chain' --->
> - <cfset
> methodAdviceChains[functionName].addAdvice(advice) />
> +
> </cfif>
> +
> </cfloop>
> - <!--- now freeze the method invocation chain
> for this method
> - <cfset
> methodAdviceChains[functionName].buildInterceptorChain() /> --->
> - <!--- so here's where we'll inject intercept
> methods --->
> - <cfset
> variables.aopProxyUtils.createUDF(md.functions[functionIx],
> aopProxyBean) />
> </cfif>
> -
> + <cfset md = md.extends />
> </cfloop>
>
> <!--- now give the proxy object the advice chains --->
>
> --
> Sean A Corfield -- http://corfield.org/
> Got frameworks?
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>