AbstractCacheMethodInterceptor.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:guja 作者:
protected CacheKeyGenerator getCacheKeyGenerator(MethodInvocation methodInvocation,
                                                 Class<? extends CacheKeyGenerator> methodCacheKeyGeneratorClass) {

  try {

    if (!methodCacheKeyGeneratorClass.equals(CacheKeyGenerator.class)) {
      // The annotation will return the CacheKeyGenerator class by default
      return methodCacheKeyGeneratorClass.newInstance();
    }

    Class clazz = GuiceCacheKeyInvocationContext.getThisClass(methodInvocation);
    if (clazz.isAnnotationPresent(CacheDefaults.class)) {
      Class<? extends CacheKeyGenerator> cacheKeyGeneratorClass = ((CacheDefaults)clazz.getAnnotation(CacheDefaults.class)).cacheKeyGenerator();
      if (!cacheKeyGeneratorClass.equals(CacheKeyGenerator.class)) {
        // The annotation will return the CacheKeyGenerator class by default
        return cacheKeyGeneratorClass.newInstance();
      }
    }

    return defaultCacheKeyGeneratorProvider.get();

  } catch (Exception e) {
    throw new AnnotationFormatError("Invalid cache key generator class " + methodCacheKeyGeneratorClass.getName());
  }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号