Exemplo n.º 1
0
 @Bean(name = "shiroCacheManager")
 public CacheManager cacheManager() {
   logger.debug("create cache mamager.");
   EhCacheManager cacheManager = new EhCacheManager();
   cacheManager.setCacheManager(CacheConfig.ehCacheManagerFactoryBean().getObject());
   return cacheManager;
 }
  @Override
  public synchronized void start() throws Exception {
    checkState(!started, "Already started");

    log.info("Starting");

    // FIXME: Sort out overlap in responsibility between lifecycle here and RealmManagerImpl
    // FIXME: Wonder if a provider to handle configuration of RealmSecurityManager here is better?

    // prepare security manager
    if (realmSecurityManager instanceof Initializable) {
      ((Initializable) realmSecurityManager).init();
    }

    // prepare shiro cache
    EhCacheManager shiroCacheManager = new EhCacheManager();
    shiroCacheManager.setCacheManager(cacheManager);
    realmSecurityManager.setCacheManager(shiroCacheManager);

    // TODO: Sort out better means to invoke lifecycle here, realm-manager is only here for
    // start/stop now
    realmManager.start();

    started = true;
  }
Exemplo n.º 3
0
 @Bean
 public EhCacheManager ehCacheManager() {
   net.sf.ehcache.config.Configuration managerConfiguration =
       new net.sf.ehcache.config.Configuration()
           .name("shiroCache")
           .updateCheck(false)
           .defaultCache(
               new CacheConfiguration()
                   .maxEntriesLocalHeap(10000)
                   .eternal(true)
                   .timeToIdleSeconds(120)
                   .timeToLiveSeconds(120)
                   .overflowToDisk(false)
                   .diskPersistent(false)
                   .diskExpiryThreadIntervalSeconds(120));
   net.sf.ehcache.CacheManager manager = net.sf.ehcache.CacheManager.create(managerConfiguration);
   EhCacheManager cacheManager = new EhCacheManager();
   cacheManager.setCacheManager(manager);
   return cacheManager;
 }
Exemplo n.º 4
0
 @Bean(name = "shiroEhcacheManager")
 public EhCacheManager getEhCacheManager() {
   EhCacheManager em = new EhCacheManager();
   em.setCacheManagerConfigFile("classpath:cache/ehcache-shiro.xml");
   return em;
 }