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