@Test public void testLoadConfigurationFromFileDistribution() throws Exception { File file = new File(TEST_CONFIG_DIR + "distribution/ehcache-distributed1.xml"); Configuration configuration = ConfigurationFactory.parseConfiguration(file); ConfigurationHelper configurationHelper = new ConfigurationHelper(manager, configuration); Map<String, CacheManagerPeerProvider> peerProviders = configurationHelper.createCachePeerProviders(); CacheManagerPeerProvider peerProvider = peerProviders.get("RMI"); assertTrue(peerProvider instanceof MulticastRMICacheManagerPeerProvider); assertEquals(Integer.valueOf(0), ((MulticastRMICacheManagerPeerProvider) peerProvider).getHeartBeatSender().getTimeToLive()); Map<String, CacheManagerPeerListener> peerListeners = configurationHelper.createCachePeerListeners(); for (CacheManagerPeerListener peerListener : peerListeners.values()) { assertTrue(peerListener instanceof RMICacheManagerPeerListener); } assertEquals(61, configurationHelper.createCaches().size()); Ehcache sampleCache1 = configurationHelper.createCacheFromName("sampleCache1"); Set listeners = sampleCache1.getCacheEventNotificationService().getCacheEventListeners(); assertEquals(2, listeners.size()); for (Iterator iterator = listeners.iterator(); iterator.hasNext();) { CacheEventListener cacheEventListener = (CacheEventListener) iterator.next(); assertTrue(cacheEventListener instanceof RMIAsynchronousCacheReplicator || cacheEventListener instanceof CountingCacheEventListener); } BootstrapCacheLoader bootstrapCacheLoader = sampleCache1.getBootstrapCacheLoader(); assertNotNull(bootstrapCacheLoader); assertEquals(RMIBootstrapCacheLoader.class, bootstrapCacheLoader.getClass()); assertEquals(true, bootstrapCacheLoader.isAsynchronous()); assertEquals(5000000, ((RMIBootstrapCacheLoader) bootstrapCacheLoader).getMaximumChunkSizeBytes()); }
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()); } } 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()); } } 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()); } } 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()); } } 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()); } } 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);  }