javax.cache.annotation.CacheRemove Java Examples
The following examples show how to use
javax.cache.annotation.CacheRemove.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationJCacheOperationSource.java From spring-analysis-note with MIT License | 5 votes |
@Override protected JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); CachePut cachePut = method.getAnnotation(CachePut.class); CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class); int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll); if (found == 0) { return null; } if (found > 1) { throw new IllegalStateException("More than one cache annotation found on '" + method + "'"); } CacheDefaults defaults = getCacheDefaults(method, targetType); if (cacheResult != null) { return createCacheResultOperation(method, defaults, cacheResult); } else if (cachePut != null) { return createCachePutOperation(method, defaults, cachePut); } else if (cacheRemove != null) { return createCacheRemoveOperation(method, defaults, cacheRemove); } else { return createCacheRemoveAllOperation(method, defaults, cacheRemoveAll); } }
Example #2
Source File: CDIJCacheHelper.java From commons-jcs with Apache License 2.0 | 5 votes |
public MethodMeta(Class<?>[] parameterTypes, List<Set<Annotation>> parameterAnnotations, Set<Annotation> annotations, Integer[] keysIndices, Integer valueIndex, Integer[] parameterIndices, String cacheResultCacheName, CacheResolverFactory cacheResultResolverFactory, CacheKeyGenerator cacheResultKeyGenerator, CacheResult cacheResult, String cachePutCacheName, CacheResolverFactory cachePutResolverFactory, CacheKeyGenerator cachePutKeyGenerator, boolean cachePutAfter, CachePut cachePut, String cacheRemoveCacheName, CacheResolverFactory cacheRemoveResolverFactory, CacheKeyGenerator cacheRemoveKeyGenerator, boolean cacheRemoveAfter, CacheRemove cacheRemove, String cacheRemoveAllCacheName, CacheResolverFactory cacheRemoveAllResolverFactory, boolean cacheRemoveAllAfter, CacheRemoveAll cacheRemoveAll) { this.parameterTypes = parameterTypes; this.parameterAnnotations = parameterAnnotations; this.annotations = annotations; this.keysIndices = keysIndices; this.valueIndex = valueIndex; this.parameterIndices = parameterIndices; this.cacheResultCacheName = cacheResultCacheName; this.cacheResultResolverFactory = cacheResultResolverFactory; this.cacheResultKeyGenerator = cacheResultKeyGenerator; this.cacheResult = cacheResult; this.cachePutCacheName = cachePutCacheName; this.cachePutResolverFactory = cachePutResolverFactory; this.cachePutKeyGenerator = cachePutKeyGenerator; this.cachePutAfter = cachePutAfter; this.cachePut = cachePut; this.cacheRemoveCacheName = cacheRemoveCacheName; this.cacheRemoveResolverFactory = cacheRemoveResolverFactory; this.cacheRemoveKeyGenerator = cacheRemoveKeyGenerator; this.cacheRemoveAfter = cacheRemoveAfter; this.cacheRemove = cacheRemove; this.cacheRemoveAllCacheName = cacheRemoveAllCacheName; this.cacheRemoveAllResolverFactory = cacheRemoveAllResolverFactory; this.cacheRemoveAllAfter = cacheRemoveAllAfter; this.cacheRemoveAll = cacheRemoveAll; }
Example #3
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #4
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #5
Source File: CacheRemoveOperationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected CacheRemoveOperation createSimpleOperation() { CacheMethodDetails<CacheRemove> methodDetails = create(CacheRemove.class, SampleObject.class, "simpleRemove", Long.class); return new CacheRemoveOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator); }
Example #6
Source File: AnnotationJCacheOperationSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
protected CacheRemoveOperation createCacheRemoveOperation(Method method, CacheDefaults defaults, CacheRemove ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator); }
Example #7
Source File: AnnotationJCacheOperationSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected JCacheOperation<?> findCacheOperation(Method method, Class<?> targetType) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); CachePut cachePut = method.getAnnotation(CachePut.class); CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class); int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll); if (found == 0) { return null; } if (found > 1) { throw new IllegalStateException("More than one cache annotation found on '" + method + "'"); } CacheDefaults defaults = getCacheDefaults(method, targetType); if (cacheResult != null) { return createCacheResultOperation(method, defaults, cacheResult); } else if (cachePut != null) { return createCachePutOperation(method, defaults, cachePut); } else if (cacheRemove != null) { return createCacheRemoveOperation(method, defaults, cacheRemove); } else { return createCacheRemoveAllOperation(method, defaults, cacheRemoveAll); } }
Example #8
Source File: CacheRemoveOperation.java From spring4-understanding with Apache License 2.0 | 5 votes |
public CacheRemoveOperation( CacheMethodDetails<CacheRemove> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CacheRemove ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
Example #9
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 5 votes |
protected CacheRemoveOperation createCacheRemoveOperation(Method method, CacheDefaults defaults, CacheRemove ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator); }
Example #10
Source File: AnnotationJCacheOperationSource.java From lams with GNU General Public License v2.0 | 5 votes |
@Override protected JCacheOperation<?> findCacheOperation(Method method, Class<?> targetType) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); CachePut cachePut = method.getAnnotation(CachePut.class); CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class); int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll); if (found == 0) { return null; } if (found > 1) { throw new IllegalStateException("More than one cache annotation found on '" + method + "'"); } CacheDefaults defaults = getCacheDefaults(method, targetType); if (cacheResult != null) { return createCacheResultOperation(method, defaults, cacheResult); } else if (cachePut != null) { return createCachePutOperation(method, defaults, cachePut); } else if (cacheRemove != null) { return createCacheRemoveOperation(method, defaults, cacheRemove); } else { return createCacheRemoveAllOperation(method, defaults, cacheRemoveAll); } }
Example #11
Source File: CacheRemoveOperation.java From lams with GNU General Public License v2.0 | 5 votes |
public CacheRemoveOperation( CacheMethodDetails<CacheRemove> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CacheRemove ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
Example #12
Source File: AnnotatedJCacheableService.java From java-technology-stack with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #13
Source File: AnnotatedJCacheableService.java From java-technology-stack with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #14
Source File: CacheRemoveOperationTests.java From java-technology-stack with MIT License | 5 votes |
@Override protected CacheRemoveOperation createSimpleOperation() { CacheMethodDetails<CacheRemove> methodDetails = create(CacheRemove.class, SampleObject.class, "simpleRemove", Long.class); return new CacheRemoveOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator); }
Example #15
Source File: AnnotationJCacheOperationSource.java From java-technology-stack with MIT License | 5 votes |
protected CacheRemoveOperation createCacheRemoveOperation(Method method, @Nullable CacheDefaults defaults, CacheRemove ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator); }
Example #16
Source File: AnnotationJCacheOperationSource.java From java-technology-stack with MIT License | 5 votes |
@Override protected JCacheOperation<?> findCacheOperation(Method method, @Nullable Class<?> targetType) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); CachePut cachePut = method.getAnnotation(CachePut.class); CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); CacheRemoveAll cacheRemoveAll = method.getAnnotation(CacheRemoveAll.class); int found = countNonNull(cacheResult, cachePut, cacheRemove, cacheRemoveAll); if (found == 0) { return null; } if (found > 1) { throw new IllegalStateException("More than one cache annotation found on '" + method + "'"); } CacheDefaults defaults = getCacheDefaults(method, targetType); if (cacheResult != null) { return createCacheResultOperation(method, defaults, cacheResult); } else if (cachePut != null) { return createCachePutOperation(method, defaults, cachePut); } else if (cacheRemove != null) { return createCacheRemoveOperation(method, defaults, cacheRemove); } else { return createCacheRemoveAllOperation(method, defaults, cacheRemoveAll); } }
Example #17
Source File: CacheRemoveOperation.java From java-technology-stack with MIT License | 5 votes |
public CacheRemoveOperation( CacheMethodDetails<CacheRemove> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CacheRemove ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
Example #18
Source File: CacheRemoveOperationTests.java From spring-analysis-note with MIT License | 5 votes |
@Override protected CacheRemoveOperation createSimpleOperation() { CacheMethodDetails<CacheRemove> methodDetails = create(CacheRemove.class, SampleObject.class, "simpleRemove", Long.class); return new CacheRemoveOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator); }
Example #19
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #20
Source File: AnnotationJCacheOperationSource.java From spring-analysis-note with MIT License | 5 votes |
protected CacheRemoveOperation createCacheRemoveOperation(Method method, @Nullable CacheDefaults defaults, CacheRemove ann) { String cacheName = determineCacheName(method, defaults, ann.cacheName()); CacheResolverFactory cacheResolverFactory = determineCacheResolverFactory(defaults, ann.cacheResolverFactory()); KeyGenerator keyGenerator = determineKeyGenerator(defaults, ann.cacheKeyGenerator()); CacheMethodDetails<CacheRemove> methodDetails = createMethodDetails(method, ann, cacheName); CacheResolver cacheResolver = getCacheResolver(cacheResolverFactory, methodDetails); return new CacheRemoveOperation(methodDetails, cacheResolver, keyGenerator); }
Example #21
Source File: CacheRemoveOperation.java From spring-analysis-note with MIT License | 5 votes |
public CacheRemoveOperation( CacheMethodDetails<CacheRemove> methodDetails, CacheResolver cacheResolver, KeyGenerator keyGenerator) { super(methodDetails, cacheResolver, keyGenerator); CacheRemove ann = methodDetails.getCacheAnnotation(); this.exceptionTypeFilter = createExceptionTypeFilter(ann.evictFor(), ann.noEvictFor()); }
Example #22
Source File: AnnotatedJCacheableService.java From spring-analysis-note with MIT License | 5 votes |
@Override @CacheRemove(afterInvocation = false) public void earlyRemove(String id) { Object key = SimpleKeyGenerator.generateKey(id); Cache.ValueWrapper valueWrapper = defaultCache.get(key); if (valueWrapper != null) { throw new AssertionError("Value with key " + key + " expected to be already remove from cache"); } }
Example #23
Source File: CDIJCacheHelper.java From commons-jcs with Apache License 2.0 | 4 votes |
private MethodMeta createMeta(final InvocationContext ic) { final CacheDefaults defaults = findDefaults(ic.getTarget() == null ? null : ic.getTarget() .getClass(), ic.getMethod()); final Class<?>[] parameterTypes = ic.getMethod().getParameterTypes(); final Annotation[][] parameterAnnotations = ic.getMethod().getParameterAnnotations(); final List<Set<Annotation>> annotations = new ArrayList<>(); for (final Annotation[] parameterAnnotation : parameterAnnotations) { final Set<Annotation> set = new HashSet<>(parameterAnnotation.length); set.addAll(Arrays.asList(parameterAnnotation)); annotations.add(set); } final Set<Annotation> mtdAnnotations = new HashSet<>(); mtdAnnotations.addAll(Arrays.asList(ic.getMethod().getAnnotations())); final CacheResult cacheResult = ic.getMethod().getAnnotation(CacheResult.class); final String cacheResultCacheResultName = cacheResult == null ? null : defaultName(ic.getMethod(), defaults, cacheResult.cacheName()); final CacheResolverFactory cacheResultCacheResolverFactory = cacheResult == null ? null : cacheResolverFactoryFor(defaults, cacheResult.cacheResolverFactory()); final CacheKeyGenerator cacheResultCacheKeyGenerator = cacheResult == null ? null : cacheKeyGeneratorFor(defaults, cacheResult.cacheKeyGenerator()); final CachePut cachePut = ic.getMethod().getAnnotation(CachePut.class); final String cachePutCachePutName = cachePut == null ? null : defaultName(ic.getMethod(), defaults, cachePut.cacheName()); final CacheResolverFactory cachePutCacheResolverFactory = cachePut == null ? null : cacheResolverFactoryFor(defaults, cachePut.cacheResolverFactory()); final CacheKeyGenerator cachePutCacheKeyGenerator = cachePut == null ? null : cacheKeyGeneratorFor(defaults, cachePut.cacheKeyGenerator()); final CacheRemove cacheRemove = ic.getMethod().getAnnotation(CacheRemove.class); final String cacheRemoveCacheRemoveName = cacheRemove == null ? null : defaultName(ic.getMethod(), defaults, cacheRemove.cacheName()); final CacheResolverFactory cacheRemoveCacheResolverFactory = cacheRemove == null ? null : cacheResolverFactoryFor(defaults, cacheRemove.cacheResolverFactory()); final CacheKeyGenerator cacheRemoveCacheKeyGenerator = cacheRemove == null ? null : cacheKeyGeneratorFor(defaults, cacheRemove.cacheKeyGenerator()); final CacheRemoveAll cacheRemoveAll = ic.getMethod().getAnnotation(CacheRemoveAll.class); final String cacheRemoveAllCacheRemoveAllName = cacheRemoveAll == null ? null : defaultName(ic.getMethod(), defaults, cacheRemoveAll.cacheName()); final CacheResolverFactory cacheRemoveAllCacheResolverFactory = cacheRemoveAll == null ? null : cacheResolverFactoryFor(defaults, cacheRemoveAll.cacheResolverFactory()); return new MethodMeta( parameterTypes, annotations, mtdAnnotations, keyParameterIndexes(ic.getMethod()), getValueParameter(annotations), getKeyParameters(annotations), cacheResultCacheResultName, cacheResultCacheResolverFactory, cacheResultCacheKeyGenerator, cacheResult, cachePutCachePutName, cachePutCacheResolverFactory, cachePutCacheKeyGenerator, cachePut != null && cachePut.afterInvocation(), cachePut, cacheRemoveCacheRemoveName, cacheRemoveCacheResolverFactory, cacheRemoveCacheKeyGenerator, cacheRemove != null && cacheRemove.afterInvocation(), cacheRemove, cacheRemoveAllCacheRemoveAllName, cacheRemoveAllCacheResolverFactory, cacheRemoveAll != null && cacheRemoveAll.afterInvocation(), cacheRemoveAll); }
Example #24
Source File: JpaConferenceRepositoryImpl.java From spring4-sandbox with Apache License 2.0 | 4 votes |
@Override @CacheRemove(cacheName = "conference" ) public void delete(final Conference conf) { entityManager.remove(entityManager.merge(conf)); entityManager.flush(); }
Example #25
Source File: JpaConferenceRepositoryImpl.java From spring4-sandbox with Apache License 2.0 | 4 votes |
@Override @CacheRemove(cacheName = "conference" ) public void delete(final Long id) { entityManager.remove(entityManager.find(Conference.class, id)); entityManager.flush(); }
Example #26
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override @CacheRemove(afterInvocation = false, evictFor = UnsupportedOperationException.class) public void earlyRemoveWithException(@CacheKey String id, boolean matchFilter) { throwException(matchFilter); }
Example #27
Source File: CDIJCacheHelper.java From commons-jcs with Apache License 2.0 | 4 votes |
public CacheRemove getCacheRemove() { return cacheRemove; }
Example #28
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override @CacheRemove(noEvictFor = NullPointerException.class) public void removeWithException(@CacheKey String id, boolean matchFilter) { throwException(matchFilter); }
Example #29
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override @CacheRemove public void remove(String id) { }
Example #30
Source File: AnnotatedJCacheableService.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override @CacheRemove(afterInvocation = false, evictFor = UnsupportedOperationException.class) public void earlyRemoveWithException(@CacheKey String id, boolean matchFilter) { throwException(matchFilter); }