@Test(expected = IllegalArgumentException.class) public void testCtorWhereEntityResolversAreBothNull() throws Exception { new DelegatingEntityResolver(null, null); }
@Override @Nullable public InputSource resolveEntity(String publicId, @Nullable String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (source == null && systemId != null) { String resourcePath = null;
/** * Return the EntityResolver to use, building a default resolver * if none specified. */ protected EntityResolver getEntityResolver() { if (this.entityResolver == null) { // Determine default EntityResolver to use. ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader != null) { this.entityResolver = new ResourceEntityResolver(resourceLoader); } else { this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader()); } } return this.entityResolver; }
@Override @Nullable public InputSource resolveEntity(String publicId, @Nullable String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (source == null && systemId != null) { String resourcePath = null;
/** * Return the EntityResolver to use, building a default resolver * if none specified. */ protected EntityResolver getEntityResolver() { if (this.entityResolver == null) { // Determine default EntityResolver to use. ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader != null) { this.entityResolver = new ResourceEntityResolver(resourceLoader); } else { this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader()); } } return this.entityResolver; }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (source == null && systemId != null) { String resourcePath = null;
private Document getDocument(String location) { InputStream inputStream = this.getClass().getResourceAsStream(location); try { return documentLoader.loadDocument(new InputSource(inputStream), new DelegatingEntityResolver(getClass().getClassLoader()), errorHandler, 0, true); } catch (Exception e) { throw new RuntimeException(e); } finally { try { inputStream.close(); } catch (IOException e) { } } }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (null == source && null != systemId) { // try the schema and dtd resolver in turn, ignoring the suffix in publicId LOG.log(Level.FINE, "Attempting to resolve systemId {0}", systemId); source = schemaResolver.resolveEntity(publicId, systemId); if (null == source) { source = dtdResolver.resolveEntity(publicId, systemId); } if (null == source) { return null; } } String resourceLocation = schemaMappings.get(systemId); if (resourceLocation != null && publicId == null) { Resource resource = new ClassPathResource(resourceLocation, classLoader); if (resource.exists()) { source.setPublicId(systemId); source.setSystemId(resource.getURL().toString()); } } return source; } }
@Test(expected = IllegalArgumentException.class) public void testCtorWhereDtdEntityResolverIsNull() throws Exception { new DelegatingEntityResolver(null, new NoOpEntityResolver()); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (null == source && null != systemId) { // try the schema and dtd resolver in turn, ignoring the suffix in publicId LOG.log(Level.FINE, "Attempting to resolve systemId {0}", systemId); source = schemaResolver.resolveEntity(publicId, systemId); if (null == source) { source = dtdResolver.resolveEntity(publicId, systemId); } } String resourceLocation = schemaMappings.get(systemId); if (resourceLocation != null && publicId == null) { Resource resource = new ClassPathResource(resourceLocation, classLoader); if (resource != null && resource.exists()) { source.setPublicId(systemId); source.setSystemId(resource.getURL().toString()); } } return source; } }
@Test(expected = IllegalArgumentException.class) public void testCtorWhereSchemaEntityResolverIsNull() throws Exception { new DelegatingEntityResolver(new NoOpEntityResolver(), null); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (null == source && null != systemId) { // try the schema and dtd resolver in turn, ignoring the suffix in publicId LOG.log(Level.FINE, "Attempting to resolve systemId {0}", systemId); source = schemaResolver.resolveEntity(publicId, systemId); if (null == source) { source = dtdResolver.resolveEntity(publicId, systemId); } } String resourceLocation = schemaMappings.get(systemId); if (resourceLocation != null && publicId == null) { Resource resource = new ClassPathResource(resourceLocation, classLoader); if (resource != null && resource.exists()) { source.setPublicId(systemId); source.setSystemId(resource.getURL().toString()); } } return source; } }
/** * Return the EntityResolver to use, building a default resolver * if none specified. */ protected EntityResolver getEntityResolver() { if (this.entityResolver == null) { // Determine default EntityResolver to use. ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader != null) { this.entityResolver = new ResourceEntityResolver(resourceLoader); } else { this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader()); } } return this.entityResolver; }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (source == null && systemId != null) { String resourcePath = null;
private Plugin(Bundle bundle) { this.bundle = bundle; ClassLoader loader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle); entity = new DelegatingEntityResolver(loader); namespace = new DefaultNamespaceHandlerResolver(loader); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { InputSource source = super.resolveEntity(publicId, systemId); if (null == source && null != systemId) { // try the schema and dtd resolver in turn, ignoring the suffix in publicId LOG.log(Level.FINE, "Attempting to resolve systemId {0}", systemId); source = schemaResolver.resolveEntity(publicId, systemId); if (null == source) { source = dtdResolver.resolveEntity(publicId, systemId); } if (null == source) { return null; } } String resourceLocation = schemaMappings.get(systemId); if (resourceLocation != null && publicId == null) { Resource resource = new ClassPathResource(resourceLocation, classLoader); if (resource.exists()) { source.setPublicId(systemId); source.setSystemId(resource.getURL().toString()); } } return source; } }
private Plugin(Bundle bundle) { this.bundle = bundle; ClassLoader loader = BundleDelegatingClassLoader.createBundleClassLoaderFor(bundle); entity = new DelegatingEntityResolver(loader); namespace = new DefaultNamespaceHandlerResolver(loader); }
/** * Creates an {@link EntityResolver} the same way Spring's * {@link XmlBeanDefinitionReader} would create it. It has to be created * here because the {@link EntityResolver} created by * {@link XmlBeanDefinitionReader} is not accessible from this class. * * @return * @see XmlBeanDefinitionReader#XmlBeanDefinitionReader(BeanDefinitionRegistry) */ protected EntityResolver createSpringEntityResolver() { EntityResolver springEntityResolver = null; // Determine EntityResolver to use. if (getResourceLoader() != null) { springEntityResolver = new ResourceEntityResolver(getResourceLoader()); } else { springEntityResolver = new DelegatingEntityResolver(ClassUtils.getDefaultClassLoader()); } return springEntityResolver; }
/** * Return the EntityResolver to use, building a default resolver * if none specified. */ protected EntityResolver getEntityResolver() { if (this.entityResolver == null) { // Determine default EntityResolver to use. ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader != null) { this.entityResolver = new ResourceEntityResolver(resourceLoader); } else { this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader()); } } return this.entityResolver; }
/** * Creates a {@link Document} from an {@link InputStream} with the required configuration of a mule configuration file parsing. * * @param extensions if the current {@code inputStream} relies in other schemas pending to be loaded from an * {@link ExtensionModel}, it will be picked up from {@code extensions} set * @param filename name of the file to display a better error messages (if there are any). Non null. * @param inputStream the input stream with the XML configuration content. * @return a new {@link Document} object with the provided content. * @throws MuleRuntimeException if an error occurs in {@link org.springframework.beans.factory.xml.DocumentLoader} factory, or * if the current {@code filename} contains 1 or more errors. * @see {@link DefaultXmlLoggerErrorHandler#getErrors()} */ public Document loadDocument(Set<ExtensionModel> extensions, String filename, InputStream inputStream) { final XmlGathererErrorHandler errorHandler = createXmlGathererErrorHandler(); Document document; try { document = new MuleDocumentLoader() .loadDocument(new InputSource(inputStream), validationMode == VALIDATION_XSD ? new ModuleDelegatingEntityResolver(extensions) : new DelegatingEntityResolver(currentThread().getContextClassLoader()), errorHandler == null ? new DefaultHandler() : errorHandler, validationMode, true); } catch (Exception e) { throw new MuleRuntimeException(createStaticMessage(format("Error loading: %s, %s", filename, e.getMessage())), e); } if (validationMode == VALIDATION_XSD) { throwExceptionIfErrorsWereFound(errorHandler, filename); } return document; }