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

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

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

Configuration.setName介绍

[英]Allows BeanHandler to set the CacheManager name.

Cache manager names have constraints on the characters they can use:

  • cache managers that are registered as MBeans must obey the javax.management.ObjectName rules for unquoted value. This means the following characters are illegal: ',', '=', ':', '"', '*' and '?'.
    Note that a clustered cache manager is by default registered as MBean.
    [中]允许BeanHandler设置CacheManager名称。
    缓存管理器名称对其可以使用的字符有限制:
    注册为MBean的缓存管理器必须遵守javax。经营不带引号的值的ObjectName规则。这意味着以下字符是非法的:“、”、“=”、“:”、“”、“”和“?”。
    请注意,集群缓存管理器默认注册为MBean。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Map properties) {
  if (properties != null) {
    final String cacheManagerName = (String) properties.get( EHCACHE_CONFIGURATION_CACHE_MANAGER_NAME );
    if (cacheManagerName != null) {
      configuration.setName( cacheManagerName );
    }
  }
  return configuration;
}

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

/**
 * Build an EhCache {@link CacheManager} from the given configuration resource.
 * @param name the desired name of the cache manager
 * @param configLocation the location of the configuration file (as a Spring resource)
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException {
  Configuration configuration = parseConfiguration(configLocation);
  configuration.setName(name);
  return new CacheManager(configuration);
}

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

/**
 * Build an EhCache {@link CacheManager} from the default configuration.
 * <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path
 * (that is, default EhCache initialization - as defined in the EhCache docs - will apply).
 * If no configuration file can be found, a fail-safe fallback configuration will be used.
 * @param name the desired name of the cache manager
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name) throws CacheException {
  Configuration configuration = ConfigurationFactory.parseConfiguration();
  configuration.setName(name);
  return new CacheManager(configuration);
}

代码示例来源:origin: hibernate/hibernate-orm

static void setCacheManagerNameIfNeeded(SessionFactoryOptions settings, Configuration configuration, Map properties) {
  overwriteCacheManagerIfConfigured( configuration, properties );
  if (configuration.getName() == null) {
    String sessionFactoryName = settings.getSessionFactoryName();
    if (sessionFactoryName != null) {
      configuration.setName( sessionFactoryName );
    }
    else {
      configuration.setName( "Hibernate " + settings.getUuid() );
    }
  }
}

代码示例来源:origin: org.springframework/spring-context-support

/**
 * Build an EhCache {@link CacheManager} from the given configuration resource.
 * @param name the desired name of the cache manager
 * @param configLocation the location of the configuration file (as a Spring resource)
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException {
  Configuration configuration = parseConfiguration(configLocation);
  configuration.setName(name);
  return new CacheManager(configuration);
}

代码示例来源:origin: org.springframework/spring-context-support

/**
 * Build an EhCache {@link CacheManager} from the default configuration.
 * <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path
 * (that is, default EhCache initialization - as defined in the EhCache docs - will apply).
 * If no configuration file can be found, a fail-safe fallback configuration will be used.
 * @param name the desired name of the cache manager
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name) throws CacheException {
  Configuration configuration = ConfigurationFactory.parseConfiguration();
  configuration.setName(name);
  return new CacheManager(configuration);
}

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

EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
if (this.cacheManagerName != null) {
  configuration.setName(this.cacheManagerName);

代码示例来源:origin: org.springframework/spring-context-support

EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
if (this.cacheManagerName != null) {
  configuration.setName(this.cacheManagerName);

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

/**
 * Builder to set the cache manager name.
 * <p>
 * Cache manager names have constraints on the characters they can use:
 * <ul>
 *     <li>cache managers that are registered as MBeans must obey the {@link javax.management.ObjectName} rules for unquoted value.
 *         This means the following characters are illegal: ',', '=', ':', '"', '*' and '?'.</li>
 * </ul>
 * Note that a clustered cache manager is by default registered as MBean.
 *
 * @see #setName(String)
 * @param name
 *            the name to set
 * @return this configuration instance
 */
public final Configuration name(String name) {
  setName(name);
  return this;
}

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

/**
   * Will overwrite the CacheManager name from the passed in configuration with the value of
   * net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory#NET_SF_EHCACHE_CACHE_MANAGER_NAME of the passed in Properties
   * @param configuration the configuration
   * @param properties the properties passed in from Hibernate
   * @return the configuration object passed in, only for convenience
   */
  static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Properties properties) {
    final String cacheManagerName = properties.getProperty(AbstractEhcacheRegionFactory.NET_SF_EHCACHE_CACHE_MANAGER_NAME);
    if (cacheManagerName != null) {
      configuration.setName(cacheManagerName);
    }
    return configuration;
  }
}

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

private String convertConfigurationToXMLString(net.sf.ehcache.config.Configuration configuration, String cacheManagerName, boolean stripCacheConfigs) {
 net.sf.ehcache.config.Configuration targetConfiguration = cloneConfiguration(configuration);
 targetConfiguration.setName(cacheManagerName);
 if (stripCacheConfigs) {
  targetConfiguration.getCacheConfigurations().clear();
 }
 return ConfigurationUtil.generateCacheManagerConfigurationText(targetConfiguration);
}

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

/**
 * Builder to set the cache manager name.
 *
 * @see #setName(String)
 * @param name
 *            the name to set
 * @return this configuration instance
 */
public final Configuration name(String name) {
  setName(name);
  return this;
}

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

/**
 * Builder to set the cache manager name.
 *
 * @see #setName(String)
 * @param name
 *            the name to set
 * @return this configuration instance
 */
public final Configuration name(String name) {
  setName(name);
  return this;
}

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

static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Map properties) {
  if (properties != null) {
    final String cacheManagerName = (String) properties.get( EHCACHE_CONFIGURATION_CACHE_MANAGER_NAME );
    if (cacheManagerName != null) {
      configuration.setName( cacheManagerName );
    }
  }
  return configuration;
}

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

/**
   * Will overwrite the CacheManager name from the passed in configuration with the value of
   * net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory#NET_SF_EHCACHE_CACHE_MANAGER_NAME of the passed in Properties
   * @param configuration the configuration
   * @param properties the properties passed in from Hibernate
   * @return the configuration object passed in, only for convenience
   */
  static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Properties properties) {
    final String cacheManagerName = properties.getProperty(AbstractEhcacheRegionFactory.NET_SF_EHCACHE_CACHE_MANAGER_NAME);
    if (cacheManagerName != null) {
      configuration.setName(cacheManagerName);
    }
    return configuration;
  }
}

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

static void setCacheManagerNameIfNeeded(SessionFactoryOptions settings, Configuration configuration, Map properties) {
  overwriteCacheManagerIfConfigured( configuration, properties );
  if (configuration.getName() == null) {
    String sessionFactoryName = settings.getSessionFactoryName();
    if (sessionFactoryName != null) {
      configuration.setName( sessionFactoryName );
    }
    else {
      configuration.setName( "Hibernate " + settings.getUuid() );
    }
  }
}

代码示例来源:origin: org.craftercms/crafter-core

/**
 * Default no-args constructor. Creates the {@code scopeManager} by calling the factory method
 * {@link net.sf.ehcache.CacheManager#newInstance(net.sf.ehcache.config.Configuration)}, because we want a
 * separate {@code CacheManager}, not the singleton one, since we don't want to the tick() method of a cache
 * implementation to be called on a CacheManager that doesn't have {@link CacheItem}s.
 */
public EhCacheStoreAdapter() {
  Configuration scopeManagerConfig = ConfigurationFactory.parseConfiguration();
  scopeManagerConfig.setName(SCOPE_MANAGER_NAME);
  scopeManager = CacheManager.newInstance(scopeManagerConfig);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Build an EhCache {@link CacheManager} from the given configuration resource.
 * @param name the desired name of the cache manager
 * @param configLocation the location of the configuration file (as a Spring resource)
 * @return the new EhCache CacheManager
 * @throws CacheException in case of configuration parsing failure
 */
public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException {
  Configuration configuration = parseConfiguration(configLocation);
  configuration.setName(name);
  return new CacheManager(configuration);
}

代码示例来源:origin: org.kantega.openaksess/openaksess-core

@Override
public void afterPropertiesSet() throws IOException, CacheException {
  InputStream is = XmlMerger.merge(OA_XML_CONFIG_FILE, PROJECT_XML_CONFIG_FILE, servletContext);
  Configuration configuration = ConfigurationFactory.parseConfiguration(is);
  String path = System.getProperty("java.io.tmpdir") + servletContext.getContextPath() + "/ehcache";
  configuration.addDiskStore(new DiskStoreConfiguration().path(path));
  configuration.setName(configuration.getName() + servletContext.getContextPath() + UUID.randomUUID());
  cacheManager = new CacheManager(configuration);
  createMBean();
}

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

相关文章

Configuration类方法