net.sf.ehcache.config.Configuration.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中net.sf.ehcache.config.Configuration.<init>()方法的一些代码示例,展示了Configuration.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.<init>()方法的具体详情如下:
包路径:net.sf.ehcache.config.Configuration
类名称:Configuration
方法名:<init>

Configuration.<init>介绍

[英]Empty constructor, which is used by ConfigurationFactory, and can be also used programmatically.

If you are using it programmtically you need to call the relevant add and setter methods in this class to populate everything.
[中]空构造函数,由ConfigurationFactory使用,也可以编程方式使用。
如果以编程方式使用它,则需要调用此类中的相关add和setter方法来填充所有内容。

代码示例

代码示例来源:origin: jooby-project/jooby

public ConfigurationBuilder() {
 this.eh = new Configuration();
}

代码示例来源:origin: gocd/gocd

@Bean(name = "goCache")
public GoCache createCache() {
  CacheManager cacheManager = CacheManager.newInstance(new Configuration().name(getClass().getName()));
  Cache cache = new Cache(cacheConfiguration);
  cacheManager.addCache(cache);
  return new GoCache(cache, transactionSynchronizationManager);
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired() {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(CachingSubjectDnX509PrincipalExtractor.class.getName()));
  synchronized (instance) {
    if (!instance.cacheExists(CACHE_NAME)) {
      instance.addCache(new Cache(cacheConfiguration()));
    }
    return instance.getCache(CACHE_NAME);
  }
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired(String cacheName) {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
  synchronized (instance) {
    if (!instance.cacheExists(cacheName)) {
      instance.addCache(new net.sf.ehcache.Cache(cacheConfiguration(cacheName)));
    }
    return instance.getCache(cacheName);
  }
}

代码示例来源:origin: gocd/gocd

private static Ehcache createCacheIfRequired(String cacheName) {
  final CacheManager instance = CacheManager.newInstance(new Configuration().name(cacheName));
  synchronized (instance) {
    if (!instance.cacheExists(cacheName)) {
      instance.addCache(new Cache(cacheConfiguration(cacheName)));
    }
    return instance.getCache(cacheName);
  }
}

代码示例来源:origin: stackoverflow.com

@Configuration
@EnableCaching
public class CachingConfig implements CachingConfigurer {
  @Bean(destroyMethod="shutdown")
  public net.sf.ehcache.CacheManager ehCacheManager() {
    CacheConfiguration cacheConfiguration = new CacheConfiguration();
    cacheConfiguration.setName("myCacheName");
    cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
    cacheConfiguration.setMaxEntriesLocalHeap(1000);

    net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
    config.addCache(cacheConfiguration);

    return net.sf.ehcache.CacheManager.newInstance(config);
  }

  @Bean
  @Override
  public CacheManager cacheManager() {
    return new EhCacheCacheManager(ehCacheManager());
  }

  @Bean
  @Override
  public KeyGenerator keyGenerator() {
    return new SimpleKeyGenerator();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Before
public void setup() {
  cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests")
      .defaultCache(new CacheConfiguration("default", 100)));
  nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
  cacheManager.addCache(nativeCache);
  cache = new EhCacheCache(nativeCache);
}

代码示例来源:origin: spring-projects/spring-framework

@Before
public void setup() {
  nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests")
      .defaultCache(new CacheConfiguration("default", 100)));
  addNativeCache(CACHE_NAME);
  cacheManager = new EhCacheCacheManager(nativeCacheManager);
  cacheManager.setTransactionAware(false);
  cacheManager.afterPropertiesSet();
  transactionalCacheManager = new EhCacheCacheManager(nativeCacheManager);
  transactionalCacheManager.setTransactionAware(true);
  transactionalCacheManager.afterPropertiesSet();
}

代码示例来源:origin: apache/kylin

System.out.println("runtime used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "M");
Configuration conf = new Configuration();
conf.setMaxBytesLocalHeap("100M");
CacheManager cacheManager = CacheManager.create(conf);

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Configures a bean from an XML input stream.
 */
public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException {
  LOG.debug("Configuring ehcache from InputStream");
  Configuration configuration = new Configuration();
  try {
    InputStream translatedInputStream = translateSystemProperties(inputStream);
    final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    final BeanHandler handler = new BeanHandler(configuration);
    parser.parse(translatedInputStream, handler);
  } catch (Exception e) {
    throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e);
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(inputStream));
  return configuration;
}

代码示例来源:origin: org.jooby/jooby-ehcache

public ConfigurationBuilder() {
 this.eh = new Configuration();
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Configures a bean from an XML input stream.
 */
public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException {
  LOG.debug("Configuring ehcache from InputStream");
  Configuration configuration = new Configuration();
  try {
    InputStream translatedInputStream = translateSystemProperties(inputStream);
    final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    final BeanHandler handler = new BeanHandler(configuration);
    parser.parse(translatedInputStream, handler);
  } catch (Exception e) {
    throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e);
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(inputStream));
  return configuration;
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Configures a bean from an XML input stream.
 */
public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException {
  LOG.debug("Configuring ehcache from InputStream");
  Configuration configuration = new Configuration();
  try {
    InputStream translatedInputStream = translateSystemProperties(inputStream);
    final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    final BeanHandler handler = new BeanHandler(configuration);
    parser.parse(translatedInputStream, handler);
  } catch (Exception e) {
    throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e);
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(inputStream));
  return configuration;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Configures a bean from an XML input stream.
 */
public static Configuration parseConfiguration(final InputStream inputStream) throws CacheException {
  LOG.debug("Configuring ehcache from InputStream");
  Configuration configuration = new Configuration();
  try {
    InputStream translatedInputStream = translateSystemProperties(inputStream);
    final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
    final BeanHandler handler = new BeanHandler(configuration);
    parser.parse(translatedInputStream, handler);
  } catch (Exception e) {
    throw new CacheException("Error configuring from input stream. Initial cause was " + e.getMessage(), e);
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(inputStream));
  return configuration;
}

代码示例来源:origin: bonitasoft/bonita-engine

protected void buildCacheManagerWithDefaultConfiguration() throws SCacheException {
  if (cacheManager != null) {
    String message = "Unable to build a new Cache Manager as the existing one is still alive: " + cacheManager + ". ";
    if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) {
      message += ". Last creation was: \n" + cacheManagerLastCreation;
    }
    throw new SCacheException(message);
  }
  final Configuration configuration = new Configuration();
  configuration.setDefaultCacheConfiguration(defaultCacheConfiguration);
  configuration.diskStore(new DiskStoreConfiguration().path(diskStorePath));
  cacheManager = new CacheManager(configuration);
  if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) {
    cacheManagerLastCreation = getCacheManagerCreationDetails();
  }
}

代码示例来源:origin: gustavoorsi/e-learning

@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {
  CacheConfiguration cacheConfiguration = new CacheConfiguration();
  cacheConfiguration.setName("restApiAuthTokenCache");
  cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
  cacheConfiguration.setMaxEntriesLocalHeap(0); // 0 = MAX
  cacheConfiguration.setTimeToLiveSeconds(14400); // 4 hours.
  cacheConfiguration.setEternal(false);
  net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
  config.addCache(cacheConfiguration);
  return net.sf.ehcache.CacheManager.newInstance(config);
}

代码示例来源:origin: bonitasoft/bonita-engine

protected void buildCacheManagerWithDefaultConfiguration() throws SCacheException {
  if (cacheManager != null) {
    String message = "Unable to build a new Cache Manager as the existing one is still alive: " + cacheManager + ". ";
    if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) {
      message += ". Last creation was: \n" + cacheManagerLastCreation;
    }
    throw new SCacheException(message);
  }
  final Configuration configuration = new Configuration();
  configuration.setDefaultCacheConfiguration(defaultCacheConfiguration);
  configuration.diskStore(new DiskStoreConfiguration().path(diskStorePath));
  cacheManager = new CacheManager(configuration);
  if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.TRACE)) {
    cacheManagerLastCreation = getCacheManagerCreationDetails();
  }
}

代码示例来源:origin: fr.inria.eventcloud/eventcloud-core

private CacheManager createCacheManager(String diskStorePath) {
  Configuration cacheManagerConfig =
      new Configuration().dynamicConfig(false)
          .diskStore(
              new DiskStoreConfiguration().path(diskStorePath))
          .name("default")
          .updateCheck(false);
  return CacheManager.create(cacheManagerConfig);
}

代码示例来源:origin: hburgmeier/jerseyoauth2

public DefaultCacheManagerProvider()
{
  net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
  config.setUpdateCheck(false);
  CacheConfiguration tokenCacheConfiguration = new CacheConfiguration().
      maxEntriesLocalHeap(DEFAULT_MAX_CACHE_ENTRIES).
      name("tokenCache").
      persistence(new PersistenceConfiguration().strategy(Strategy.NONE));
  tokenCacheConfiguration.validateConfiguration();
  config.addCache(tokenCacheConfiguration );
  cacheManager = CacheManager.create(config);
}

代码示例来源:origin: org.finra.herd/herd-dao

/**
 * Gets an EH Cache manager.
 *
 * @return the EH Cache manager.
 */
@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager()
{
  CacheConfiguration cacheConfiguration = new CacheConfiguration();
  cacheConfiguration.setName(HERD_CACHE_NAME);
  cacheConfiguration.setTimeToLiveSeconds(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_TIME_TO_LIVE_SECONDS, Long.class));
  cacheConfiguration.setTimeToIdleSeconds(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_TIME_TO_IDLE_SECONDS, Long.class));
  cacheConfiguration.setMaxElementsInMemory(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_MAX_ELEMENTS_IN_MEMORY, Integer.class));
  cacheConfiguration.setMemoryStoreEvictionPolicy(configurationHelper.getProperty(ConfigurationValue.HERD_CACHE_MEMORY_STORE_EVICTION_POLICY));
  net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
  config.addCache(cacheConfiguration);
  return net.sf.ehcache.CacheManager.create(config);
}

相关文章

微信公众号

最新文章

更多

Configuration类方法