I'm working on a cacheing mechanism for a Spring/Hibernate/Struts based application. All access to the DAO layer is via a service facade, using TransactionProxyFactoryBean, so I'd have something like this for each "subject area":

<bean id="organisationService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="store*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
</props>
</property>
<property name="target">
<ref local="organisationServiceTarget"/>
</property>
</bean>


<bean id="organisationServiceTarget" class="mypackage.service.OrganisationServiceImpl">
<property name="organisationDAO">
<ref local="organisationDAO"/>
</property>
</bean>

<bean id="organisationDAO" parent="baseDAO" class="mypackage.dao.organisation.HibernateOrganis ationDAO"/>


Now, I want to throw cacheing into the mix - purging the cache when certain methods are used, checking and perhaps using the content of the cache when other methods are used. My first attempt used BeanNameAutoProxyCreator to allow me to apply my interceptor to all relevant beans, but I found that if I match *Service, the only method that gets intercepted is the getObject method of the TransactionProxyFactoryBean, NOT the methods of the proxied object. Changing this to *ServiceTarget (i.e, the objects themselves) gets the right methods called.

But I'm wondering whether this is the right approach at all. Should I be adding stuff into the configuration of the service beans themselves instead, namely PreInterceptors or PostInterceptors for the TransactionProxyFactoryBean, or perhaps specifying a MethodPointcut for the TransactionInterceptor?