@Override protected CacheRemoveAllOperation createSimpleOperation() { CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class, SampleObject.class, "simpleRemoveAll"); return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver); }
public CacheRemoveAllOperation(CacheMethodDetails<CacheRemoveAll> methodDetails, CacheResolver cacheResolver) { super(methodDetails, cacheResolver); CacheRemoveAll ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
/** * Specify if the cache should be cleared before invoking the method. By default, the * cache is cleared after the method invocation. * @see javax.cache.annotation.CacheRemoveAll#afterInvocation() */ public boolean isEarlyRemove() { return !getCacheAnnotation().afterInvocation(); }
@Override protected Object invoke( CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) { CacheRemoveAllOperation operation = context.getOperation(); boolean earlyRemove = operation.isEarlyRemove(); if (earlyRemove) { removeAll(context); } try { Object result = invoker.invoke(); if (!earlyRemove) { removeAll(context); } return result; } catch (CacheOperationInvoker.ThrowableWrapper ex) { Throwable original = ex.getOriginal(); if (!earlyRemove && operation.getExceptionTypeFilter().match(original.getClass())) { removeAll(context); } throw ex; } }
@Test public void removeAll() { CacheRemoveAllOperation op = getDefaultCacheOperation(CacheRemoveAllOperation.class); assertEquals(defaultCacheResolver, op.getCacheResolver()); }
@Test public void simpleRemoveAll() { CacheRemoveAllOperation operation = createSimpleOperation(); CacheInvocationParameter[] allParameters = operation.getAllParameters(); assertEquals(0, allParameters.length); }
@Override protected Object invoke( CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) { CacheRemoveAllOperation operation = context.getOperation(); boolean earlyRemove = operation.isEarlyRemove(); if (earlyRemove) { removeAll(context); } try { Object result = invoker.invoke(); if (!earlyRemove) { removeAll(context); } return result; } catch (CacheOperationInvoker.ThrowableWrapper ex) { Throwable original = ex.getOriginal(); if (!earlyRemove && operation.getExceptionTypeFilter().match(original.getClass())) { removeAll(context); } throw ex; } }
@Override protected Object invoke(CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) { CacheRemoveAllOperation operation = context.getOperation(); boolean earlyRemove = operation.isEarlyRemove(); if (earlyRemove) { removeAll(context); } try { Object result = invoker.invoke(); if (!earlyRemove) { removeAll(context); } return result; } catch (CacheOperationInvoker.ThrowableWrapper ex) { Throwable original = ex.getOriginal(); if (!earlyRemove && operation.getExceptionTypeFilter().match(original.getClass())) { removeAll(context); } throw ex; } }
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, @Nullable CacheDefaults defaults, CacheRemoveAll ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); CacheMethodDetails<CacheRemoveAll> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveAllOperation(methodDetails, cacheResolver); }
public CacheRemoveAllOperation(CacheMethodDetails<CacheRemoveAll> methodDetails, CacheResolver cacheResolver) { super(methodDetails, cacheResolver); CacheRemoveAll ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
/** * Specify if the cache should be cleared before invoking the method. By default, the * cache is cleared after the method invocation. * @see javax.cache.annotation.CacheRemoveAll#afterInvocation() */ public boolean isEarlyRemove() { return !getCacheAnnotation().afterInvocation(); }
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, @Nullable CacheDefaults defaults, CacheRemoveAll ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); CacheMethodDetails<CacheRemoveAll> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveAllOperation(methodDetails, cacheResolver); }
public CacheRemoveAllOperation(CacheMethodDetails<CacheRemoveAll> methodDetails, CacheResolver cacheResolver) { super(methodDetails, cacheResolver); CacheRemoveAll ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
/** * Specify if the cache should be cleared before invoking the method. By default, the * cache is cleared after the method invocation. * @see javax.cache.annotation.CacheRemoveAll#afterInvocation() */ public boolean isEarlyRemove() { return !getCacheAnnotation().afterInvocation(); }
protected CacheRemoveAllOperation createCacheRemoveAllOperation(Method method, CacheDefaults defaults, CacheRemoveAll ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); CacheMethodDetails<CacheRemoveAll> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveAllOperation(methodDetails, cacheResolver); }