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

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

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

Configuration.getDiskStoreConfiguration介绍

[英]Gets the disk store configuration.
[中]获取磁盘存储配置。

代码示例

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

/**
 * @return the disk store path, or null if not set.
 */
public final String getDiskStorePath() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration == null) {
    return null;
  } else {
    return diskStoreConfiguration.getPath();
  }
}

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

private void testAddDiskStoreElement() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration != null) {
    addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration));
  }
}

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

/**
 * @return the disk store path, or null if not set.
 */
public final String getDiskStorePath() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration == null) {
    return null;
  } else {
    return diskStoreConfiguration.getPath();
  }
}

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

/**
 * @return the disk store path, or null if not set.
 */
public final String getDiskStorePath() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration == null) {
    return null;
  } else {
    return diskStoreConfiguration.getPath();
  }
}

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

/**
 * @return the disk store path, or null if not set.
 */
public final String getDiskStorePath() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration == null) {
    return null;
  } else {
    return diskStoreConfiguration.getPath();
  }
}

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

protected void configureDiskStore( final AppContext appContext, final Configuration ehConfig )
  {
    if ( ehConfig.getDiskStoreConfiguration() != null && ehConfig.getDiskStoreConfiguration().getPath() != null )
    {
      final String path = ehConfig.getDiskStoreConfiguration().getPath();
      final String interpolatedPath = appContext != null ? appContext.interpolate( path ) : path;
      try
      {
        ehConfig.getDiskStoreConfiguration().setPath( new File( interpolatedPath ).getCanonicalPath() );
      }
      catch ( IOException e )
      {
        getLogger().warn( "Could not canonize the path \"{}\"!", interpolatedPath, e );

        // set the best we can
        ehConfig.getDiskStoreConfiguration().setPath( new File( interpolatedPath ).getAbsolutePath() );
      }
    }
  }
}

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

private void testAddDiskStoreElement() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration != null) {
    addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration));
  }
}

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

private void testAddDiskStoreElement() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration != null) {
    addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration));
  }
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

private static CacheManager findDefaultCacheManager(String confName, URL configFileURL) {
  try {
    Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
    conf.setName(confName);
    if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) {
      String path = conf.getDiskStoreConfiguration().getPath() + File.separator
        + confName;
      conf.getDiskStoreConfiguration().setPath(path);
    }
    return createCacheManager(conf);
  } catch (Throwable t) {
    return null;
  }
}

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

private void testAddDiskStoreElement() {
  DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration();
  if (diskStoreConfiguration != null) {
    addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration));
  }
}

代码示例来源:origin: uk.ac.ebi.enfin.mi.cluster/micluster

configuration.getDiskStoreConfiguration().setPath( cacheStorage.getAbsolutePath() );
ehcacheManager = new net.sf.ehcache.CacheManager( configuration );

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

private void createCache(String configFile, Bus cxfBus) {
  if (cxfBus == null) {
    cxfBus = BusFactory.getThreadDefaultBus(true);
  }
  URL configFileURL = null;
  try {
    configFileURL =
      ClassLoaderUtils.getResource(configFile, EHCacheXKMSClientCache.class);
  } catch (Exception ex) {
    // ignore
  }
  if (configFileURL == null) {
    cacheManager = EHCacheUtil.createCacheManager();
  } else {
    Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
    if (cxfBus != null) {
      conf.setName(cxfBus.getId());
      DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
      if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
        String path = conf.getDiskStoreConfiguration().getPath() + File.separator
          + cxfBus.getId();
        conf.getDiskStoreConfiguration().setPath(path);
      }
    }
    cacheManager = EHCacheUtil.createCacheManager(conf);
  }
  CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
  Ehcache newCache = new Cache(cc);
  cache = cacheManager.addCacheIfAbsent(newCache);
}

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

private void createCache(String configFile, Bus bus) {
  if (bus == null) {
    bus = BusFactory.getThreadDefaultBus(true);
  }
  URL configFileURL = null;
  try {
    configFileURL =
      ResourceUtils.getClasspathResourceURL(configFile, EHCacheTokenReplayCache.class, bus);
  } catch (Exception ex) {
    // ignore
  }
  if (configFileURL == null) {
    cacheManager = EHCacheUtil.createCacheManager();
  } else {
    Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
    if (bus != null) {
      conf.setName(bus.getId());
      DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
      if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
        String path = conf.getDiskStoreConfiguration().getPath() + File.separator
          + bus.getId();
        conf.getDiskStoreConfiguration().setPath(path);
      }
    }
    cacheManager = EHCacheUtil.createCacheManager(conf);
  }
  CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
  Ehcache newCache = new Cache(cc);
  cache = cacheManager.addCacheIfAbsent(newCache);
}

代码示例来源:origin: org.apache.cxf.services.xkms/cxf-services-xkms-client

private void createCache(String configFile, Bus cxfBus) {
  if (cxfBus == null) {
    cxfBus = BusFactory.getThreadDefaultBus(true);
  }
  URL configFileURL = null;
  try {
    configFileURL =
      ClassLoaderUtils.getResource(configFile, EHCacheXKMSClientCache.class);
  } catch (Exception ex) {
    // ignore
  }
  if (configFileURL == null) {
    cacheManager = EHCacheUtil.createCacheManager();
  } else {
    Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
    if (cxfBus != null) {
      conf.setName(cxfBus.getId());
      DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
      if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
        String path = conf.getDiskStoreConfiguration().getPath() + File.separator
          + cxfBus.getId();
        conf.getDiskStoreConfiguration().setPath(path);
      }
    }
    cacheManager = EHCacheUtil.createCacheManager(conf);
  }
  CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
  Ehcache newCache = new Cache(cc);
  cache = cacheManager.addCacheIfAbsent(newCache);
}

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

DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
  String path = conf.getDiskStoreConfiguration().getPath() + File.separator
    + bus.getId();
  conf.getDiskStoreConfiguration().setPath(path);

代码示例来源:origin: info.magnolia/magnolia-module-cache

@Override
public void start() {
  final Configuration cfg = ConfigurationFactory.parseConfiguration();
  cfg.setSource("ehcache defaults");
  if (defaultCacheConfiguration != null) {
    cfg.setDefaultCacheConfiguration(defaultCacheConfiguration);
    cfg.setSource(cfg.getConfigurationSource() + " + Magnolia-based defaultCacheConfiguration");
  }
  if (diskStorePath != null) {
    cfg.getDiskStoreConfiguration().setPath(diskStorePath);
    cfg.setSource(cfg.getConfigurationSource() + " + Magnolia-based diskStorePath");
  }
  cacheManager = new CacheManager(cfg);
  // TODO cacheManager.setName(...magnolia instance name ...);
  final MBeanServer mBeanServer = MBeanUtil.getMBeanServer();
  ManagementService.registerMBeans(cacheManager, mBeanServer, true, true, true, true);
}

代码示例来源:origin: com.madgag/mini-git-server-server

private void configureDefaultCache() {
 final CacheConfiguration c = new CacheConfiguration();
 c.setMaxElementsInMemory(1024);
 c.setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy.LFU);
 c.setTimeToIdleSeconds(0);
 c.setTimeToLiveSeconds(0 /* infinite */);
 c.setEternal(true);
 if (mgr.getDiskStoreConfiguration() != null) {
  c.setMaxElementsOnDisk(16384);
  c.setOverflowToDisk(false);
  c.setDiskPersistent(false);
  c.setDiskSpoolBufferSizeMB(5);
  c.setDiskExpiryThreadIntervalSeconds(60 * 60);
 }
 mgr.setDefaultCacheConfiguration(c);
}

代码示例来源:origin: rtyley/mini-git-server

private void configureDefaultCache() {
 final CacheConfiguration c = new CacheConfiguration();
 c.setMaxElementsInMemory(1024);
 c.setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy.LFU);
 c.setTimeToIdleSeconds(0);
 c.setTimeToLiveSeconds(0 /* infinite */);
 c.setEternal(true);
 if (mgr.getDiskStoreConfiguration() != null) {
  c.setMaxElementsOnDisk(16384);
  c.setOverflowToDisk(false);
  c.setDiskPersistent(false);
  c.setDiskSpoolBufferSizeMB(5);
  c.setDiskExpiryThreadIntervalSeconds(60 * 60);
 }
 mgr.setDefaultCacheConfiguration(c);
}

代码示例来源:origin: rtyley/mini-git-server

Configuration toConfiguration() {
 configureDiskStore();
 configureDefaultCache();
 for (CacheProvider<?, ?> p : caches.values()) {
  final String name = p.getName();
  final CacheConfiguration c = newCache(name);
  c.setMemoryStoreEvictionPolicyFromObject(toPolicy(p.evictionPolicy()));
  c.setMaxElementsInMemory(getInt(name, "memorylimit", p.memoryLimit()));
  c.setTimeToIdleSeconds(0);
  c.setTimeToLiveSeconds(getSeconds(name, "maxage", p.maxAge()));
  c.setEternal(c.getTimeToLiveSeconds() == 0);
  if (p.disk() && mgr.getDiskStoreConfiguration() != null) {
   c.setMaxElementsOnDisk(getInt(name, "disklimit", p.diskLimit()));
   int v = c.getDiskSpoolBufferSizeMB() * MB;
   v = getInt(name, "diskbuffer", v) / MB;
   c.setDiskSpoolBufferSizeMB(Math.max(1, v));
   c.setOverflowToDisk(c.getMaxElementsOnDisk() > 0);
   c.setDiskPersistent(c.getMaxElementsOnDisk() > 0);
  }
  mgr.addCache(c);
 }
 return mgr;
}

代码示例来源:origin: com.madgag/mini-git-server-server

Configuration toConfiguration() {
 configureDiskStore();
 configureDefaultCache();
 for (CacheProvider<?, ?> p : caches.values()) {
  final String name = p.getName();
  final CacheConfiguration c = newCache(name);
  c.setMemoryStoreEvictionPolicyFromObject(toPolicy(p.evictionPolicy()));
  c.setMaxElementsInMemory(getInt(name, "memorylimit", p.memoryLimit()));
  c.setTimeToIdleSeconds(0);
  c.setTimeToLiveSeconds(getSeconds(name, "maxage", p.maxAge()));
  c.setEternal(c.getTimeToLiveSeconds() == 0);
  if (p.disk() && mgr.getDiskStoreConfiguration() != null) {
   c.setMaxElementsOnDisk(getInt(name, "disklimit", p.diskLimit()));
   int v = c.getDiskSpoolBufferSizeMB() * MB;
   v = getInt(name, "diskbuffer", v) / MB;
   c.setDiskSpoolBufferSizeMB(Math.max(1, v));
   c.setOverflowToDisk(c.getMaxElementsOnDisk() > 0);
   c.setDiskPersistent(c.getMaxElementsOnDisk() > 0);
  }
  mgr.addCache(c);
 }
 return mgr;
}

相关文章

Configuration类方法