/** * Builder to set the configuration source. * * @return this configuration instance */ public final Configuration source(ConfigurationSource configurationSource) { setSource(configurationSource); return this; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Builder to set the configuration source. * * @return this configuration instance */ public final Configuration source(ConfigurationSource configurationSource) { setSource(configurationSource); return this; }
/** * Builder to set the configuration source. * * @return this configuration instance */ public final Configuration source(ConfigurationSource configurationSource) { setSource(configurationSource); return this; }
/** * Builder to set the configuration source. * * @return this configuration instance */ public final Configuration source(ConfigurationSource configurationSource) { setSource(configurationSource); return this; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
@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); }