I do it a bit differently, first, I write a config xml like this (this code shows introduction advice):
Code:
<bean name="beanAdvisor" class="spring.ExtensionAdvisor" singleton="false">
<constructor-arg index="0">
<bean class="Application.BeanExtensionImpl" singleton="false" />
</constructor-arg>
<constructor-arg index="1">
<value>Application.BeanExtension</value>
</constructor-arg>
</bean>
<bean name="bean" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="singleton"><value>false</value></property>
<property name="proxyInterfaces">
<value>Application.BeanView</value>
</property>
<property name="interceptorNames">
<list>
<value>beanAdvisor</value>
</list>
</property>
</bean>
And then use code like this to "wire" up the instance:
Code:
BeanView target = null;
if( context.containsBean("bean") ) {
target = (BeanView) context.getBean("bean");
((Advised) target).setTargetSource(beanInstance);
}
This allows me the flexibility of defining all the advice in a config file.
Cheers