Search in sources :

Example 6 with EhCacheManager

use of org.apache.shiro.cache.ehcache.EhCacheManager in project Spring-Family by Sierou-Java.

the class ShiroConfiguration method ehCacheManager.

// /////////////////////////////////////身份认证 END/////////////////////////////////////
// /////////////////////////////////////缓存 START/////////////////////////////////////
/**
 * shiro缓存管理器;
 * 需要注入对应的其它的实体类中:
 * 1、安全管理器:securityManager
 * 可见securityManager是整个shiro的核心;
 *
 * 查看控制台的打印信息:
 * 权限配置-->MyShiroRealm.doGetAuthorizationInfo()
 * 这个信息就只打印一次了,说明我们的缓存生效了。
 * @return
 */
@Bean
public EhCacheManager ehCacheManager() {
    System.out.println("ShiroConfiguration.getEhCacheManager()");
    EhCacheManager cacheManager = new EhCacheManager();
    cacheManager.setCacheManagerConfigFile("classpath:config/ehcache-shiro.xml");
    return cacheManager;
}
Also used : EhCacheManager(org.apache.shiro.cache.ehcache.EhCacheManager) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

EhCacheManager (org.apache.shiro.cache.ehcache.EhCacheManager)6 Bean (org.springframework.context.annotation.Bean)4 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)3 DefaultSecurityManager (org.apache.shiro.mgt.DefaultSecurityManager)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 MethodInvokingFactoryBean (org.springframework.beans.factory.config.MethodInvokingFactoryBean)1 EhCacheManagerFactoryBean (org.springframework.cache.ehcache.EhCacheManagerFactoryBean)1