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

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

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

Configuration.setSource介绍

[英]Sets the configuration source.
[中]

代码示例

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

/**
 * Builder to set the configuration source.
 *
 * @return this configuration instance
 */
public final Configuration source(ConfigurationSource configurationSource) {
  setSource(configurationSource);
  return this;
}

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

/**
 * Configures a bean from an XML file in the classpath.
 */
public static Configuration parseConfiguration() throws CacheException {
  ClassLoader standardClassloader = Thread.currentThread().getContextClassLoader();
  URL url = null;
  if (standardClassloader != null) {
    url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url == null) {
    url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url != null) {
    LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url);
  } else {
    url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE);
    LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml "
        + " found in the classpath: {}", url);
  }
  Configuration configuration = parseConfiguration(url);
  configuration.setSource(ConfigurationSource.getConfigurationSource());
  return configuration;
}

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

/**
 * Configures a bean from an XML file available as an URL.
 */
public static Configuration parseConfiguration(final URL url) throws CacheException {
  LOG.debug("Configuring ehcache from URL: {}", url);
  Configuration configuration;
  InputStream input = null;
  try {
    input = url.openStream();
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + url + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(url));
  return configuration;
}

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

/**
 * Configures a bean from an XML file.
 */
public static Configuration parseConfiguration(final File file) throws CacheException {
  if (file == null) {
    throw new CacheException("Attempt to configure ehcache from null file.");
  }
  LOG.debug("Configuring ehcache from file: {}", file);
  Configuration configuration = null;
  InputStream input = null;
  try {
    input = new BufferedInputStream(new FileInputStream(file));
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(file));
  return configuration;
}

代码示例来源: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.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Builder to set the configuration source.
 *
 * @return this configuration instance
 */
public final Configuration source(ConfigurationSource configurationSource) {
  setSource(configurationSource);
  return this;
}

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

/**
 * Builder to set the configuration source.
 *
 * @return this configuration instance
 */
public final Configuration source(ConfigurationSource configurationSource) {
  setSource(configurationSource);
  return this;
}

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

/**
 * Builder to set the configuration source.
 *
 * @return this configuration instance
 */
public final Configuration source(ConfigurationSource configurationSource) {
  setSource(configurationSource);
  return this;
}

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

/**
 * Configures a bean from an XML file in the classpath.
 */
public static Configuration parseConfiguration() throws CacheException {
  ClassLoader standardClassloader = Thread.currentThread().getContextClassLoader();
  URL url = null;
  if (standardClassloader != null) {
    url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url == null) {
    url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url != null) {
    LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url);
  } else {
    url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE);
    LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml "
        + " found in the classpath: {}", url);
  }
  Configuration configuration = parseConfiguration(url);
  configuration.setSource(ConfigurationSource.getConfigurationSource());
  return configuration;
}

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

/**
 * Configures a bean from an XML file in the classpath.
 */
public static Configuration parseConfiguration() throws CacheException {
  ClassLoader standardClassloader = Thread.currentThread().getContextClassLoader();
  URL url = null;
  if (standardClassloader != null) {
    url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url == null) {
    url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url != null) {
    LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url);
  } else {
    url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE);
    LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml "
        + " found in the classpath: {}", url);
  }
  Configuration configuration = parseConfiguration(url);
  configuration.setSource(ConfigurationSource.getConfigurationSource());
  return configuration;
}

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

/**
 * Configures a bean from an XML file available as an URL.
 */
public static Configuration parseConfiguration(final URL url) throws CacheException {
  LOG.debug("Configuring ehcache from URL: {}", url);
  Configuration configuration;
  InputStream input = null;
  try {
    input = url.openStream();
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + url + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(url));
  return configuration;
}

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

/**
 * Configures a bean from an XML file available as an URL.
 */
public static Configuration parseConfiguration(final URL url) throws CacheException {
  LOG.debug("Configuring ehcache from URL: {}", url);
  Configuration configuration;
  InputStream input = null;
  try {
    input = url.openStream();
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + url + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(url));
  return configuration;
}

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

/**
 * Configures a bean from an XML file available as an URL.
 */
public static Configuration parseConfiguration(final URL url) throws CacheException {
  LOG.debug("Configuring ehcache from URL: {}", url);
  Configuration configuration;
  InputStream input = null;
  try {
    input = url.openStream();
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + url + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(url));
  return configuration;
}

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

/**
 * Configures a bean from an XML file in the classpath.
 */
public static Configuration parseConfiguration() throws CacheException {
  ClassLoader standardClassloader = ClassLoaderUtil.getStandardClassLoader();
  URL url = null;
  if (standardClassloader != null) {
    url = standardClassloader.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url == null) {
    url = ConfigurationFactory.class.getResource(DEFAULT_CLASSPATH_CONFIGURATION_FILE);
  }
  if (url != null) {
    LOG.debug("Configuring ehcache from ehcache.xml found in the classpath: " + url);
  } else {
    url = ConfigurationFactory.class.getResource(FAILSAFE_CLASSPATH_CONFIGURATION_FILE);
    LOG.warn("No configuration found. Configuring ehcache from ehcache-failsafe.xml "
        + " found in the classpath: {}", url);
  }
  Configuration configuration = parseConfiguration(url);
  configuration.setSource(ConfigurationSource.getConfigurationSource());
  return configuration;
}

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

/**
 * Configures a bean from an XML file.
 */
public static Configuration parseConfiguration(final File file) throws CacheException {
  if (file == null) {
    throw new CacheException("Attempt to configure ehcache from null file.");
  }
  LOG.debug("Configuring ehcache from file: {}", file);
  Configuration configuration = null;
  InputStream input = null;
  try {
    input = new BufferedInputStream(new FileInputStream(file));
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(file));
  return 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 file.
 */
public static Configuration parseConfiguration(final File file) throws CacheException {
  if (file == null) {
    throw new CacheException("Attempt to configure ehcache from null file.");
  }
  LOG.debug("Configuring ehcache from file: {}", file);
  Configuration configuration = null;
  InputStream input = null;
  try {
    input = new BufferedInputStream(new FileInputStream(file));
    configuration = parseConfiguration(input);
  } catch (Exception e) {
    throw new CacheException("Error configuring from " + file + ". Initial cause was " + e.getMessage(), e);
  } finally {
    try {
      if (input != null) {
        input.close();
      }
    } catch (IOException e) {
      LOG.error("IOException while closing configuration input stream. Error was " + e.getMessage());
    }
  }
  configuration.setSource(ConfigurationSource.getConfigurationSource(file));
  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: 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: 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类方法