Java Code Examples for net.sf.ehcache.CacheManager#getInstance()

The following examples show how to use net.sf.ehcache.CacheManager#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheKillingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testKillCacheAndSurvive() {
  EhCacheDataCache dataCache = new EhCacheDataCache();
  DataCacheKey key = new DataCacheKey();
  key.addAttribute( "Test", "test" );
  dataCache.put( key, new DefaultTableModel() );

  final CacheManager cacheManager = CacheManager.getInstance();
  // Note: EHCacheProvider will dynamically create these
  // caches if they don't exist.
  cacheManager.clearAll();
  cacheManager.removalAll();

  assertFalse( cacheManager.cacheExists( "libloader-bundles" ) );
  assertFalse( cacheManager.cacheExists( "libloader-data" ) );
  assertFalse( cacheManager.cacheExists( "libloader-factory" ) );
  assertFalse( cacheManager.cacheExists( "report-dataset-cache" ) );

  cacheManager.shutdown();

  assertNull( dataCache.get( key ) );
  dataCache.put( key, new DefaultTableModel() );
  assertNotNull( dataCache.get( key ) );

}
 
Example 2
Source File: EhCacheProvider.java    From J2Cache with Apache License 2.0 6 votes vote down vote up
/**
 * init ehcache config
 *
 * @param props current configuration settings.
 */
public void start(Properties props) {
    if (manager != null) {
        log.warn("Attempt to restart an already started EhCacheProvider.");
        return;
    }

    // 如果指定了名称,那么尝试获取已有实例
    String ehcacheName = (String)props.get(KEY_EHCACHE_NAME);
    if (ehcacheName != null && ehcacheName.trim().length() > 0)
        manager = CacheManager.getCacheManager(ehcacheName);
    if (manager == null) {
        // 指定了配置文件路径? 加载之
        if (props.containsKey(KEY_EHCACHE_CONFIG_XML)) {
            String propertiesFile = props.getProperty(KEY_EHCACHE_CONFIG_XML);
            URL url = getClass().getResource(propertiesFile);
            url = (url == null) ? getClass().getClassLoader().getResource(propertiesFile) : url;
            manager = CacheManager.newInstance(url);
        } else {
            // 加载默认实例
            manager = CacheManager.getInstance();
        }
    }
    caches = new ConcurrentHashMap<>();
}
 
Example 3
Source File: CacheWrapperImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache
 */
protected CacheWrapperImpl(String cacheName, CacheConfig config) {
    this.cacheName = cacheName;
    this.config = config;
    this.cachemanager = CacheManager.getInstance();
    // now we need a cache which has appropriate (by configuration) values for cache configs such as ttl, tti, max elements and so on.
    // next line needed since cache can also be initialized through ehcache.xml
    if (cachemanager.cacheExists(cacheName)) {
        this.cache = cachemanager.getCache(cacheName);
        log.warn("using cache parameters from ehcache.xml for cache named '" + cacheName + "'");
    } else {
        this.cache = config.createCache(cacheName);
        try {
            cachemanager.addCache(this.cache);
        } catch (CacheException e) {
            throw new OLATRuntimeException("Problem when initializing the caches", e);
        }
    }
}
 
Example 4
Source File: CacheKillingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void testKillCacheWithoutShutdownAndSurvive() {
  EhCacheDataCache dataCache = new EhCacheDataCache();
  DataCacheKey key = new DataCacheKey();
  key.addAttribute( "Test", "test" );
  dataCache.put( key, new DefaultTableModel() );

  final CacheManager cacheManager = CacheManager.getInstance();
  // Note: EHCacheProvider will dynamically create these
  // caches if they don't exist.
  cacheManager.clearAll();
  cacheManager.removalAll();

  assertFalse( cacheManager.cacheExists( "libloader-bundles" ) );
  assertFalse( cacheManager.cacheExists( "libloader-data" ) );
  assertFalse( cacheManager.cacheExists( "libloader-factory" ) );
  assertFalse( cacheManager.cacheExists( "report-dataset-cache" ) );

  assertNull( dataCache.get( key ) );
  dataCache.put( key, new DefaultTableModel() );
  assertNotNull( dataCache.get( key ) );

}
 
Example 5
Source File: Context.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Takes care of shutting down all cache managers
 */
private static void closeCaches() {
	CacheManager cm1 = CacheManager.getInstance();
	cm1.shutdown();

	for (Object cm : Context.get().getBeansOfType(CacheManager.class)) {
		((CacheManager) cm).shutdown();
	}
}
 
Example 6
Source File: EHCacheUtil.java    From sanshanblog with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化缓存管理容器
 */
public static CacheManager initCacheManager() {
    try {
        if (cacheManager == null)
            cacheManager = CacheManager.getInstance();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return cacheManager;
}
 
Example 7
Source File: EhCacheBackedMapImpl.java    From openregistry with Apache License 2.0 5 votes vote down vote up
public EhCacheBackedMapImpl() {
    final CacheManager cacheManager = CacheManager.getInstance();
    final Cache tempCache = cacheManager.getCache(DEFAULT_CACHE_NAME);

    if (tempCache == null) {
        this.cache = new Cache(DEFAULT_CACHE_NAME, 20000, false, false, 60000, 60000);
        cacheManager.addCache(this.cache);
    } else {
        this.cache = tempCache;
    }
}
 
Example 8
Source File: EhCacheDataCache.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initializeCacheManager() {
  if ( ClassicEngineBoot.getInstance().getExtendedConfig().getBoolProperty(
      "org.pentaho.reporting.engine.classic.core.cache.EhCacheDataCache.UseGlobalCacheManager" ) ) {
    manager = CacheManager.getInstance();
  } else if ( manager == null ) {
    manager = createCacheManager();
  }
}
 
Example 9
Source File: TestHtmlReport.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/** Test.
 * @throws IOException e */
@Test
public void testCache() throws IOException {
	final String cacheName = "test 1";
	final CacheManager cacheManager = CacheManager.getInstance();
	cacheManager.addCache(cacheName);
	// test empty cache name in the cache keys link:
	// cacheManager.addCache("") does nothing, but cacheManager.addCache(new Cache("", ...)) works
	cacheManager.addCache(new Cache("", 1000, true, false, 10000, 10000, false, 10000));
	final String cacheName2 = "test 2";
	try {
		final Cache cache = cacheManager.getCache(cacheName);
		cache.put(new Element(1, Math.random()));
		cache.get(1);
		cache.get(0);
		cacheManager.addCache(cacheName2);
		final Cache cache2 = cacheManager.getCache(cacheName2);
		cache2.getCacheConfiguration().setOverflowToDisk(false);
		cache2.getCacheConfiguration().setEternal(true);
		cache2.getCacheConfiguration().setMaxElementsInMemory(0);

		// JavaInformations doit être réinstancié pour récupérer les caches
		final List<JavaInformations> javaInformationsList2 = Collections
				.singletonList(new JavaInformations(null, true));
		final HtmlReport htmlReport = new HtmlReport(collector, null, javaInformationsList2,
				Period.TOUT, writer);
		htmlReport.toHtml(null, null);
		assertNotEmptyAndClear(writer);
		setProperty(Parameter.SYSTEM_ACTIONS_ENABLED, "false");
		htmlReport.toHtml(null, null);
		assertNotEmptyAndClear(writer);
	} finally {
		setProperty(Parameter.SYSTEM_ACTIONS_ENABLED, null);
		cacheManager.removeCache(cacheName);
		cacheManager.removeCache(cacheName2);
	}
}
 
Example 10
Source File: Output.java    From red5-io with Apache License 2.0 5 votes vote down vote up
private static CacheManager constructDefault() {
    CacheManager manager = CacheManager.getInstance();
    manager.addCacheIfAbsent("org.red5.io.amf.Output.stringCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.getterCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.fieldCache");
    manager.addCacheIfAbsent("org.red5.io.amf.Output.serializeCache");
    return manager;
}
 
Example 11
Source File: AllCachesController.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * @param ureq
 * @param wControl
 */
public AllCachesController(final UserRequest ureq, final WindowControl wControl) {
    super(ureq, wControl);
    // create page
    myContent = createVelocityContainer("index");

    final TableGuiConfiguration tableConfig = new TableGuiConfiguration();

    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.name", 0, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.disk", 1, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.hitcnt", 2, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcexp", 3, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcnotfound", 4, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.quickcount", 5, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.tti", 6, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.ttl", 7, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.maxElements", 8, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor("empty", "cache.empty", translate("action.choose")));
    listenTo(tableCtr);
    myContent.contextPut("title", translate("caches.title"));

    // eh cache
    try {
        cm = CacheManager.getInstance();
    } catch (final CacheException e) {
        throw new AssertException("could not get cache", e);
    }
    cnames = cm.getCacheNames();
    tdm = new AllCachesTableDataModel(cnames);
    tableCtr.setTableDataModel(tdm);
    myContent.put("cachetable", tableCtr.getInitialComponent());

    // returned panel is not needed here, because this controller only shows content with the index.html velocity page
    putInitialPanel(myContent);

}
 
Example 12
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static synchronized CacheManager getCacheManager() throws CacheException {
  if ( cacheManager == null ) {
    cacheManager = CacheManager.getInstance();
  }
  return cacheManager;
}
 
Example 13
Source File: EhCacheFactoryBean.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	// If no cache name given, use bean name as cache name.
	String cacheName = getName();
	if (cacheName == null) {
		cacheName = this.beanName;
		if (cacheName != null) {
			setName(cacheName);
		}
	}

	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	synchronized (this.cacheManager) {
		// Fetch cache region: If none with the given name exists, create one on the fly.
		Ehcache rawCache;
		boolean cacheExists = this.cacheManager.cacheExists(cacheName);

		if (cacheExists) {
			if (logger.isDebugEnabled()) {
				logger.debug("Using existing EhCache cache region '" + cacheName + "'");
			}
			rawCache = this.cacheManager.getEhcache(cacheName);
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Creating new EhCache cache region '" + cacheName + "'");
			}
			rawCache = createCache();
			rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader);
		}

		if (this.cacheEventListeners != null) {
			for (CacheEventListener listener : this.cacheEventListeners) {
				rawCache.getCacheEventNotificationService().registerListener(listener);
			}
		}

		// Needs to happen after listener registration but before setStatisticsEnabled
		if (!cacheExists) {
			this.cacheManager.addCache(rawCache);
		}

		if (this.disabled) {
			rawCache.setDisabled(true);
		}

		Ehcache decoratedCache = decorateCache(rawCache);
		if (decoratedCache != rawCache) {
			this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
		}
		this.cache = decoratedCache;
	}
}
 
Example 14
Source File: EhCacheFactoryBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void afterPropertiesSet() throws CacheException, IOException {
	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (log.isDebugEnabled()) {
			log.debug("Using default EHCache CacheManager for cache region '" + this.cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	// If no cache name given, use bean name as cache name.
	if (this.cacheName == null) {
		this.cacheName = this.beanName;
	}

	// Fetch cache region: If none with the given name exists,
	// create one on the fly.
	Ehcache rawCache;
	if (this.cacheManager.cacheExists(this.cacheName)) {
		if (log.isDebugEnabled()) {
			log.debug("Using existing EHCache cache region '" + this.cacheName + "'");
		}
		rawCache = this.cacheManager.getEhcache(this.cacheName);
	}
	else {
		if (log.isDebugEnabled()) {
			log.debug("Creating new EHCache cache region '" + this.cacheName + "'");
		}
		rawCache = createCache();
           // Not look for any custom configuration.
           // Check for old configuration properties.
           if(serverConfigurationService.getString(this.cacheName) == null) {
               log.warn("Old cache configuration "+ this.cacheName+ " must be changed to memory."+ this.cacheName);
           }
           String config = serverConfigurationService.getString("memory."+ this.cacheName);
           if (config != null && config.length() > 0) {
               log.debug("Found configuration for cache: "+ this.cacheName+ " of: "+ config);
               new CacheInitializer().configure(config).initialize(
                       rawCache.getCacheConfiguration());
           }

		this.cacheManager.addCache(rawCache);
	}
	boolean override = false;
	if (serverConfigurationService != null) {
		override = serverConfigurationService.getBoolean(
				"memory.cache.statistics.force.disabled", false);
	}
	if (this.statisticsEnabled && !override) {
		rawCache.setStatisticsEnabled(true);
	}
	if (this.sampledStatisticsEnabled) {
		rawCache.setSampledStatisticsEnabled(true);
	}

	// Decorate cache if necessary.
	Ehcache decoratedCache = decorateCache(rawCache);
	if (decoratedCache != rawCache) {
		this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
	}
	this.cache = decoratedCache;
}
 
Example 15
Source File: EhCacheImpl.java    From red5-io with Apache License 2.0 4 votes vote down vote up
public void init() {
    log.info("Loading ehcache");
    // log.debug("Appcontext: " + applicationContext.toString());
    try {
        // instance the manager
        cm = CacheManager.getInstance();
        // Use the Configuration to create our caches
        Configuration configuration = new Configuration();
        //set initial default cache name
        @SuppressWarnings("unused")
        String defaultCacheName = Cache.DEFAULT_CACHE_NAME;
        //add the configs to a configuration
        for (CacheConfiguration conf : configs) {
            //set disk expiry
            conf.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
            //set eviction policy
            conf.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy);
            if (null == cache) {
                //get first cache name and use as default
                defaultCacheName = conf.getName();
                configuration.addDefaultCache(conf);
            } else {
                configuration.addCache(conf);
            }
        }
        //instance the helper
        ConfigurationHelper helper = new ConfigurationHelper(cm, configuration);
        //create the default cache
        cache = helper.createDefaultCache();
        //init the default
        cache.initialise();
        cache.bootstrap();
        //create the un-init'd caches
        @SuppressWarnings("unchecked")
        Set<Cache> caches = helper.createCaches();
        if (log.isDebugEnabled()) {
            log.debug("Number of caches: " + caches.size() + " Default cache: " + (cache != null ? 1 : 0));
        }
        for (Cache nonDefaultCache : caches) {
            nonDefaultCache.initialise();
            nonDefaultCache.bootstrap();
        }
    } catch (Exception e) {
        log.warn("Error on cache init", e);
    }
    if (log.isDebugEnabled()) {
        log.debug("Cache is null? {}", (null == cache));
    }
}
 
Example 16
Source File: AllCachesController.java    From olat with Apache License 2.0 4 votes vote down vote up
protected AllCachesTableDataModel(final String[] cnames) {
    this.cnames = cnames;
    this.cacheManager = CacheManager.getInstance();
}
 
Example 17
Source File: EhCacheFactoryBean.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void afterPropertiesSet() throws CacheException, IOException {
	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (log.isDebugEnabled()) {
			log.debug("Using default EHCache CacheManager for cache region '" + this.cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	// If no cache name given, use bean name as cache name.
	if (this.cacheName == null) {
		this.cacheName = this.beanName;
	}

	// Fetch cache region: If none with the given name exists,
	// create one on the fly.
	Ehcache rawCache;
	if (this.cacheManager.cacheExists(this.cacheName)) {
		if (log.isDebugEnabled()) {
			log.debug("Using existing EHCache cache region '" + this.cacheName + "'");
		}
		rawCache = this.cacheManager.getEhcache(this.cacheName);
	}
	else {
		if (log.isDebugEnabled()) {
			log.debug("Creating new EHCache cache region '" + this.cacheName + "'");
		}
		rawCache = createCache();
           // Not look for any custom configuration.
           // Check for old configuration properties.
           if(serverConfigurationService.getString(this.cacheName) == null) {
               log.warn("Old cache configuration "+ this.cacheName+ " must be changed to memory."+ this.cacheName);
           }
           String config = serverConfigurationService.getString("memory."+ this.cacheName);
           if (config != null && config.length() > 0) {
               log.debug("Found configuration for cache: "+ this.cacheName+ " of: "+ config);
               new CacheInitializer().configure(config).initialize(
                       rawCache.getCacheConfiguration());
           }

		this.cacheManager.addCache(rawCache);
	}
	boolean override = false;
	if (serverConfigurationService != null) {
		override = serverConfigurationService.getBoolean(
				"memory.cache.statistics.force.disabled", false);
	}
	if (this.statisticsEnabled && !override) {
		rawCache.setStatisticsEnabled(true);
	}
	if (this.sampledStatisticsEnabled) {
		rawCache.setSampledStatisticsEnabled(true);
	}

	// Decorate cache if necessary.
	Ehcache decoratedCache = decorateCache(rawCache);
	if (decoratedCache != rawCache) {
		this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
	}
	this.cache = decoratedCache;
}
 
Example 18
Source File: CacheProvider.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtain CacheManager used by Hibernate
 */
public CacheManager getManager() {
	return CacheManager.getInstance();
}
 
Example 19
Source File: EhCacheFactoryBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	// If no cache name given, use bean name as cache name.
	String cacheName = getName();
	if (cacheName == null) {
		cacheName = this.beanName;
		setName(cacheName);
	}

	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	synchronized (this.cacheManager) {
		// Fetch cache region: If none with the given name exists, create one on the fly.
		Ehcache rawCache;
		boolean cacheExists = this.cacheManager.cacheExists(cacheName);

		if (cacheExists) {
			if (logger.isDebugEnabled()) {
				logger.debug("Using existing EhCache cache region '" + cacheName + "'");
			}
			rawCache = this.cacheManager.getEhcache(cacheName);
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Creating new EhCache cache region '" + cacheName + "'");
			}
			rawCache = createCache();
			rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader);
		}

		if (this.cacheEventListeners != null) {
			for (CacheEventListener listener : this.cacheEventListeners) {
				rawCache.getCacheEventNotificationService().registerListener(listener);
			}
		}

		// Needs to happen after listener registration but before setStatisticsEnabled
		if (!cacheExists) {
			this.cacheManager.addCache(rawCache);
		}

		// Only necessary on EhCache <2.7: As of 2.7, statistics are on by default.
		if (this.statisticsEnabled && setStatisticsEnabledMethod != null) {
			ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true);
		}
		if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) {
			ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true);
		}

		if (this.disabled) {
			rawCache.setDisabled(true);
		}

		Ehcache decoratedCache = decorateCache(rawCache);
		if (decoratedCache != rawCache) {
			this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
		}
		this.cache = decoratedCache;
	}
}
 
Example 20
Source File: EhCacheFactoryBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	// If no cache name given, use bean name as cache name.
	String cacheName = getName();
	if (cacheName == null) {
		cacheName = this.beanName;
		setName(cacheName);
	}

	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	synchronized (this.cacheManager) {
		// Fetch cache region: If none with the given name exists, create one on the fly.
		Ehcache rawCache;
		boolean cacheExists = this.cacheManager.cacheExists(cacheName);

		if (cacheExists) {
			if (logger.isDebugEnabled()) {
				logger.debug("Using existing EhCache cache region '" + cacheName + "'");
			}
			rawCache = this.cacheManager.getEhcache(cacheName);
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Creating new EhCache cache region '" + cacheName + "'");
			}
			rawCache = createCache();
			rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader);
		}

		if (this.cacheEventListeners != null) {
			for (CacheEventListener listener : this.cacheEventListeners) {
				rawCache.getCacheEventNotificationService().registerListener(listener);
			}
		}

		// Needs to happen after listener registration but before setStatisticsEnabled
		if (!cacheExists) {
			this.cacheManager.addCache(rawCache);
		}

		// Only necessary on EhCache <2.7: As of 2.7, statistics are on by default.
		if (this.statisticsEnabled && setStatisticsEnabledMethod != null) {
			ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true);
		}
		if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) {
			ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true);
		}

		if (this.disabled) {
			rawCache.setDisabled(true);
		}

		Ehcache decoratedCache = decorateCache(rawCache);
		if (decoratedCache != rawCache) {
			this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
		}
		this.cache = decoratedCache;
	}
}