Example usage for org.springframework.cache.ehcache EhCacheManagerFactoryBean setAcceptExisting

List of usage examples for org.springframework.cache.ehcache EhCacheManagerFactoryBean setAcceptExisting

Introduction

In this page you can find the example usage for org.springframework.cache.ehcache EhCacheManagerFactoryBean setAcceptExisting.

Prototype

public void setAcceptExisting(boolean acceptExisting) 

Source Link

Document

Set whether an existing EhCache CacheManager of the same name will be accepted for this EhCacheManagerFactoryBean setup.

Usage

From source file:ru.anr.base.dao.AbstractDaoConfig.java

/**
 * Definition of CacheManager. We use EhCache
 * //from w ww.  jav a 2 s  .  com
 * @return An instance of {@link CacheManager} interface
 */
@Bean(name = "cacheManager")
public CacheManager cacheManager() {

    EhCacheManagerFactoryBean factory = new EhCacheManagerFactoryBean();
    factory.setAcceptExisting(true);
    factory.setShared(false);
    factory.setConfigLocation(new ClassPathResource("ehcache.xml"));

    factory.afterPropertiesSet();

    EhCacheCacheManager mgr = new EhCacheCacheManager();
    mgr.setCacheManager(factory.getObject());
    mgr.setTransactionAware(true);
    mgr.afterPropertiesSet();

    return mgr;
}