1
除了Spring 3.1和ehcache-spring-annotations,我们还有其他的选择是否与EhCache和Spring不同?用于Java的声明性(基于注释的)缓存解决方案
除了Spring 3.1和ehcache-spring-annotations,我们还有其他的选择是否与EhCache和Spring不同?用于Java的声明性(基于注释的)缓存解决方案
你看过基于Spring-AOP的解决方案吗?您可以使用org.springframework.aop.support.RegexpMethodPointcutAdvisor在Spring的ApplicationContext创建自动代理对象,然后进行实现AfterReturningAdvice,ThrowsAdvice和MethodBeforeAdvice的对象。
使用该对象来监视函数调用并退出并缓存您想要的信息。
<bean name="cacheHandler" class="org.yourname.CachingInterceptor" />
<bean id="cacheAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice" ref="cacheHandler" />
<property name="pattern" value="org.yourname.regex.of.stuff.you.want.cached.*" />
</bean>
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />