getLog().tracef("Interception of method named '%s'", invocationContext.getMethod().getName());
}
final CacheKeyInvocationContext<CachePut> cacheKeyInvocationContext = contextFactory.getCacheKeyInvocationContext(invocationContext);
final CacheKeyGenerator cacheKeyGenerator = cacheKeyInvocationContext.unwrap(CacheKeyInvocationContextImpl.class).getCacheKeyGenerator();
final CachePut cachePut = cacheKeyInvocationContext.getCacheAnnotation();
final GeneratedCacheKey cacheKey = cacheKeyGenerator.generateCacheKey(cacheKeyInvocationContext);
final Cache<GeneratedCacheKey, Object> cache = cacheResolver.resolveCache(cacheKeyInvocationContext);
final Object valueToCache = cacheKeyInvocationContext.getValueParameter().getValue();
if (!cachePut.afterInvocation() && valueToCache != null) {
cache.put(cacheKey, valueToCache);
if (getLog().isTraceEnabled()) {
getLog().tracef("Value '%s' cached in cache '%s' with key '%s' before method invocation", valueToCache, cache.getName(), cacheKey);
}
}
final Object result = invocationContext.proceed();
if (cachePut.afterInvocation() && valueToCache != null) {
cache.put(cacheKey, valueToCache);
if (getLog().isTraceEnabled()) {
getLog().tracef("Value '%s' cached in cache '%s' with key '%s' after method invocation", valueToCache, cache.getName(), cacheKey);
}
}