/** * Set one or more sources to find cache operations. * @see CacheInterceptor#setCacheOperationSources */ public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) { this.cacheInterceptor.setCacheOperationSources(cacheOperationSources); }
/** * Set the {@link CacheManager} to use to create a default {@link CacheResolver}. * Replace the current {@link CacheResolver}, if any. * @since 5.0.3 * @see CacheInterceptor#setCacheManager */ public void setCacheManager(CacheManager cacheManager) { this.cacheInterceptor.setCacheManager(cacheManager); }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheInterceptor cacheInterceptor() { CacheInterceptor interceptor = new CacheInterceptor(); interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager); interceptor.setCacheOperationSource(cacheOperationSource()); return interceptor; }
@Bean public CacheInterceptor cacheInterceptor(CacheOperationSource cacheOperationSource) { CacheInterceptor cacheInterceptor = new TestCacheInterceptor(); cacheInterceptor.setCacheManager(cacheManager()); cacheInterceptor.setCacheOperationSources(cacheOperationSource); return cacheInterceptor; } }
@Override protected Object createMainInterceptor() { this.cacheInterceptor.afterPropertiesSet(); return new DefaultPointcutAdvisor(this.pointcut, this.cacheInterceptor); }
@Override public void afterSingletonsInstantiated() { this.cacheInterceptor.afterSingletonsInstantiated(); }
/** * Set the default {@link CacheResolver} that this cache aspect should delegate * to if no specific cache resolver has been set for the operation. * <p>The default resolver resolves the caches against their names and the * default cache manager. * @since 5.0.3 * @see CacheInterceptor#setCacheResolver */ public void setCacheResolver(CacheResolver cacheResolver) { this.cacheInterceptor.setCacheResolver(cacheResolver); }
@Override public void setBeanFactory(BeanFactory beanFactory) { this.cacheInterceptor.setBeanFactory(beanFactory); }
/** * Set the default {@link KeyGenerator} that this cache aspect should delegate to * if no specific key generator has been set for the operation. * <p>The default is a {@link SimpleKeyGenerator}. * @since 5.0.3 * @see CacheInterceptor#setKeyGenerator */ public void setKeyGenerator(KeyGenerator keyGenerator) { this.cacheInterceptor.setKeyGenerator(keyGenerator); }
@Override @Nullable public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CacheOperationInvoker aopAllianceInvoker = () -> { try { return invocation.proceed(); } catch (Throwable ex) { throw new CacheOperationInvoker.ThrowableWrapper(ex); } }; try { return execute(aopAllianceInvoker, invocation.getThis(), method, invocation.getArguments()); } catch (CacheOperationInvoker.ThrowableWrapper th) { throw th.getOriginal(); } }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheInterceptor cacheInterceptor() { CacheInterceptor interceptor = new CacheInterceptor(); interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager); interceptor.setCacheOperationSource(cacheOperationSource()); return interceptor; }
@Override protected Object createMainInterceptor() { this.cacheInterceptor.afterPropertiesSet(); return new DefaultPointcutAdvisor(this.pointcut, this.cacheInterceptor); }
@Override public void afterSingletonsInstantiated() { this.cacheInterceptor.afterSingletonsInstantiated(); }
/** * Set the default {@link CacheResolver} that this cache aspect should delegate * to if no specific cache resolver has been set for the operation. * <p>The default resolver resolves the caches against their names and the * default cache manager. * @since 5.0.3 * @see CacheInterceptor#setCacheResolver */ public void setCacheResolver(CacheResolver cacheResolver) { this.cacheInterceptor.setCacheResolver(cacheResolver); }
@Override public void setBeanFactory(BeanFactory beanFactory) { this.cacheInterceptor.setBeanFactory(beanFactory); }
/** * Set the default {@link KeyGenerator} that this cache aspect should delegate to * if no specific key generator has been set for the operation. * <p>The default is a {@link SimpleKeyGenerator}. * @since 5.0.3 * @see CacheInterceptor#setKeyGenerator */ public void setKeyGenerator(KeyGenerator keyGenerator) { this.cacheInterceptor.setKeyGenerator(keyGenerator); }
@Override @Nullable public Object invoke(final MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CacheOperationInvoker aopAllianceInvoker = () -> { try { return invocation.proceed(); } catch (Throwable ex) { throw new CacheOperationInvoker.ThrowableWrapper(ex); } }; try { return execute(aopAllianceInvoker, invocation.getThis(), method, invocation.getArguments()); } catch (CacheOperationInvoker.ThrowableWrapper th) { throw th.getOriginal(); } }
/** * Set one or more sources to find cache operations. * @see CacheInterceptor#setCacheOperationSources */ public void setCacheOperationSources(CacheOperationSource... cacheOperationSources) { this.cacheInterceptor.setCacheOperationSources(cacheOperationSources); }
@Bean @Role(BeanDefinition.ROLE_INFRASTRUCTURE) public CacheInterceptor cacheInterceptor() { CacheInterceptor interceptor = new CacheInterceptor(); interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager); interceptor.setCacheOperationSource(cacheOperationSource()); return interceptor; }
/** * Set the {@link CacheManager} to use to create a default {@link CacheResolver}. * Replace the current {@link CacheResolver}, if any. * @since 5.0.3 * @see CacheInterceptor#setCacheManager */ public void setCacheManager(CacheManager cacheManager) { this.cacheInterceptor.setCacheManager(cacheManager); }