Example usage for org.springframework.cache.ehcache EhCacheFactoryBean setCacheName

List of usage examples for org.springframework.cache.ehcache EhCacheFactoryBean setCacheName

Introduction

In this page you can find the example usage for org.springframework.cache.ehcache EhCacheFactoryBean setCacheName.

Prototype

public void setCacheName(String cacheName) 

Source Link

Document

Set a name for which to retrieve or create a cache instance.

Usage

From source file:org.openvpms.archetype.rules.workflow.ScheduleTestHelper.java

/**
 * Helper to create an in-memory cache./*from   www.  jav  a  2  s.  c  o m*/
 *
 * @param maxElementsInMemory specifies the maximum number of cached objects in memory
 * @return a new cache
 */
public static Ehcache createCache(int maxElementsInMemory) {
    EhCacheFactoryBean bean = new EhCacheFactoryBean();
    bean.setCacheName("foo" + System.nanoTime());
    bean.setMaxElementsInMemory(maxElementsInMemory);
    bean.setEternal(true);
    bean.setOverflowToDisk(false);
    try {
        bean.afterPropertiesSet();
    } catch (IOException exception) {
        throw new CacheException(exception);
    }
    return bean.getObject();
}

From source file:org.createnet.raptor.auth.service.AclConfiguration.java

@Bean
public EhCacheFactoryBean aclEhCacheFactoryBean() {
    EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
    ehCacheFactoryBean.setCacheManager(aclCacheManager().getObject());
    ehCacheFactoryBean.setCacheName("aclCache");
    return ehCacheFactoryBean;
}

From source file:cz.lbenda.coursing.client.ClientAppConfig.java

public @Bean EhCacheFactoryBean userCacheBackend() {
    EhCacheFactoryBean result = new EhCacheFactoryBean();
    result.setCacheManager(cacheManager());
    result.setCacheName("userCache");
    return result;
}

From source file:fr.mby.saml2.sp.impl.core.EhcacheSaml20Storage.java

/**
 * Initialize caches if needed./*  w  ww  .j av  a  2  s  .c  o m*/
 * 
 * @throws IOException
 * @throws CacheException
 */
protected void initCaches() throws CacheException, IOException {
    if (this.samlAuthenticationsCache == null) {
        final EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
        cacheFactory.setCacheName(EhcacheSaml20Storage.SAML2_AUTH_CREDS_CACHE_NAME);
        cacheFactory.afterPropertiesSet();
        this.samlAuthenticationsCache = cacheFactory.getObject();
    }
    this.samlAuthenticationsCache.bootstrap();

    if (this.samlRequestWaitingForResponseCache == null) {
        final EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
        cacheFactory.setCacheName(EhcacheSaml20Storage.SAML2_RWFR_CACHE_NAME);
        cacheFactory.afterPropertiesSet();
        this.samlRequestWaitingForResponseCache = cacheFactory.getObject();
    }
    this.samlRequestWaitingForResponseCache.bootstrap();

    if (this.saml2BaseIdCache == null) {
        final EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
        cacheFactory.setCacheName(EhcacheSaml20Storage.SAML2_BASE_ID_CACHE_NAME);
        cacheFactory.afterPropertiesSet();
        this.saml2BaseIdCache = cacheFactory.getObject();
    }
    this.saml2BaseIdCache.bootstrap();

    if (this.saml2NameIdCache == null) {
        final EhCacheFactoryBean cacheFactory = new EhCacheFactoryBean();
        cacheFactory.setCacheName(EhcacheSaml20Storage.SAML2_NAME_ID_CACHE_NAME);
        cacheFactory.afterPropertiesSet();
        this.saml2NameIdCache = cacheFactory.getObject();
    }
    this.saml2NameIdCache.bootstrap();
}