【发布时间】:2016-08-19 20:54:31
【问题描述】:
我创建了一个在 Spring 应用程序中运行良好的 AspectJ 方面。现在我想添加缓存,使用 springs Cacheable 注解。
为了检查@Cacheable 是否被拾取,我使用了一个不存在的缓存管理器的名称。常规的运行时行为是抛出异常。但是在这种情况下,没有抛出异常,这表明@Cacheable 注解没有被应用到拦截对象。
/* { package, some more imports... } */
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.cache.annotation.Cacheable;
@Aspect
public class GetPropertyInterceptor
{
@Around( "call(* *.getProperty(..))" )
@Cacheable( cacheManager = "nonExistingCacheManager", value = "thisShouldBlowUp", key = "#nosuchkey" )
public Object intercepting( ProceedingJoinPoint pjp ) throws Throwable
{
Object o;
/* { modify o } */
return o;
}
}
鉴于我的 Aspect 已经在工作,我怎样才能让 @Cacheable 在它之上工作?
【问题讨论】:
标签: java spring aspectj aspect