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

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

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

Configuration.getConfigurationSource介绍

[英]Gets a description of the source from which this configuration was created.
[中]获取创建此配置的源的说明。

代码示例

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

/**
 * Returns the original configuration text for this {@link CacheManager}
 *
 * @return Returns the original configuration text for this {@link CacheManager}
 */
public String getOriginalConfigurationText() {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    return ConfigurationUtil.generateCacheManagerConfigurationText(originalConfiguration);
  }
}

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

private void detectAndFixCacheManagerPeerListenerConflict(ConfigurationHelper configurationHelper) {
  if (cacheManagerPeerListeners == null) {
    return;
  }
  for (CacheManagerPeerListener cacheManagerPeerListener : cacheManagerPeerListeners.values()) {
    String uniqueResourceIdentifier = cacheManagerPeerListener.getUniqueResourceIdentifier();
    for (CacheManager cacheManager : ALL_CACHE_MANAGERS) {
      for (CacheManagerPeerListener otherCacheManagerPeerListener : cacheManager.cacheManagerPeerListeners.values()) {
        if (otherCacheManagerPeerListener == null) {
          continue;
        }
        String otherUniqueResourceIdentifier = otherCacheManagerPeerListener.getUniqueResourceIdentifier();
        if (uniqueResourceIdentifier.equals(otherUniqueResourceIdentifier)) {
          LOG.warn("Creating a new instance of CacheManager with a CacheManagerPeerListener which "
              + "has a conflict on a resource that must be unique.\n" + "The resource is " + uniqueResourceIdentifier
              + ".\n" + "Attempting automatic resolution. The source of the configuration was "
              + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n"
              + "To avoid this warning consider using the CacheManager factory methods to create a "
              + "singleton CacheManager "
              + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.");
          cacheManagerPeerListener.attemptResolutionOfUniqueResourceConflict();
          break;
        }
      }
    }
  }
}

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

private void assertNoCacheManagerExistsWithSameName(Configuration configuration) {
  synchronized (CacheManager.class) {
    final String name;
    final boolean isNamed;
    if (configuration.getName() != null) {
      name = configuration.getName();
      isNamed = true;
    } else {
      name = DEFAULT_NAME;
      isNamed = false;
    }
    CacheManager cacheManager = CACHE_MANAGERS_MAP.get(name);
    if (cacheManager == null) {
      CACHE_MANAGERS_MAP.put(name, this);
      CACHE_MANAGERS_REVERSE_MAP.put(this, name);
    } else {
      ConfigurationSource configurationSource = cacheManager.getConfiguration().getConfigurationSource();
      final String msg = "Another "
          + (isNamed ? "CacheManager with same name '" + name + "'" : "unnamed CacheManager")
          + " already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:\n"
          + "1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name"
          + " or create one if necessary\n"
          + "2. Shutdown the earlier cacheManager before creating new one with same name.\n"
          + "The source of the existing CacheManager is: "
          + (configurationSource == null ? "[Programmatically configured]" : configurationSource);
      throw new CacheException(msg);
    }
  }
}

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

/**
 * Returns the original configuration text for the input cacheName
 *
 * @param cacheName
 * @return Returns the original configuration text for the input cacheName
 * @throws CacheException if the cache with <code>cacheName</code> does not exist in the original config
 */
public String getOriginalConfigurationText(String cacheName) throws CacheException {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    CacheConfiguration cacheConfiguration = originalConfiguration.getCacheConfigurations().get(cacheName);
    if (cacheConfiguration == null) {
      throw new CacheException("Cache with name '" + cacheName + "' does not exist in the original configuration");
    }
    return ConfigurationUtil.generateCacheConfigurationText(runtimeCfg.getConfiguration(), cacheConfiguration);
  }
}

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

/**
 * Returns the original configuration text for this {@link CacheManager}
 *
 * @return Returns the original configuration text for this {@link CacheManager}
 */
public String getOriginalConfigurationText() {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    return ConfigurationUtil.generateCacheManagerConfigurationText(originalConfiguration);
  }
}

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

/**
 * Returns the original configuration text for this {@link CacheManager}
 *
 * @return Returns the original configuration text for this {@link CacheManager}
 */
public String getOriginalConfigurationText() {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    return ConfigurationUtil.generateCacheManagerConfigurationText(originalConfiguration);
  }
}

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

/**
 * Returns the original configuration text for this {@link CacheManager}
 *
 * @return Returns the original configuration text for this {@link CacheManager}
 */
public String getOriginalConfigurationText() {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    return ConfigurationUtil.generateCacheManagerConfigurationText(originalConfiguration);
  }
}

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

private void detectAndFixCacheManagerPeerListenerConflict(ConfigurationHelper configurationHelper) {
  if (cacheManagerPeerListeners == null) {
    return;
  }
  for (CacheManagerPeerListener cacheManagerPeerListener : cacheManagerPeerListeners.values()) {
    String uniqueResourceIdentifier = cacheManagerPeerListener.getUniqueResourceIdentifier();
    for (CacheManager cacheManager : ALL_CACHE_MANAGERS) {
      for (CacheManagerPeerListener otherCacheManagerPeerListener : cacheManager.cacheManagerPeerListeners.values()) {
        if (otherCacheManagerPeerListener == null) {
          continue;
        }
        String otherUniqueResourceIdentifier = otherCacheManagerPeerListener.getUniqueResourceIdentifier();
        if (uniqueResourceIdentifier.equals(otherUniqueResourceIdentifier)) {
          LOG.warn("Creating a new instance of CacheManager with a CacheManagerPeerListener which "
              + "has a conflict on a resource that must be unique.\n" + "The resource is " + uniqueResourceIdentifier
              + ".\n" + "Attempting automatic resolution. The source of the configuration was "
              + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n"
              + "To avoid this warning consider using the CacheManager factory methods to create a "
              + "singleton CacheManager "
              + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.");
          cacheManagerPeerListener.attemptResolutionOfUniqueResourceConflict();
          break;
        }
      }
    }
  }
}

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

private void detectAndFixCacheManagerPeerListenerConflict(ConfigurationHelper configurationHelper) {
  if (cacheManagerPeerListeners == null) {
    return;
  }
  for (CacheManagerPeerListener cacheManagerPeerListener : cacheManagerPeerListeners.values()) {
    String uniqueResourceIdentifier = cacheManagerPeerListener.getUniqueResourceIdentifier();
    for (CacheManager cacheManager : ALL_CACHE_MANAGERS) {
      for (CacheManagerPeerListener otherCacheManagerPeerListener : cacheManager.cacheManagerPeerListeners.values()) {
        if (otherCacheManagerPeerListener == null) {
          continue;
        }
        String otherUniqueResourceIdentifier = otherCacheManagerPeerListener.getUniqueResourceIdentifier();
        if (uniqueResourceIdentifier.equals(otherUniqueResourceIdentifier)) {
          LOG.warn("Creating a new instance of CacheManager with a CacheManagerPeerListener which "
              + "has a conflict on a resource that must be unique.\n" + "The resource is " + uniqueResourceIdentifier
              + ".\n" + "Attempting automatic resolution. The source of the configuration was "
              + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n"
              + "To avoid this warning consider using the CacheManager factory methods to create a "
              + "singleton CacheManager "
              + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.");
          cacheManagerPeerListener.attemptResolutionOfUniqueResourceConflict();
          break;
        }
      }
    }
  }
}

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

private void detectAndFixCacheManagerPeerListenerConflict(ConfigurationHelper configurationHelper) {
  if (cacheManagerPeerListeners == null) {
    return;
  }
  for (CacheManagerPeerListener cacheManagerPeerListener : cacheManagerPeerListeners.values()) {
    String uniqueResourceIdentifier = cacheManagerPeerListener.getUniqueResourceIdentifier();
    for (CacheManager cacheManager : ALL_CACHE_MANAGERS) {
      for (CacheManagerPeerListener otherCacheManagerPeerListener : cacheManager.cacheManagerPeerListeners.values()) {
        if (otherCacheManagerPeerListener == null) {
          continue;
        }
        String otherUniqueResourceIdentifier = otherCacheManagerPeerListener.getUniqueResourceIdentifier();
        if (uniqueResourceIdentifier.equals(otherUniqueResourceIdentifier)) {
          LOG.warn("Creating a new instance of CacheManager with a CacheManagerPeerListener which "
              + "has a conflict on a resource that must be unique.\n" + "The resource is " + uniqueResourceIdentifier
              + ".\n" + "Attempting automatic resolution. The source of the configuration was "
              + configurationHelper.getConfigurationBean().getConfigurationSource() + ".\n"
              + "To avoid this warning consider using the CacheManager factory methods to create a "
              + "singleton CacheManager "
              + "or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.");
          cacheManagerPeerListener.attemptResolutionOfUniqueResourceConflict();
          break;
        }
      }
    }
  }
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

@Override
public Properties getProperties() {
  Configuration ec = cacheManager.getConfiguration();
  Properties p = new Properties();
  p.put("name", ec.getName());
  p.put("source", ec.getConfigurationSource().toString());
  p.put("timeoutSeconds", ec.getDefaultTransactionTimeoutInSeconds());
  p.put("maxBytesDisk", ec.getMaxBytesLocalDisk());
  p.put("maxBytesHeap", ec.getMaxBytesLocalHeap());
  p.put("maxDepth", ec.getSizeOfPolicyConfiguration().getMaxDepth());
  p.put("defaultCacheMaxEntries", ec.getDefaultCacheConfiguration().getMaxEntriesLocalHeap());
  p.put("defaultCacheTimeToIdleSecs", ec.getDefaultCacheConfiguration().getTimeToIdleSeconds());
  p.put("defaultCacheTimeToLiveSecs", ec.getDefaultCacheConfiguration().getTimeToLiveSeconds());
  p.put("defaultCacheEternal", ec.getDefaultCacheConfiguration().isEternal());
  return p;
}

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

private void assertNoCacheManagerExistsWithSameName(Configuration configuration) {
  synchronized (CacheManager.class) {
    final String name;
    final boolean isNamed;
    if (configuration.getName() != null) {
      name = configuration.getName();
      isNamed = true;
    } else {
      name = DEFAULT_NAME;
      isNamed = false;
    }
    CacheManager cacheManager = CACHE_MANAGERS_MAP.get(name);
    if (cacheManager == null) {
      CACHE_MANAGERS_MAP.put(name, this);
      CACHE_MANAGERS_REVERSE_MAP.put(this, name);
    } else {
      ConfigurationSource configurationSource = cacheManager.getConfiguration().getConfigurationSource();
      final String msg = "Another "
          + (isNamed ? "CacheManager with same name '" + name + "'" : "unnamed CacheManager")
          + " already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:\n"
          + "1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name"
          + " or create one if necessary\n"
          + "2. Shutdown the earlier cacheManager before creating new one with same name.\n"
          + "The source of the existing CacheManager is: "
          + (configurationSource == null ? "[Programmatically configured]" : configurationSource);
      throw new CacheException(msg);
    }
  }
}

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

private void assertNoCacheManagerExistsWithSameName(Configuration configuration) {
  synchronized (CacheManager.class) {
    final String name;
    final boolean isNamed;
    if (configuration.getName() != null) {
      name = configuration.getName();
      isNamed = true;
    } else {
      name = DEFAULT_NAME;
      isNamed = false;
    }
    CacheManager cacheManager = CACHE_MANAGERS_MAP.get(name);
    if (cacheManager == null) {
      CACHE_MANAGERS_MAP.put(name, this);
      CACHE_MANAGERS_REVERSE_MAP.put(this, name);
    } else {
      ConfigurationSource configurationSource = cacheManager.getConfiguration().getConfigurationSource();
      final String msg = "Another "
          + (isNamed ? "CacheManager with same name '" + name + "'" : "unnamed CacheManager")
          + " already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:\n"
          + "1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name"
          + " or create one if necessary\n"
          + "2. Shutdown the earlier cacheManager before creating new one with same name.\n"
          + "The source of the existing CacheManager is: "
          + (configurationSource == null ? "[Programmatically configured]" : configurationSource);
      throw new CacheException(msg);
    }
  }
}

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

private void assertNoCacheManagerExistsWithSameName(Configuration configuration) {
  synchronized (CacheManager.class) {
    final String name;
    final boolean isNamed;
    if (configuration.getName() != null) {
      name = configuration.getName();
      isNamed = true;
    } else {
      name = DEFAULT_NAME;
      isNamed = false;
    }
    CacheManager cacheManager = CACHE_MANAGERS_MAP.get(name);
    if (cacheManager == null) {
      CACHE_MANAGERS_MAP.put(name, this);
      CACHE_MANAGERS_REVERSE_MAP.put(this, name);
    } else {
      ConfigurationSource configurationSource = cacheManager.getConfiguration().getConfigurationSource();
      final String msg = "Another "
          + (isNamed ? "CacheManager with same name '" + name + "'" : "unnamed CacheManager")
          + " already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:\n"
          + "1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name"
          + " or create one if necessary\n"
          + "2. Shutdown the earlier cacheManager before creating new one with same name.\n"
          + "The source of the existing CacheManager is: "
          + (configurationSource == null ? "[Programmatically configured]" : configurationSource);
      throw new CacheException(msg);
    }
  }
}

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

/**
 * Returns the original configuration text for the input cacheName
 *
 * @param cacheName
 * @return Returns the original configuration text for the input cacheName
 * @throws CacheException if the cache with <code>cacheName</code> does not exist in the original config
 */
public String getOriginalConfigurationText(String cacheName) throws CacheException {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    CacheConfiguration cacheConfiguration = originalConfiguration.getCacheConfigurations().get(cacheName);
    if (cacheConfiguration == null) {
      throw new CacheException("Cache with name '" + cacheName + "' does not exist in the original configuration");
    }
    return ConfigurationUtil.generateCacheConfigurationText(runtimeCfg.getConfiguration(), cacheConfiguration);
  }
}

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

/**
 * Returns the original configuration text for the input cacheName
 *
 * @param cacheName
 * @return Returns the original configuration text for the input cacheName
 * @throws CacheException if the cache with <code>cacheName</code> does not exist in the original config
 */
public String getOriginalConfigurationText(String cacheName) throws CacheException {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    CacheConfiguration cacheConfiguration = originalConfiguration.getCacheConfigurations().get(cacheName);
    if (cacheConfiguration == null) {
      throw new CacheException("Cache with name '" + cacheName + "' does not exist in the original configuration");
    }
    return ConfigurationUtil.generateCacheConfigurationText(runtimeCfg.getConfiguration(), cacheConfiguration);
  }
}

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

/**
 * Returns the original configuration text for the input cacheName
 *
 * @param cacheName
 * @return Returns the original configuration text for the input cacheName
 * @throws CacheException if the cache with <code>cacheName</code> does not exist in the original config
 */
public String getOriginalConfigurationText(String cacheName) throws CacheException {
  if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
    return "Originally configured programmatically. No original configuration source text.";
  } else {
    Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
    CacheConfiguration cacheConfiguration = originalConfiguration.getCacheConfigurations().get(cacheName);
    if (cacheConfiguration == null) {
      throw new CacheException("Cache with name '" + cacheName + "' does not exist in the original configuration");
    }
    return ConfigurationUtil.generateCacheConfigurationText(runtimeCfg.getConfiguration(), cacheConfiguration);
  }
}

代码示例来源: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);
}

相关文章

Configuration类方法