org.apache.shiro.cache.ehcache.EhCacheManager Java Examples
The following examples show how to use
org.apache.shiro.cache.ehcache.EhCacheManager.
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: ShiroConfig.java From ruoyiplus with MIT License | 6 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public EhCacheManager getEhCacheManager() { net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi"); EhCacheManager em = new EhCacheManager(); if (StringUtils.isNull(cacheManager)) { em.setCacheManagerConfigFile("classpath:ehcache/ehcache-shiro.xml"); return em; } else { em.setCacheManager(cacheManager); return em; } }
Example #2
Source File: ShiroConfig.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
private void biuldCacheManager() { this.cacheManager = this.customizer.getCacheManager(); if(Objects.isNull(this.cacheManager)) { if(Objects.isNull(springCacheManager)) { this.cacheManager = new MapCacheManager(); }else { if (springCacheManager instanceof EhCacheCacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(((EhCacheCacheManager) springCacheManager).getCacheManager()); this.cacheManager = ehCacheManager; } if (springCacheManager instanceof org.springframework.data.redis.cache.RedisCacheManager) { RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisTemplate(RedisUtils.imitateRedisTemplate()); this.cacheManager = redisCacheManager; } } } this.cacheDelegator = new CacheDelegator(this.cacheManager); }
Example #3
Source File: CacheManagerBuilder.java From jsets-shiro-spring-boot-starter with Apache License 2.0 | 6 votes |
private CacheManager decision(org.springframework.cache.CacheManager springCacheManager) { if (springCacheManager instanceof EhCacheCacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(((EhCacheCacheManager) springCacheManager).getCacheManager()); return ehCacheManager; } if (springCacheManager instanceof org.springframework.data.redis.cache.RedisCacheManager) { GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer(); RedisTemplate rt = new RedisTemplate<Object, Object>(); rt.setConnectionFactory(SpringContextUtils.getBean(RedisConnectionFactory.class)); rt.setKeySerializer(jsonSerializer); rt.setHashKeySerializer(jsonSerializer); rt.setBeanClassLoader(this.getClass().getClassLoader()); rt.afterPropertiesSet(); RedisCacheManager redisCacheManager = new RedisCacheManager(); redisCacheManager.setRedisTemplate(rt); return redisCacheManager; } return new SpringCacheManager(springCacheManager); }
Example #4
Source File: ShiroConfig.java From LuckyFrameWeb with GNU Affero General Public License v3.0 | 6 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public EhCacheManager getEhCacheManager() { net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("luckyframe"); EhCacheManager em = new EhCacheManager(); if (StringUtils.isNull(cacheManager)) { em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream())); return em; } else { em.setCacheManager(cacheManager); return em; } }
Example #5
Source File: ShiroConfig.java From supplierShop with MIT License | 6 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public EhCacheManager getEhCacheManager() { net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi"); EhCacheManager em = new EhCacheManager(); if (StringUtils.isNull(cacheManager)) { em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream())); return em; } else { em.setCacheManager(cacheManager); return em; } }
Example #6
Source File: ShiroConfig.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public EhCacheManager getEhCacheManager() { net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("ruoyi"); EhCacheManager em = new EhCacheManager(); if (ObjectUtil.isNull(cacheManager)) { em.setCacheManager(new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream())); return em; } else { em.setCacheManager(cacheManager); return em; } }
Example #7
Source File: SecurityRealmConfiguration.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * Initialize the configuration with the default values */ @PostConstruct protected void initialize() { this.realms = new HashSet<>(); this.cacheManager = new EhCacheManager(); this.mechanism = new DatabaseAuthenticationMechanism(this.userAccountService); this.configureJdbcRealm(); this.configureLdapRealm(); }
Example #8
Source File: SecurityRealmConfiguration.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * Initialize the configuration with the default values */ @PostConstruct protected void initialize() { this.realms = new HashSet<>(); this.cacheManager = new EhCacheManager(); this.mechanism = new DatabaseAuthenticationMechanism(this.userAccountService); this.configureJdbcRealm(); this.configureLdapRealm(); }
Example #9
Source File: ShiroAutoConfiguration.java From utils with Apache License 2.0 | 5 votes |
@Bean(name = "cacheManager") @ConditionalOnClass(name = {"org.apache.shiro.cache.ehcache.EhCacheManager"}) @ConditionalOnMissingBean(name = "cacheManager") public CacheManager ehcacheManager() { EhCacheManager ehCacheManager = new EhCacheManager(); ShiroProperties.Ehcache ehcache = shiroProperties.getEhcache(); if (ehcache.getConfigFile() != null) { ehCacheManager.setCacheManagerConfigFile(ehcache.getConfigFile()); } return ehCacheManager; }
Example #10
Source File: ShiroAutoConfiguration.java From spring-boot-shiro with Apache License 2.0 | 5 votes |
@Bean(name = "cacheManager") @ConditionalOnClass(name = {"org.apache.shiro.cache.ehcache.EhCacheManager"}) @ConditionalOnMissingBean(name = "cacheManager") public CacheManager ehcacheManager() { EhCacheManager ehCacheManager = new EhCacheManager(); ShiroProperties.Ehcache ehcache = properties.getEhcache(); if (ehcache.getCacheManagerConfigFile() != null) { ehCacheManager.setCacheManagerConfigFile(ehcache.getCacheManagerConfigFile()); } return ehCacheManager; }
Example #11
Source File: ShiroConfiguration.java From wangmarket with Apache License 2.0 | 5 votes |
/** * EhCacheManager , 缓存管理 * 用户登陆成功后 , 把用户信息和权限信息缓存起来 , 然后每次用户请求时 , 放入用户的session中 , 如果不设置这个bean , 每个请求都会查询一次数据库 . */ @Bean @DependsOn("lifecycleBeanPostProcessor") public EhCacheManager ehCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:shiro-ehcache.xml");//配置文件路径 return em; }
Example #12
Source File: SecurityRealmConfiguration.java From library with Apache License 2.0 | 5 votes |
/** * Initialize the configuration with the default values */ @PostConstruct protected void initialize() { this.realms = new HashSet<>(); this.cacheManager = new EhCacheManager(); this.mechanism = new DatabaseAuthenticationMechanism(this.userAccountService); this.configureJdbcRealm(); this.configureLdapRealm(); }
Example #13
Source File: ShiroConfig.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * shiro缓存管理器; * 需要注入对应的其它的实体类中: * 安全管理器:securityManager * * @return */ @Bean(name="ehCacheManager") @DependsOn("lifecycleBeanPostProcessor") public EhCacheManager ehCacheManager() { log.info("ShiroConfiguration.getEhCacheManager()"); EhCacheManager cacheManager = new EhCacheManager(); cacheManager.setCacheManagerConfigFile("classpath:ehcache-shiro.xml"); return cacheManager; }
Example #14
Source File: ShiroConfig.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * shiro缓存管理器; * 需要注入对应的其它的实体类中: * 安全管理器:securityManager * * @return */ @Bean(name="ehCacheManager") @DependsOn("lifecycleBeanPostProcessor") public EhCacheManager ehCacheManager() { log.info("ShiroConfiguration.getEhCacheManager()"); EhCacheManager cacheManager = new EhCacheManager(); cacheManager.setCacheManagerConfigFile("classpath:ehcache-shiro.xml"); return cacheManager; }
Example #15
Source File: ShiroConfig.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * @DependOn :在初始化 defaultWebSecurityManager 实例前 强制先初始化 adminRealm ,ehCacheManager。。。。。 * @param realm * @param ehCacheManager * @param cookieRememberMeManager * @return */ @Bean(name = "securityManager") @DependsOn({"adminRealm","ehCacheManager","cookieRememberMeManager"}) public DefaultWebSecurityManager getDefaultWebSecurityManager(AdminRealm realm, EhCacheManager ehCacheManager,CookieRememberMeManager cookieRememberMeManager) { DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager(); //设置realm. defaultWebSecurityManager.setRealm(realm); defaultWebSecurityManager.setCacheManager(ehCacheManager); defaultWebSecurityManager.setRememberMeManager(cookieRememberMeManager); return defaultWebSecurityManager; }
Example #16
Source File: ShiroConfig.java From MeetingFilm with Apache License 2.0 | 5 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public CacheManager getCacheShiroManager(EhCacheManagerFactoryBean ehcache) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(ehcache.getObject()); return ehCacheManager; }
Example #17
Source File: AuthConfig.java From v-mock with MIT License | 5 votes |
/** * 缓存管理器 */ @Bean public EhCacheManager getEhCacheManager() { net.sf.ehcache.CacheManager cacheManager = net.sf.ehcache.CacheManager.getCacheManager("vmock"); EhCacheManager em = new EhCacheManager(); em.setCacheManager(cacheManager == null ? new net.sf.ehcache.CacheManager(getCacheManagerConfigFileInputStream()) : cacheManager); return em; }
Example #18
Source File: ShiroConfig.java From WebStack-Guns with MIT License | 5 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public CacheManager getCacheShiroManager(EhCacheManagerFactoryBean ehcache) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(ehcache.getObject()); return ehCacheManager; }
Example #19
Source File: ShiroConfig.java From kvf-admin with MIT License | 5 votes |
/** * shiro缓存管理器。需要添加到securityManager中 * @return cacheManager */ @Bean public EhCacheManager ehCacheManager(){ EhCacheManager cacheManager = new EhCacheManager(); cacheManager.setCacheManagerConfigFile("classpath:ehcache.xml"); return cacheManager; }
Example #20
Source File: ShiroConfig.java From springboot-learn with MIT License | 5 votes |
/** * 缓存管理器 使用Ehcache实现 */ @Bean public EhCacheManager getEhCacheManager() { CacheManager cacheManager = CacheManager.getCacheManager("shiro"); EhCacheManager em = new EhCacheManager(); if (StringUtils.isEmpty(cacheManager)) { em.setCacheManagerConfigFile("classpath:ehcache/ehcache-shiro.xml"); return em; } else { em.setCacheManager(cacheManager); return em; } }
Example #21
Source File: ShiroBaseConfigure.java From ueboot with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 当用户的环境没有配置redisTemplate时则使用ehcache做缓存 * * @param realm realm * @return DefaultWebSecurityManager */ @Bean @Conditional(RedisDisabledCondition.class) public DefaultWebSecurityManager webSecurityManager(Realm realm) { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); securityManager.setRealm(realm); //使用ehcache当缓存 EhCacheManager cacheManager = new EhCacheManager(); securityManager.setCacheManager(cacheManager); return securityManager; }
Example #22
Source File: ShiroConfig.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * @DependOn :在初始化 defaultWebSecurityManager 实例前 强制先初始化 adminRealm ,ehCacheManager。。。。。 * @param realm * @param ehCacheManager * @param cookieRememberMeManager * @return */ @Bean(name = "securityManager") @DependsOn({"adminRealm","ehCacheManager","cookieRememberMeManager"}) public DefaultWebSecurityManager getDefaultWebSecurityManager(AdminRealm realm, EhCacheManager ehCacheManager,CookieRememberMeManager cookieRememberMeManager) { DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager(); //设置realm. defaultWebSecurityManager.setRealm(realm); defaultWebSecurityManager.setCacheManager(ehCacheManager); defaultWebSecurityManager.setRememberMeManager(cookieRememberMeManager); return defaultWebSecurityManager; }
Example #23
Source File: ShiroConfig.java From yyblog with MIT License | 4 votes |
@Bean public EhCacheManager ehCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:config/ehcache.xml"); return em; }
Example #24
Source File: ShiroConfig.java From SpringAll with MIT License | 4 votes |
@Bean public EhCacheManager getEhCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:config/shiro-ehcache.xml"); return em; }
Example #25
Source File: ShiroConfig.java From SpringAll with MIT License | 4 votes |
@Bean public EhCacheManager getEhCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:config/shiro-ehcache.xml"); return em; }
Example #26
Source File: ShiroConfig.java From SpringAll with MIT License | 4 votes |
@Bean public EhCacheManager getEhCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:config/shiro-ehcache.xml"); return em; }
Example #27
Source File: ShiroConfig.java From Goku.Framework.CoreUI with MIT License | 4 votes |
/** * EhCacheManager,缓存管理,用户登陆成功后,把用户信息和权限信息缓存起来, * 然后每次用户请求时,放入用户的session中,如果不设置这个bean,每个请求都会查询一次数据库。 */ @Bean(name = "ehCacheManager") @DependsOn("lifecycleBeanPostProcessor") public EhCacheManager ehCacheManager() { return new EhCacheManager(); }
Example #28
Source File: ShiroConfig.java From server-boilerplate with MIT License | 4 votes |
@Bean public CacheManager getCacheManager() { return new EhCacheManager(); }
Example #29
Source File: ShiroConfiguration.java From spring-boot-quickstart with Apache License 2.0 | 4 votes |
@Bean(name = "shiroEhcacheManager") public EhCacheManager getEhCacheManager() { EhCacheManager em = new EhCacheManager(); em.setCacheManagerConfigFile("classpath:ehcache/ehcache-shiro.xml"); return em; }
Example #30
Source File: ShiroConfiguration.java From mblog with GNU General Public License v3.0 | 4 votes |
@Bean public CacheManager shiroCacheManager(net.sf.ehcache.CacheManager cacheManager) { EhCacheManager ehCacheManager = new EhCacheManager(); ehCacheManager.setCacheManager(cacheManager); return ehCacheManager; }