Search in sources :

Example 6 with EhCacheManagerFactoryBean

use of org.springframework.cache.ehcache.EhCacheManagerFactoryBean in project vip by guangdada.

the class EhCacheConfig method ehcache.

/**
 * EhCache的配置
 */
@Bean
public EhCacheManagerFactoryBean ehcache() {
    EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
    return ehCacheManagerFactoryBean;
}
Also used : EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 7 with EhCacheManagerFactoryBean

use of org.springframework.cache.ehcache.EhCacheManagerFactoryBean in project cas by apereo.

the class EhcacheTicketRegistryConfiguration method ehcacheTicketCacheManager.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "ehcacheTicketCacheManager")
public CacheManager ehcacheTicketCacheManager(@Qualifier("ticketRMISynchronousCacheReplicator") final CacheReplicator ticketRMISynchronousCacheReplicator, @Qualifier("ticketCacheBootstrapCacheLoader") final BootstrapCacheLoader ticketCacheBootstrapCacheLoader, @Qualifier(TicketCatalog.BEAN_NAME) final TicketCatalog ticketCatalog, final CasConfigurationProperties casProperties) {
    AsciiArtUtils.printAsciiArtWarning(LOGGER, "CAS Integration with ehcache 2.x will be discontinued after CAS 6.2.x. Consider migrating to another type of registry.");
    val cache = casProperties.getTicket().getRegistry().getEhcache();
    val bean = new EhCacheManagerFactoryBean();
    cache.getSystemProps().forEach(System::setProperty);
    val configExists = ResourceUtils.doesResourceExist(cache.getConfigLocation());
    if (configExists) {
        bean.setConfigLocation(cache.getConfigLocation());
    } else {
        LOGGER.warn("Ehcache configuration file [{}] cannot be found", cache.getConfigLocation());
    }
    bean.setShared(cache.isShared());
    bean.setCacheManagerName(cache.getCacheManagerName());
    bean.afterPropertiesSet();
    val ehCacheManager = bean.getObject();
    val definitions = ticketCatalog.findAll();
    definitions.forEach(ticketDefn -> {
        val ehcache = buildCache(casProperties, ticketDefn, ticketRMISynchronousCacheReplicator, ticketCacheBootstrapCacheLoader);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Created Ehcache cache [{}] for [{}]", ehcache.getName(), ticketDefn);
            val config = ehcache.getCacheConfiguration();
            LOGGER.debug("[{}].maxEntriesLocalHeap=[{}]", ehcache.getName(), config.getMaxEntriesLocalHeap());
            LOGGER.debug("[{}].maxEntriesLocalDisk=[{}]", ehcache.getName(), config.getMaxEntriesLocalDisk());
            LOGGER.debug("[{}].maxEntriesInCache=[{}]", ehcache.getName(), config.getMaxEntriesInCache());
            LOGGER.debug("[{}].persistenceConfiguration=[{}]", ehcache.getName(), config.getPersistenceConfiguration().getStrategy());
            LOGGER.debug("[{}].synchronousWrites=[{}]", ehcache.getName(), config.getPersistenceConfiguration().getSynchronousWrites());
            LOGGER.debug("[{}].timeToLive=[{}]", ehcache.getName(), config.getTimeToLiveSeconds());
            LOGGER.debug("[{}].timeToIdle=[{}]", ehcache.getName(), config.getTimeToIdleSeconds());
            LOGGER.debug("[{}].cacheManager=[{}]", ehcache.getName(), ehcache.getCacheManager().getName());
        }
        ehCacheManager.addDecoratedCacheIfAbsent(ehcache);
    });
    LOGGER.debug("The following caches are available: [{}]", Arrays.toString(ehCacheManager.getCacheNames()));
    return ehCacheManager;
}
Also used : lombok.val(lombok.val) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) EhCacheFactoryBean(org.springframework.cache.ehcache.EhCacheFactoryBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with EhCacheManagerFactoryBean

use of org.springframework.cache.ehcache.EhCacheManagerFactoryBean in project wechat by dllwh.

the class EhCacheConfig method ehcache.

/**
 * @方法描述 : EhCache的配置
 * @return
 */
public EhCacheManagerFactoryBean ehcache() {
    EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource(ehcache_path));
    return ehCacheManagerFactoryBean;
}
Also used : EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 9 with EhCacheManagerFactoryBean

use of org.springframework.cache.ehcache.EhCacheManagerFactoryBean in project cas by apereo.

the class EhcacheTicketRegistryConfiguration method ehcacheTicketCacheManager.

@Bean
public EhCacheManagerFactoryBean ehcacheTicketCacheManager() {
    final EhcacheProperties cache = casProperties.getTicket().getRegistry().getEhcache();
    final EhCacheManagerFactoryBean bean = new EhCacheManagerFactoryBean();
    final boolean configExists = ResourceUtils.doesResourceExist(cache.getConfigLocation());
    if (configExists) {
        bean.setConfigLocation(cache.getConfigLocation());
    } else {
        LOGGER.warn("Ehcache configuration file [{}] cannot be found", cache.getConfigLocation());
    }
    bean.setShared(cache.isShared());
    bean.setCacheManagerName(cache.getCacheManagerName());
    return bean;
}
Also used : EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) EhcacheProperties(org.apereo.cas.configuration.model.support.ehcache.EhcacheProperties) EhCacheFactoryBean(org.springframework.cache.ehcache.EhCacheFactoryBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 10 with EhCacheManagerFactoryBean

use of org.springframework.cache.ehcache.EhCacheManagerFactoryBean in project tesla by linking12.

the class CacheConfiguration method ehCacheManagerFactoryBean.

@Bean
public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {
    EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    cacheManagerFactoryBean.setConfigLocation(new ClassPathResource("config/ehcache.xml"));
    cacheManagerFactoryBean.setShared(true);
    return cacheManagerFactoryBean;
}
Also used : EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

EhCacheManagerFactoryBean (org.springframework.cache.ehcache.EhCacheManagerFactoryBean)12 Bean (org.springframework.context.annotation.Bean)11 ClassPathResource (org.springframework.core.io.ClassPathResource)7 EhCacheFactoryBean (org.springframework.cache.ehcache.EhCacheFactoryBean)3 EhcacheProperties (org.apereo.cas.configuration.model.support.ehcache.EhcacheProperties)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 lombok.val (lombok.val)1 EhCacheManager (org.apache.shiro.cache.ehcache.EhCacheManager)1 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)1 MethodInvokingFactoryBean (org.springframework.beans.factory.config.MethodInvokingFactoryBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Lazy (org.springframework.context.annotation.Lazy)1