Source:
public XmlConfigurationWrapper documentToConfig(Document document, ClassLoader classLoader, Map<String, ClassLoader> cacheClassLoaders) throws JAXBException, ClassNotFoundException, InstantiationException, IllegalAccessException { substituteSystemProperties(document); Element root = document.getDocumentElement(); QName rootName = new QName(root.getNamespaceURI(), root.getLocalName()); if (!CORE_SCHEMA_ROOT_NAME.equals(rootName)) { throw new XmlConfigurationException("Expecting " + CORE_SCHEMA_ROOT_NAME + " element; found " + rootName); } Class<ConfigType> configTypeClass = ConfigType.class; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ConfigType jaxbModel = unmarshaller.unmarshal(document, configTypeClass).getValue(); ConfigurationBuilder managerBuilder = newConfigurationBuilder().withClassLoader(classLoader); managerBuilder = serviceCreationConfigurationParser.parseServiceCreationConfiguration(jaxbModel, classLoader, managerBuilder); for (CacheDefinition cacheDefinition : getCacheElements(jaxbModel)) { String alias = cacheDefinition.id(); if(managerBuilder.containsCache(alias)) { throw new XmlConfigurationException("Two caches defined with the same alias: " + alias); } ClassLoader cacheClassLoader = cacheClassLoaders.get(alias); boolean classLoaderConfigured = false; if (cacheClassLoader != null) { classLoaderConfigured = true; } if (cacheClassLoader == null) { if (classLoader != null) { cacheClassLoader = classLoader; } else { cacheClassLoader = ClassLoading.getDefaultClassLoader(); } } Class<?> keyType = getClassForName(cacheDefinition.keyType(), cacheClassLoader); Class<?> valueType = getClassForName(cacheDefinition.valueType(), cacheClassLoader); ResourcePools resourcePools = resourceConfigurationParser.parseResourceConfiguration(cacheDefinition, newResourcePoolsBuilder()); CacheConfigurationBuilder<?, ?> cacheBuilder = newCacheConfigurationBuilder(keyType, valueType, resourcePools); if (classLoaderConfigured) { cacheBuilder = cacheBuilder.withClassLoader(cacheClassLoader); } cacheBuilder = parseServiceConfigurations(cacheBuilder, cacheClassLoader, cacheDefinition); managerBuilder = managerBuilder.addCache(alias, cacheBuilder.build()); } Map<String, XmlConfiguration.Template> templates = getTemplates(jaxbModel); return new XmlConfigurationWrapper(managerBuilder.build(), templates); }

Target:
public XmlConfigurationWrapper documentToConfig(Document document, ClassLoader classLoader, Map<String, ClassLoader> cacheClassLoaders) throws JAXBException, ClassNotFoundException, InstantiationException, IllegalAccessException { substituteSystemProperties(document); Element root = document.getDocumentElement(); QName rootName = new QName(root.getNamespaceURI(), root.getLocalName()); if (!CORE_SCHEMA_ROOT_NAME.equals(rootName)) { throw new XmlConfigurationException("Expecting " + CORE_SCHEMA_ROOT_NAME + " element; found " + rootName); } Class<ConfigType> configTypeClass = ConfigType.class; Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); ConfigType jaxbModel = unmarshaller.unmarshal(document, configTypeClass).getValue(); ConfigurationBuilder managerBuilder = newConfigurationBuilder().withClassLoader(classLoader); managerBuilder = serviceCreationConfigurationParser.parseServiceCreationConfiguration(jaxbModel, classLoader, managerBuilder); for (CacheDefinition cacheDefinition : getCacheElements(jaxbModel)) { String alias = cacheDefinition.id(); if(managerBuilder.containsCache(alias)) { throw new XmlConfigurationException("Two caches defined with the same alias: " + alias); } ClassLoader cacheClassLoader = cacheClassLoaders.get(alias); boolean classLoaderConfigured = cacheClassLoader != null; if (cacheClassLoader == null) { if (classLoader != null) { cacheClassLoader = classLoader; } else { cacheClassLoader = ClassLoading.getDefaultClassLoader(); } } Class<?> keyType = getClassForName(cacheDefinition.keyType(), cacheClassLoader); Class<?> valueType = getClassForName(cacheDefinition.valueType(), cacheClassLoader); ResourcePools resourcePools = resourceConfigurationParser.parseResourceConfiguration(cacheDefinition, newResourcePoolsBuilder()); CacheConfigurationBuilder<?, ?> cacheBuilder = newCacheConfigurationBuilder(keyType, valueType, resourcePools); if (classLoaderConfigured) { cacheBuilder = cacheBuilder.withClassLoader(cacheClassLoader); } cacheBuilder = parseServiceConfigurations(cacheBuilder, cacheClassLoader, cacheDefinition); managerBuilder = managerBuilder.addCache(alias, cacheBuilder.build()); } Map<String, XmlConfiguration.Template> templates = getTemplates(jaxbModel); return new XmlConfigurationWrapper(managerBuilder.build(), templates); }