@Test public void testLoadConfigurationFromFileCountingCacheListener() throws Exception { File file = new File(TEST_CONFIG_DIR + "ehcache-countinglisteners.xml"); Configuration configuration = ConfigurationFactory.parseConfiguration(file); ConfigurationHelper configurationHelper = new ConfigurationHelper(manager, configuration); Class actualClass = configurationHelper.createCacheManagerEventListener(null).getClass(); assertEquals(CountingCacheManagerEventListener.class, actualClass); assertEquals(10, configurationHelper.createCaches().size()); Ehcache sampleCache1 = configurationHelper.createCacheFromName("sampleCache1"); Set registeredListeners = sampleCache1.getCacheEventNotificationService().getCacheEventListeners(); assertEquals(2, registeredListeners.size()); Ehcache sampleCache2 = configurationHelper.createCacheFromName("sampleCache2"); registeredListeners = sampleCache2.getCacheEventNotificationService().getCacheEventListeners(); assertEquals(1, registeredListeners.size()); Ehcache sampleCache3 = configurationHelper.createCacheFromName("sampleCache3"); registeredListeners = sampleCache3.getCacheEventNotificationService().getCacheEventListeners(); assertEquals(1, registeredListeners.size()); Ehcache footerPageCache = configurationHelper.createCacheFromName("FooterPageCache"); registeredListeners = footerPageCache.getCacheEventNotificationService().getCacheEventListeners(); assertEquals(0, registeredListeners.size()); Ehcache persistentLongExpiryIntervalCache = configurationHelper.createCacheFromName("persistentLongExpiryIntervalCache"); registeredListeners = persistentLongExpiryIntervalCache.getCacheEventNotificationService() .getCacheEventListeners(); assertEquals(1, registeredListeners.size()); }
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; }
ConfigurationFactory { 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; } }
ConfigurationFactory { 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; } private  ConfigurationFactory(); }
ConfigurationFactory { 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; } private  ConfigurationFactory(); static Configuration parseConfiguration(final File file); static Configuration parseConfiguration(final URL url); static Configuration parseConfiguration(); static Configuration parseConfiguration(final InputStream inputStream); }
ConfigurationFactory { 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; } private  ConfigurationFactory(); static Configuration parseConfiguration(final File file); static Configuration parseConfiguration(final URL url); static Configuration parseConfiguration(); static Configuration parseConfiguration(final InputStream inputStream);  }