I have always been a little irked when I saw two bean definitions:
The target: This is the real service that will do things
The proxy: This holds interceptors and such, and then finally delegates to the target
A usual Spring convention is to have fooTarget and foo. You know not to lookup *Target beans.
However, I want to stop people :) I don't want it as an option.
Well, while talking about this with Rod Johnson, he told me that he had implemented this while sitting at an AOP talk at a BeJUG meeting :)
So now we can use inner bean classes:
<bean id="person"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>com.mycompany.Person</value></property>
<!-- Use inner bean, not local reference to target -->
<property name="target">
<bean class="com.mycompany.PersonImpl">
<property name="name"><value>Tony</value></property>
<property name="age"><value>51</value></property>
</bean>
</property>
<property name="interceptorNames">
<list>
<value>myAdvisor</value>
<value>debugInterceptor</value>
</list>
</property>
</bean>
Compare that to the old way:
<bean id="personTarget" class="com.mycompany.PersonImpl">
<property name="name"><value>Tony</value></property>
<property name="age"><value>51</value></property>
</bean>
<bean id="person"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>com.mycompany.Person</value></property>
<property name="target"><ref local="personTarget"/></property>
<property name="interceptorNames">
<list>
<value>myAdvisor</value>
<value>debugInterceptor</value>
</list>
</property>
</bean>
Obviously, I omitted the interceptor declarations
Thanks Rod, Juergen, and co!