javax.cache.annotation.CacheInvocationContext Java Examples

The following examples show how to use javax.cache.annotation.CacheInvocationContext. 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: CacheResolverAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
	if (!(context instanceof CacheInvocationContext<?>)) {
		throw new IllegalStateException("Unexpected context " + context);
	}
	CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
	javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext);
	if (cache == null) {
		throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target);
	}
	return Collections.singleton(new JCacheCache(cache));
}
 
Example #2
Source File: CacheResolverAdapterTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
	CacheResolver cacheResolver = mock(CacheResolver.class);
	javax.cache.Cache cache;
	if (cacheName == null) {
		cache = null;
	}
	else {
		cache = mock(javax.cache.Cache.class);
		given(cache.getName()).willReturn(cacheName);
	}
	given(cacheResolver.resolveCache(context)).willReturn(cache);
	return cacheResolver;
}
 
Example #3
Source File: TestableCacheResolver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
	String cacheName = cacheInvocationContext.getCacheName();
	Cache<K, V> mock = mock(Cache.class);
	given(mock.getName()).willReturn(cacheName);
	return mock;
}
 
Example #4
Source File: CacheResolverAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
	if (!(context instanceof CacheInvocationContext<?>)) {
		throw new IllegalStateException("Unexpected context " + context);
	}
	CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
	javax.cache.Cache<Object, Object> cache = this.target.resolveCache(cacheInvocationContext);
	if (cache == null) {
		throw new IllegalStateException("Could not resolve cache for " + context + " using " + this.target);
	}
	return Collections.singleton(new JCacheCache(cache));
}
 
Example #5
Source File: CacheResolverAdapterTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
	CacheResolver cacheResolver = mock(CacheResolver.class);
	javax.cache.Cache cache;
	if (cacheName == null) {
		cache = null;
	}
	else {
		cache = mock(javax.cache.Cache.class);
		given(cache.getName()).willReturn(cacheName);
	}
	given(cacheResolver.resolveCache(context)).willReturn(cache);
	return cacheResolver;
}
 
Example #6
Source File: TestableCacheResolver.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
	String cacheName = cacheInvocationContext.getCacheName();
	Cache<K, V> mock = mock(Cache.class);
	given(mock.getName()).willReturn(cacheName);
	return mock;
}
 
Example #7
Source File: CacheResolverAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
	if (!(context instanceof CacheInvocationContext<?>)) {
		throw new IllegalStateException("Unexpected context " + context);
	}
	CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
	javax.cache.Cache<Object, Object> cache = target.resolveCache(cacheInvocationContext);
	Assert.notNull(cache, "Cannot resolve cache for '" + context + "' using '" + target + "'");
	return Collections.singleton(new JCacheCache(cache));
}
 
Example #8
Source File: CacheResolverAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) {
	if (!(context instanceof CacheInvocationContext<?>)) {
		throw new IllegalStateException("Unexpected context " + context);
	}
	CacheInvocationContext<?> cacheInvocationContext = (CacheInvocationContext<?>) context;
	javax.cache.Cache<Object, Object> cache = target.resolveCache(cacheInvocationContext);
	Assert.notNull(cache, "Cannot resolve cache for '" + context + "' using '" + target + "'");
	return Collections.singleton(new JCacheCache(cache));
}
 
Example #9
Source File: CacheResolverAdapterTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
	CacheResolver cacheResolver = mock(CacheResolver.class);
	final javax.cache.Cache cache;
	if (cacheName == null) {
		cache = null;
	}
	else {
		cache = mock(javax.cache.Cache.class);
		given(cache.getName()).willReturn(cacheName);
	}
	given(cacheResolver.resolveCache(context)).willReturn(cache);
	return cacheResolver;
}
 
Example #10
Source File: TestableCacheResolver.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
	String cacheName = cacheInvocationContext.getCacheName();
	Cache<K, V> mock = mock(Cache.class);
	given(mock.getName()).willReturn(cacheName);
	return mock;
}
 
Example #11
Source File: CacheResolverImpl.java    From commons-jcs with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> Cache<K, V> resolveCache(final CacheInvocationContext<? extends Annotation> cacheInvocationContext)
{
    return (Cache<K, V>) delegate;
}