javax.cache.annotation.CacheResolver Java Examples

The following examples show how to use javax.cache.annotation.CacheResolver. 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: 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 #2
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 #3
Source File: VaultProxyCacheResolver.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
private CacheResolver findCacheResolver(final String exceptionCacheName) {
    Cache<?, ?> cache = cacheManager.getCache(exceptionCacheName);
    if (cache == null) {
        try {
            cache = createCache(exceptionCacheName);
        } catch (final CacheException ce) {
            cache = cacheManager.getCache(exceptionCacheName);
        }
    }
    return new CacheResolverImpl(cache);
}
 
Example #4
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 #5
Source File: CacheResolverFactoryImpl.java    From commons-jcs with Apache License 2.0 5 votes vote down vote up
@Override
public CacheResolver getExceptionCacheResolver(final CacheMethodDetails<CacheResult> cacheMethodDetails)
{
    final String exceptionCacheName = cacheMethodDetails.getCacheAnnotation().exceptionCacheName();
    if (exceptionCacheName == null || exceptionCacheName.isEmpty())
    {
        throw new IllegalArgumentException("CacheResult.exceptionCacheName() not specified");
    }
    return findCacheResolver(exceptionCacheName);
}
 
Example #6
Source File: CacheResolverFactoryImpl.java    From commons-jcs with Apache License 2.0 5 votes vote down vote up
private CacheResolver findCacheResolver(String exceptionCacheName)
{
    Cache<?, ?> cache = cacheManager.getCache(exceptionCacheName);
    if (cache == null)
    {
        cache = createCache(exceptionCacheName);
    }
    return new CacheResolverImpl(cache);
}
 
Example #7
Source File: TestableCacheResolverFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #8
Source File: TestableCacheResolverFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #9
Source File: TestableCacheResolverFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #10
Source File: TestableCacheResolverFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #11
Source File: VaultProxyCacheResolver.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public CacheResolver getCacheResolver(final CacheMethodDetails<? extends Annotation> cacheMethodDetails) {
    return findCacheResolver(cacheMethodDetails.getCacheName());
}
 
Example #12
Source File: VaultProxyCacheResolver.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public CacheResolver getExceptionCacheResolver(final CacheMethodDetails<CacheResult> cacheMethodDetails) {
    return findCacheResolver(cacheMethodDetails.getCacheAnnotation().exceptionCacheName());
}
 
Example #13
Source File: TestableCacheResolverFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #14
Source File: TestableCacheResolverFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cacheMethodDetails) {
	return new TestableCacheResolver();
}
 
Example #15
Source File: CacheResolverFactoryImpl.java    From commons-jcs with Apache License 2.0 4 votes vote down vote up
@Override
public CacheResolver getCacheResolver(CacheMethodDetails<? extends Annotation> cacheMethodDetails)
{
    return findCacheResolver(cacheMethodDetails.getCacheName());
}