use of com.adeptj.modularweb.cache.api.CacheProvider in project adeptj-modules by AdeptJ.
the class ShiroCacheManager method getCache.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
LOGGER.info("Getting cache: [{}]", name);
CacheProvider cacheProvider = CacheProviderTracker.getCacheProvider();
Cache<K, V> shiroCache = null;
switch(name) {
case SHIRO_AUTHORIZATION_CACHE:
com.adeptj.modularweb.cache.api.Cache<K, V> cache = (com.adeptj.modularweb.cache.api.Cache<K, V>) cacheProvider.getCache(SHIRO_AUTHORIZATION_CACHE, PrincipalCollection.class, AuthorizationInfo.class);
if (cache == null) {
LOGGER.warn("Cache: [{}] is not configured properly!!", name);
} else {
shiroCache = new AuthorizationCache<>(cache);
}
break;
case SHIRO_SESSION_CACHE:
com.adeptj.modularweb.cache.api.Cache<K, V> sessionCache = (com.adeptj.modularweb.cache.api.Cache<K, V>) cacheProvider.getCache(SHIRO_SESSION_CACHE, Serializable.class, Session.class);
if (sessionCache == null) {
LOGGER.warn("Cache: [{}] is not configured properly!!", name);
} else {
shiroCache = new ShiroSessionCache<>(sessionCache);
}
break;
default:
LOGGER.warn("Unknown Cache: {}", name);
break;
}
return shiroCache;
}
Aggregations