Reusing a single Method Interceptor


It is possible to apply the same CachingInterceptor to many beans and have a full control of the methods to advise and how to apply caching to them:

<bean id="cachingInterceptor"
    <property name="cacheProviderFacade">
        <ref local="cacheProvider" />
    <property name="cachingAttributeSource">

Internally, the bean context uses an instance of CachingAttributeSourceEditor to create a MethodMapCachingAttributeSource from the text specified in the property cachingAttributeSource of the interceptor.

Note: We need to register a CachingAttributeSourceEditor in the bean context:

    <property name="customEditors">
                key="org.wanghy.cache.interceptor.caching.CachingAttributeSource" >
	                class="org.wanghy.cache.interceptor.caching.CachingAttributeSourceEditor" />

This feature can be useful when using BeanNameAutoProxyCreator to proxify all the application beans in one shot. For example, we can end up having only one interceptor of each kind: Acegi for security, Spring for transactions and Wanghy-Cache for caching.

Special thanks to Xavier Dury for contributing this functionality to the project.

Support for cache flushing will be part of the next release.