Reusing a single Method Interceptor

Caching

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"
    class="org.wanghy.cache.interceptor.caching.CachingInterceptor">
    <property name="cacheProviderFacade">
        <ref local="cacheProvider" />
    </property>
    <property name="cachingAttributeSource">
        org.wanghy.cache.integration.CacheableImpl.get*=[cacheProfileId=test]
    </property>
</bean>

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:

<bean
    class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
        <map>
            <entry  
                key="org.wanghy.cache.interceptor.caching.CachingAttributeSource" >
	            <bean  
	                class="org.wanghy.cache.interceptor.caching.CachingAttributeSourceEditor" />
            </entry  
        </map>
    </property>
</bean>

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.