Source:
public void init() { final StatusTransitioner.Transition st = statusTransitioner.init(); LOGGER.info("Initializing EhcacheManager."); try { Map<Service, ServiceConfiguration<?>> serviceConfigs = new HashMap<Service, ServiceConfiguration<?>>(); for (ServiceConfiguration<?> serviceConfig : configuration.getServiceConfigurations()) { Service service = serviceLocator.discoverService(serviceConfig); if(service == null) { service = serviceLocator.findService(serviceConfig.getServiceType()); } if (service == null) { throw new IllegalArgumentException("Couldn't resolve Service " + serviceConfig.getServiceType().getName()); } serviceConfigs.put(service, serviceConfig); } try { serviceLocator.startAllServices(serviceConfigs); } catch (Exception e) { st.failed(); LOGGER.error("Initialization of EhcacheManager failed while starting Services."); throw new StateTransitionException(e); } Deque<String> initiatedCaches = new ArrayDeque<String>(); try { for (Entry<String, CacheConfiguration<?, ?>> cacheConfigurationEntry : configuration.getCacheConfigurations() .entrySet()) { final String alias = cacheConfigurationEntry.getKey(); createCache(alias, cacheConfigurationEntry.getValue()); initiatedCaches.push(alias); } } catch (RuntimeException e) { while (!initiatedCaches.isEmpty()) { String toBeClosed = initiatedCaches.pop(); try { removeCache(toBeClosed); } catch (Exception exceptionClosingCache) { LOGGER.error("Cache '"+toBeClosed+"' could not be removed due to "+ exceptionClosingCache.getMessage()); } } throw e; } } catch (RuntimeException e) { st.failed(); LOGGER.error("Initialization of EhcacheManager failed while initiating Caches."); throw new StateTransitionException(e); } st.succeeded(); LOGGER.info("Initialization of EhcacheManager succeeded."); }

Target:
public void init() { final StatusTransitioner.Transition st = statusTransitioner.init(); LOGGER.info("Initializing EhcacheManager."); try { Map<Service, ServiceConfiguration<?>> serviceConfigs = new HashMap<Service, ServiceConfiguration<?>>(); for (ServiceConfiguration<?> serviceConfig : configuration.getServiceConfigurations()) { Service service = serviceLocator.discoverService(serviceConfig); if(service == null) { service = serviceLocator.findService(serviceConfig.getServiceType()); } if (service == null) { throw new IllegalArgumentException("Couldn't resolve Service " + serviceConfig.getServiceType().getName()); } serviceConfigs.put(service, serviceConfig); } try { serviceLocator.startAllServices(serviceConfigs); } catch (Exception e) { st.failed(); LOGGER.error("Initialization of EhcacheManager failed while starting Services."); throw new StateTransitionException(e); } Deque<String> initiatedCaches = new ArrayDeque<String>(); try { for (Entry<String, CacheConfiguration<?, ?>> cacheConfigurationEntry : configuration.getCacheConfigurations() .entrySet()) { final String alias = cacheConfigurationEntry.getKey(); createCache(alias, cacheConfigurationEntry.getValue()); initiatedCaches.push(alias); } } catch (RuntimeException e) { while (!initiatedCaches.isEmpty()) { String toBeClosed = initiatedCaches.pop(); try { removeCache(toBeClosed); } catch (Exception exceptionClosingCache) { LOGGER.error("Cache '{}' could not be removed due to ", toBeClosed, exceptionClosingCache); } } throw e; } } catch (RuntimeException e) { st.failed(); LOGGER.error("Initialization of EhcacheManager failed while initiating Caches."); throw new StateTransitionException(e); } st.succeeded(); LOGGER.info("Initialization of EhcacheManager succeeded."); }