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

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

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

Configuration.getClassLoader介绍

暂无

代码示例

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

/**
 * Only Constructor
 *
 * @param cacheManager
 * @param configuration
 */
public ConfigurationHelper(CacheManager cacheManager, Configuration configuration) {
  if (cacheManager == null || configuration == null) {
    throw new IllegalArgumentException("Cannot have null parameters");
  }
  this.cacheManager = cacheManager;
  this.configuration = configuration;
  this.loader = configuration.getClassLoader();
}

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

private ClassLoader getClassLoader() {
  return this.runtimeCfg.getConfiguration().getClassLoader();
}

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

/**
 * Create a cache given a cache configuration
 *
 * @param cacheConfiguration
 */
final Ehcache createCache(CacheConfiguration cacheConfiguration) {        
  CacheConfiguration configClone = cacheConfiguration.clone();
  
  // make sure all caches use the same classloader that the CacheManager is configured to use
  configClone.setClassLoader(configuration.getClassLoader());
  
  Ehcache cache = new Cache(configClone, null, null);
  cache = applyCacheExceptionHandler(configClone, cache);
  return cache;
}

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

lookupConfiguration.getPropertySeparator());
ClassLoader loader = getClassLoader();

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

private void doLoad(final Ehcache cache) {
  CacheManager manager = cache.getCacheManager();
  if (manager == null) {
    throw new CacheException("Cache must belong to a cache manager to bootstrap");
  }
  DiskStorePathManager pathManager = diskStorePathManager != null ? diskStorePathManager : cache.getCacheManager()
      .getDiskStorePathManager();
  final RotatingSnapshotFile snapshotFile = new RotatingSnapshotFile(pathManager, cache.getName(), manager.getConfiguration().getClassLoader());
  try {
    final Set<Object> keys = snapshotFile.readAll();
    int loaded = 0;
    for (Object key : keys) {
      if (isInMemoryLimitReached(cache, loaded)) {
        break;
      }
      cache.get(key);
      loaded++;
    }
    LOG.info("Finished loading {} keys (of {} on disk) from previous snapshot for Cache '{}'",
        new Object[] {Integer.valueOf(loaded), keys.size(), cache.getName()});
  } catch (IOException e) {
    LOG.error("Couldn't load keySet for Cache '{}'", cache.getName(), e);
  }
  if (doKeySnapshot) {
    keySnapshotter = new KeySnapshotter(cache, interval, doKeySnapshotOnDedicatedThread, snapshotFile);
  }
}

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

private synchronized ClusteredInstanceFactoryWrapper createNewClusteredInstanceFactory() {
  // shut down the old factory
  if (clusteredInstanceFactory != null) {
    info("Shutting down old ClusteredInstanceFactory...");
    shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory);
  }
  info("Creating new ClusteredInstanceFactory");
  ClusteredInstanceFactory factory;
  factory = TerracottaClusteredInstanceHelper.getInstance().newClusteredInstanceFactory(terracottaClientConfiguration, cacheManager.getConfiguration().getClassLoader());
  CacheCluster underlyingCacheCluster = factory.getTopology();
  cacheCluster.setUnderlyingCacheCluster(underlyingCacheCluster);
  return new ClusteredInstanceFactoryWrapper(this, factory);
}

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

/**
 * Only Constructor
 *
 * @param cacheManager
 * @param configuration
 */
public ConfigurationHelper(CacheManager cacheManager, Configuration configuration) {
  if (cacheManager == null || configuration == null) {
    throw new IllegalArgumentException("Cannot have null parameters");
  }
  this.cacheManager = cacheManager;
  this.configuration = configuration;
  this.loader = configuration.getClassLoader();
}

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

/**
 * Only Constructor
 *
 * @param cacheManager
 * @param configuration
 */
public ConfigurationHelper(CacheManager cacheManager, Configuration configuration) {
  if (cacheManager == null || configuration == null) {
    throw new IllegalArgumentException("Cannot have null parameters");
  }
  this.cacheManager = cacheManager;
  this.configuration = configuration;
  this.loader = configuration.getClassLoader();
}

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

@Override
public ClassLoader getClassLoader() {
  return cacheManager.getConfiguration().getClassLoader();
}

代码示例来源:origin: ehcache/ehcache-jcache

@Override
public ClassLoader getClassLoader() {
  return cacheManager.getConfiguration().getClassLoader();
}

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

private ClassLoader getClassLoader() {
  return this.runtimeCfg.getConfiguration().getClassLoader();
}

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

private ClassLoader getClassLoader() {
  return this.runtimeCfg.getConfiguration().getClassLoader();
}

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

if (loader != cacheManager.getConfiguration().getClassLoader()) {

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

/**
 * Create a cache given a cache configuration
 *
 * @param cacheConfiguration
 */
final Ehcache createCache(CacheConfiguration cacheConfiguration) {        
  CacheConfiguration configClone = cacheConfiguration.clone();
  
  // make sure all caches use the same classloader that the CacheManager is configured to use
  configClone.setClassLoader(configuration.getClassLoader());
  
  Ehcache cache = new Cache(configClone, null, null);
  cache = applyCacheExceptionHandler(configClone, cache);
  return cache;
}

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

/**
 * Create a cache given a cache configuration
 *
 * @param cacheConfiguration
 */
final Ehcache createCache(CacheConfiguration cacheConfiguration) {        
  CacheConfiguration configClone = cacheConfiguration.clone();
  
  // make sure all caches use the same classloader that the CacheManager is configured to use
  configClone.setClassLoader(configuration.getClassLoader());
  
  Ehcache cache = new Cache(configClone, null, null);
  cache = applyCacheExceptionHandler(configClone, cache);
  return cache;
}

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

private void doLoad(final Ehcache cache) {
  CacheManager manager = cache.getCacheManager();
  if (manager == null) {
    throw new CacheException("Cache must belong to a cache manager to bootstrap");
  }
  DiskStorePathManager pathManager = diskStorePathManager != null ? diskStorePathManager : cache.getCacheManager()
      .getDiskStorePathManager();
  final RotatingSnapshotFile snapshotFile = new RotatingSnapshotFile(pathManager, cache.getName(), manager.getConfiguration().getClassLoader());
  try {
    final Set<Object> keys = snapshotFile.readAll();
    int loaded = 0;
    for (Object key : keys) {
      if (isInMemoryLimitReached(cache, loaded)) {
        break;
      }
      cache.get(key);
      loaded++;
    }
    LOG.info("Finished loading {} keys (of {} on disk) from previous snapshot for Cache '{}'",
        new Object[] {Integer.valueOf(loaded), keys.size(), cache.getName()});
  } catch (IOException e) {
    LOG.error("Couldn't load keySet for Cache '{}'", cache.getName(), e);
  }
  if (doKeySnapshot) {
    keySnapshotter = new KeySnapshotter(cache, interval, doKeySnapshotOnDedicatedThread, snapshotFile);
  }
}

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

private synchronized ClusteredInstanceFactoryWrapper createNewClusteredInstanceFactory() {
  // shut down the old factory
  if (clusteredInstanceFactory != null) {
    info("Shutting down old ClusteredInstanceFactory...");
    shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory);
  }
  info("Creating new ClusteredInstanceFactory");
  ClusteredInstanceFactory factory;
  factory = TerracottaClusteredInstanceHelper.getInstance().newClusteredInstanceFactory(terracottaClientConfiguration, cacheManager.getConfiguration().getClassLoader());
  CacheCluster underlyingCacheCluster = factory.getTopology();
  cacheCluster.setUnderlyingCacheCluster(underlyingCacheCluster);
  return new ClusteredInstanceFactoryWrapper(this, factory);
}

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

private synchronized ClusteredInstanceFactoryWrapper createNewClusteredInstanceFactory() {
  // shut down the old factory
  if (clusteredInstanceFactory != null) {
    info("Shutting down old ClusteredInstanceFactory...");
    shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory);
  }
  info("Creating new ClusteredInstanceFactory");
  ClusteredInstanceFactory factory;
  factory = TerracottaClusteredInstanceHelper.getInstance().newClusteredInstanceFactory(terracottaClientConfiguration, cacheManager.getConfiguration().getClassLoader());
  CacheCluster underlyingCacheCluster = factory.getTopology();
  cacheCluster.setUnderlyingCacheCluster(underlyingCacheCluster);
  return new ClusteredInstanceFactoryWrapper(this, factory);
}

代码示例来源:origin: ehcache/ehcache-jcache

private CacheConfiguration toEhcacheConfig(final String name, final Configuration configuration) {
  final int maxSize = cacheManager.getConfiguration().isMaxBytesLocalHeapSet() ? 0 : DEFAULT_SIZE;
  CacheConfiguration cfg = new CacheConfiguration(name, maxSize);
  cfg.setClassLoader(cacheManager.getConfiguration().getClassLoader());
  if(configuration.isStoreByValue()) {
    final CopyStrategyConfiguration copyStrategyConfiguration = new CopyStrategyConfiguration();
    copyStrategyConfiguration.setCopyStrategyInstance(new JCacheCopyOnWriteStrategy());
    cfg.copyOnRead(true).copyOnWrite(true)
      .addCopyStrategy(copyStrategyConfiguration);
  }
  if(configuration instanceof CompleteConfiguration) {
    if(((CompleteConfiguration)configuration).isWriteThrough()) {
      cfg.addCacheWriter(new CacheWriterConfiguration().writeMode(CacheWriterConfiguration.WriteMode.WRITE_THROUGH));
    }
  }
  return cfg;
}

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

private CacheConfiguration toEhcacheConfig(final String name, final Configuration configuration) {
  final int maxSize = cacheManager.getConfiguration().isMaxBytesLocalHeapSet() ? 0 : DEFAULT_SIZE;
  CacheConfiguration cfg = new CacheConfiguration(name, maxSize);
  cfg.setClassLoader(cacheManager.getConfiguration().getClassLoader());
  if(configuration.isStoreByValue()) {
    final CopyStrategyConfiguration copyStrategyConfiguration = new CopyStrategyConfiguration();
    copyStrategyConfiguration.setCopyStrategyInstance(new JCacheCopyOnWriteStrategy());
    cfg.copyOnRead(true).copyOnWrite(true)
      .addCopyStrategy(copyStrategyConfiguration);
  }
  if(configuration instanceof CompleteConfiguration) {
    if(((CompleteConfiguration)configuration).isWriteThrough()) {
      cfg.addCacheWriter(new CacheWriterConfiguration().writeMode(CacheWriterConfiguration.WriteMode.WRITE_THROUGH));
    }
  }
  return cfg;
}

相关文章

微信公众号

最新文章

更多

Configuration类方法