javax.cache.annotation.CacheValue Java Examples

The following examples show how to use javax.cache.annotation.CacheValue. 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: AbstractJCacheOperation.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
public CacheParameterDetail(Method method, int parameterPosition) {
	this.rawType = method.getParameterTypes()[parameterPosition];
	this.annotations = new LinkedHashSet<Annotation>();
	boolean foundKeyAnnotation = false;
	boolean foundValueAnnotation = false;
	for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) {
		this.annotations.add(annotation);
		if (CacheKey.class.isAssignableFrom(annotation.annotationType())) {
			foundKeyAnnotation = true;
		}
		if (CacheValue.class.isAssignableFrom(annotation.annotationType())) {
			foundValueAnnotation = true;
		}
	}
	this.parameterPosition = parameterPosition;
	this.isKey = foundKeyAnnotation;
	this.isValue = foundValueAnnotation;
}
 
Example #2
Source File: AbstractJCacheOperation.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public CacheParameterDetail(Method method, int parameterPosition) {
	this.rawType = method.getParameterTypes()[parameterPosition];
	this.annotations = new LinkedHashSet<Annotation>();
	boolean foundKeyAnnotation = false;
	boolean foundValueAnnotation = false;
	for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) {
		this.annotations.add(annotation);
		if (CacheKey.class.isAssignableFrom(annotation.annotationType())) {
			foundKeyAnnotation = true;
		}
		if (CacheValue.class.isAssignableFrom(annotation.annotationType())) {
			foundValueAnnotation = true;
		}
	}
	this.parameterPosition = parameterPosition;
	this.isKey = foundKeyAnnotation;
	this.isValue = foundValueAnnotation;
}
 
Example #3
Source File: AbstractJCacheOperation.java    From spring-analysis-note with MIT License 6 votes vote down vote up
public CacheParameterDetail(Method method, int parameterPosition) {
	this.rawType = method.getParameterTypes()[parameterPosition];
	this.annotations = new LinkedHashSet<>();
	boolean foundKeyAnnotation = false;
	boolean foundValueAnnotation = false;
	for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) {
		this.annotations.add(annotation);
		if (CacheKey.class.isAssignableFrom(annotation.annotationType())) {
			foundKeyAnnotation = true;
		}
		if (CacheValue.class.isAssignableFrom(annotation.annotationType())) {
			foundValueAnnotation = true;
		}
	}
	this.parameterPosition = parameterPosition;
	this.isKey = foundKeyAnnotation;
	this.isValue = foundValueAnnotation;
}
 
Example #4
Source File: AbstractJCacheOperation.java    From java-technology-stack with MIT License 6 votes vote down vote up
public CacheParameterDetail(Method method, int parameterPosition) {
	this.rawType = method.getParameterTypes()[parameterPosition];
	this.annotations = new LinkedHashSet<>();
	boolean foundKeyAnnotation = false;
	boolean foundValueAnnotation = false;
	for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) {
		this.annotations.add(annotation);
		if (CacheKey.class.isAssignableFrom(annotation.annotationType())) {
			foundKeyAnnotation = true;
		}
		if (CacheValue.class.isAssignableFrom(annotation.annotationType())) {
			foundValueAnnotation = true;
		}
	}
	this.parameterPosition = parameterPosition;
	this.isKey = foundKeyAnnotation;
	this.isValue = foundValueAnnotation;
}
 
Example #5
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #6
Source File: CDIJCacheHelper.java    From commons-jcs with Apache License 2.0 5 votes vote down vote up
private Integer getValueParameter(final List<Set<Annotation>> annotations)
{
    int idx = 0;
    for (final Set<Annotation> set : annotations)
    {
        for (final Annotation a : set)
        {
            if (a.annotationType() == CacheValue.class)
            {
                return idx;
            }
        }
    }
    return -1;
}
 
Example #7
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #8
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #9
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #10
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #11
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPut(String id, @CacheValue Object value) {
	Object key = SimpleKeyGenerator.generateKey(id);
	Cache.ValueWrapper valueWrapper = defaultCache.get(key);
	if (valueWrapper == null) {
		throw new AssertionError("Excepted value to be put in cache with key " + key);
	}
	Object actual = valueWrapper.get();
	if (value != actual) { // instance check on purpose
		throw new AssertionError("Wrong value set in cache with key " + key + ". " +
				"Expected=" + value + ", but got=" + actual);
	}
}
 
Example #12
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPutWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #13
Source File: SampleObject.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CachePut(cacheName = "simpleCache")
public void simplePut(Long id, @CacheValue SampleObject instance) {
}
 
Example #14
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPutWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #15
Source File: SampleObject.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CachePut(cacheName = "simpleCache")
public void multiCacheValues(Long id, @CacheValue SampleObject instance,
		@CacheValue SampleObject anotherInstance) {
}
 
Example #16
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut(cacheFor = UnsupportedOperationException.class)
public void putWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #17
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut
public void put(String id, @CacheValue Object value) {
}
 
Example #18
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut(afterInvocation = false)
public void earlyPutWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #19
Source File: SampleObject.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CachePut(cacheName = "simpleCache", afterInvocation = false,
		cacheFor = Exception.class, noCacheFor = RuntimeException.class)
public void fullPutConfig(@CacheKey Long id, @CacheValue SampleObject instance) {
}
 
Example #20
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut(cacheFor = UnsupportedOperationException.class)
public void putWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #21
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CachePut
public void put(String id, @CacheValue Object value) {
}
 
Example #22
Source File: JCacheErrorHandlerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CachePut
public void put(long id, @CacheValue Object object) {
}
 
Example #23
Source File: SampleObject.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CachePut(cacheName = "simpleCache", afterInvocation = false,
		cacheFor = Exception.class, noCacheFor = RuntimeException.class)
public void fullPutConfig(@CacheKey Long id, @CacheValue SampleObject instance) {
}
 
Example #24
Source File: SampleObject.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CachePut(cacheName = "simpleCache")
public void multiCacheValues(Long id, @CacheValue SampleObject instance,
		@CacheValue SampleObject anotherInstance) {
}
 
Example #25
Source File: SampleObject.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CachePut(cacheName = "simpleCache")
public void simplePut(Long id, @CacheValue SampleObject instance) {
}
 
Example #26
Source File: JCacheErrorHandlerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CachePut
public void put(long id, @CacheValue Object object) {
}
 
Example #27
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CachePut
public void put(String id, @CacheValue Object value) {
}
 
Example #28
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CachePut(cacheFor = UnsupportedOperationException.class)
public void putWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #29
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CachePut(cacheFor = UnsupportedOperationException.class)
public void putWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}
 
Example #30
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@CachePut(cacheFor = UnsupportedOperationException.class)
public void putWithException(@CacheKey String id, @CacheValue Object value, boolean matchFilter) {
	throwException(matchFilter);
}