public void afterPropertiesSet() { getCacheOperationSource(); this.cacheResultInterceptor = new CacheResultInterceptor(getErrorHandler()); this.cachePutInterceptor = new CachePutInterceptor(getErrorHandler()); this.cacheRemoveEntryInterceptor = new CacheRemoveEntryInterceptor(getErrorHandler()); this.cacheRemoveAllInterceptor = new CacheRemoveAllInterceptor(getErrorHandler()); this.initialized = true; }
public DefaultCacheKeyInvocationContext(AbstractJCacheKeyOperation<A> operation, Object target, Object[] args) { super(operation, target, args); this.keyParameters = operation.getKeyParameters(args); if (operation instanceof CachePutOperation) { this.valueParameter = ((CachePutOperation) operation).getValueParameter(args); } else { this.valueParameter = null; } }
@Override public boolean matches(Method method, Class<?> targetClass) { JCacheOperationSource cas = getCacheOperationSource(); return (cas != null && cas.getCacheOperation(method, targetClass) != null); }
protected DefaultCacheInvocationContext<?> createDummyContext() throws Exception { Method method = Sample.class.getMethod("get", String.class); CacheResult cacheAnnotation = method.getAnnotation(CacheResult.class); CacheMethodDetails<CacheResult> methodDetails = new DefaultCacheMethodDetails<>(method, cacheAnnotation, "test"); CacheResultOperation operation = new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); return new DefaultCacheInvocationContext<>(operation, new Sample(), new Object[] {"id"}); }
protected void cacheValue(CacheOperationInvocationContext<CachePutOperation> context, Object value) { Object key = generateKey(context); Cache cache = resolveCache(context); doPut(cache, key, value); }
protected JCacheInterceptor createInterceptor(JCacheOperationSource source) { JCacheInterceptor interceptor = new JCacheInterceptor(); interceptor.setCacheOperationSource(source); interceptor.afterPropertiesSet(); return interceptor; }
@Override protected CacheResolver getDefaultExceptionCacheResolver() { if (getExceptionCacheResolver() == null) { this.exceptionCacheResolver = SingletonSupplier.of(new LazyCacheResolver()); } return getExceptionCacheResolver(); }
@Override protected CacheResultOperation createSimpleOperation() { CacheMethodDetails<CacheResult> methodDetails = create(CacheResult.class, SampleObject.class, "simpleGet", Long.class); return new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); }
@Override protected CacheRemoveOperation createSimpleOperation() { CacheMethodDetails<CacheRemove> methodDetails = create(CacheRemove.class, SampleObject.class, "simpleRemove", Long.class); return new CacheRemoveOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator); }
@Override protected CacheRemoveAllOperation createSimpleOperation() { CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class, SampleObject.class, "simpleRemoveAll"); return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver); }
@SuppressWarnings("unchecked") private CacheOperationInvocationContext<?> createCacheOperationInvocationContext( Object target, Object[] args, JCacheOperation<?> operation) { return new DefaultCacheInvocationContext<>( (JCacheOperation<Annotation>) operation, target, args); }
@Override public Set<Annotation> getAnnotations() { return this.operation.getAnnotations(); }
@Override public String getCacheName() { return this.operation.getCacheName(); }
@SuppressWarnings("unchecked") private CacheKeyInvocationContext<?> createCacheKeyInvocationContext( Object target, JCacheOperation<?> operation, Object[] params) { AbstractJCacheKeyOperation<Annotation> keyCacheOperation = (AbstractJCacheKeyOperation<Annotation>) operation; return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, params); }
public DefaultCacheInvocationContext(JCacheOperation<A> operation, Object target, Object[] args) { this.operation = operation; this.target = target; this.args = args; this.allParameters = operation.getAllParameters(args); }
@Override public Object invoke() throws ThrowableWrapper { return invokeOperation(this.delegate); } }
/** * Create a new instance. * @param methodDetails the {@link CacheMethodDetails} related to the cached method * @param cacheResolver the cache resolver to resolve regular caches * @param keyGenerator the key generator to compute cache keys */ protected AbstractJCacheKeyOperation(CacheMethodDetails<A> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver); this.keyGenerator = keyGenerator; this.keyParameterDetails = initializeKeyParameterDetails(this.allParameterDetails); }
/** * Set the {@link org.springframework.aop.ClassFilter} to use for this pointcut. * Default is {@link org.springframework.aop.ClassFilter#TRUE}. */ public void setClassFilter(ClassFilter classFilter) { this.pointcut.setClassFilter(classFilter); }
public CacheInvocationParameter toCacheInvocationParameter(Object value) { return new CacheInvocationParameterImpl(this, value); } }
@Override protected CachePutOperation createSimpleOperation() { CacheMethodDetails<CachePut> methodDetails = create(CachePut.class, SampleObject.class, "simplePut", Long.class, SampleObject.class); return createDefaultOperation(methodDetails); }