I am trying to add AOP advice to a bean that is generated by a custom
factory /snip/ <bean id="somethingfactory" class="somethingfactory"/>
<bean id="something" factory-bean="somethingfactory" factory-
method="makesomething" class='something'/> /snip/
It appears when I apply advice via the <AOP> schema to the class that
it does a strait create on the something object with out using the
factory.
If I use the older style ProxyFactoryBean it works just fine.
I would much perfer to use the pointcut style so that I do not have
declare exactly where advice should be used on each bean. Have tried
to walk though the coldspring getBean paths for the two styles and not
finding where the problem is. I have encluded simple examples below
of that is being used to test this issue.
<cfcomponent name="somethingfactory.cfc>
<cffunction name="init">
<cfreturn this>
</cffunction>
<cffunction name="makesomething">
<cfset var local=structnew()>
<cfset local.something= createObject( 'component', 'something')/>
<cfset local.something.setfoo(5)>
<cfset local.something.xxx=4>
<cfreturn local.something>
</cffunction>
</cfcomponent>
<cfcomponent name="something">
<cffunction name="init">
<cfreturn this>
</cffunction>
<cffunction name="setfoo">
<cfargument name="thevalue">
<cfset this.foo = arguments.thevalue>
</cffunction>
<cffunction name="getfoo">
<cfreturn this.foo>
</cffunction>
</cfcomponent>
<cfcomponent name="AOPtest"
implements="coldspring.aop.MethodInterceptor">
<cffunction name="init">
<cfreturn this>
</cffunction>
<cffunction name="invokeMethod" access="public" returntype="any"
output="FALSE">
<cfargument name="methodInvocation"
type="coldspring.aop.MethodInvocation" required="true" />
<cfset rtn = arguments.methodInvocation.proceed() />
</cffunction>
</cfcomponent>
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName"
xmlns="
http://www.coldspringframework.org/schema/beans"
xmlns:aop="
http://www.coldspringframework.org/schema/aop"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.coldspringframework.org/
schema/beans
http://coldspringframework.org/schema/coldspring-beans-2.0.xsd
http://www.coldspringframework.org/schema/aop
http://www.coldspringframework.org/schema/coldspring-aop-2.0.xsd"
>
<bean id="aoptest" class="aoptest" />
<bean id="somethingfactory" class="somethingfactory"/>
<bean id="something" factory-bean="somethingfactory" factory-
method="makesomething" class='something'/>
<!-- new style does not work. -->
<!-- <aop:config>-->
<!-- <aop:aspect ref="aoptest">-->
<!-- <aop:around method="invokeMethod" pointcut="execution(public *
something.getfoo(..))"/>-->
<!-- </aop:aspect> -->
<!-- </aop:config>-->
<!-- old style works -->
<bean id="securityAdvisor"
class="coldspring.aop.support.NamedMethodPointcutAdvisor">
<property name="advice">
<ref bean="aoptest" />
</property>
<property name="mappedNames">
<value>getfoo</value>
</property>
</bean>
<bean id="somethingtest"
class="coldspring.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="something" />
</property>
<property name="interceptorNames">
<list>
<value>securityAdvisor</value>
</list>
</property>
</bean>
</beans>