javax.cache.annotation.CacheRemoveAll Java Examples

The following examples show how to use javax.cache.annotation.CacheRemoveAll. 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: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #2
Source File: CacheTest.java    From cache2k with Apache License 2.0 5 votes vote down vote up
/**
 * This just illustrates how easily we could discover a runtime annotation.
 */
@Test
public void testAnnotations() {
  Object value = new CacheNameOnEachMethodBlogManagerImpl();
  boolean foundRemoveAllAnnotation = false;
  for (Method m : value.getClass().getMethods()) {
    if (m.isAnnotationPresent(CacheRemoveAll.class)) {
      System.out.println(m.getName());
      foundRemoveAllAnnotation = true;
    }
  }
  assertTrue(foundRemoveAllAnnotation);
}
 
Example #3
Source File: CDIJCacheHelper.java    From commons-jcs with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: JpaConferenceRepositoryImpl.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Override
@CacheRemoveAll(cacheName = "conference")
public void deleteAll() {
	List<Conference> all = entityManager.createQuery("from Conference",
			Conference.class).getResultList();
	for (Conference c : all) {
		delete(c);
	}
	entityManager.flush();
}
 
Example #5
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #6
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #7
Source File: CacheRemoveAllOperationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected CacheRemoveAllOperation createSimpleOperation() {
	CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class,
			SampleObject.class, "simpleRemoveAll");

	return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver);
}
 
Example #8
Source File: AnnotationJCacheOperationSource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #9
Source File: AnnotationJCacheOperationSource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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 #10
Source File: AnnotationJCacheOperationSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: AnnotationJCacheOperationSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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 #12
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #13
Source File: CacheRemoveAllOperationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected CacheRemoveAllOperation createSimpleOperation() {
	CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class,
			SampleObject.class, "simpleRemoveAll");

	return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver);
}
 
Example #14
Source File: AnnotationJCacheOperationSource.java    From java-technology-stack with MIT License 5 votes vote down vote up
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);
}
 
Example #15
Source File: AnnotationJCacheOperationSource.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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 #16
Source File: AnnotationJCacheOperationSource.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #18
Source File: AnnotationJCacheOperationSource.java    From spring-analysis-note with MIT License 5 votes vote down vote up
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);
}
 
Example #19
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false)
public void earlyRemoveAll() {
	ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) defaultCache.getNativeCache();
	if (!nativeCache.isEmpty()) {
		throw new AssertionError("Cache was expected to be empty");
	}
}
 
Example #20
Source File: CacheRemoveAllOperationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected CacheRemoveAllOperation createSimpleOperation() {
	CacheMethodDetails<CacheRemoveAll> methodDetails = create(CacheRemoveAll.class,
			SampleObject.class, "simpleRemoveAll");

	return new CacheRemoveAllOperation(methodDetails, defaultCacheResolver);
}
 
Example #21
Source File: SampleObject.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CacheRemoveAll(cacheName = "simpleCache")
public void simpleRemoveAll() {
}
 
Example #22
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CacheRemoveAll
public void removeAll() {
}
 
Example #23
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CacheRemove
@CacheRemoveAll
public void multiAnnotations() {
}
 
Example #24
Source File: JCacheErrorHandlerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CacheRemoveAll
public void clear() {
}
 
Example #25
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheRemoveAll
public void removeAll() {
}
 
Example #26
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheRemoveAll(noEvictFor = NullPointerException.class)
public void removeAllWithException(boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #27
Source File: JCacheErrorHandlerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CacheRemoveAll
public void clear() {
}
 
Example #28
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheRemoveAll(afterInvocation = false, evictFor = UnsupportedOperationException.class)
public void earlyRemoveAllWithException(boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #29
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheRemoveAll
public void removeAll() {
}
 
Example #30
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheRemoveAll(noEvictFor = NullPointerException.class)
public void removeAllWithException(boolean matchFilter) {
	throwException(matchFilter);
}