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

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

Introduction

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

Prototype

@Override
    @Nullable
    public Ehcache getObject() 

Source Link

Usage

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

/**
 * Helper to create an in-memory cache./*from   w  ww  . j a  v 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:fr.mby.saml2.sp.impl.core.EhcacheSaml20Storage.java

/**
 * Initialize caches if needed./*from   ww w. j a  v a  2s  . 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();
}