/** * Return the environment to use. * @see XmlBeanDefinitionReader#setEnvironment */ public final Environment getEnvironment() { return this.reader.getEnvironment(); }
/** * Return the environment to use. * @see XmlBeanDefinitionReader#setEnvironment */ public final Environment getEnvironment() { return this.reader.getEnvironment(); }
private int load(CharSequence source) { String resolvedSource = this.xmlReader.getEnvironment() .resolvePlaceholders(source.toString()); // Attempt as a Class try { return load(ClassUtils.forName(resolvedSource, null)); } catch (IllegalArgumentException | ClassNotFoundException ex) { // swallow exception and continue } // Attempt as resources Resource[] resources = findResources(resolvedSource); int loadCount = 0; boolean atLeastOneResourceExists = false; for (Resource resource : resources) { if (isLoadCandidate(resource)) { atLeastOneResourceExists = true; loadCount += load(resource); } } if (atLeastOneResourceExists) { return loadCount; } // Attempt as package Package packageResource = findPackage(resolvedSource); if (packageResource != null) { return load(packageResource); } throw new IllegalArgumentException("Invalid source '" + resolvedSource + "'"); }
/** * Register the bean definitions contained in the given DOM document. * Called by <code>loadBeanDefinitions</code>. * <p>Creates a new instance of the parser class and invokes * <code>registerBeanDefinitions</code> on it. * @param doc the DOM document * @param resource the resource descriptor (for context information) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of parsing errors * @see #loadBeanDefinitions * @see #setDocumentReaderClass * @see BeanDefinitionDocumentReader#registerBeanDefinitions */ public int registerBeanDefinitions(Document doc, Resource resource) throws BeanDefinitionStoreException { BeanDefinitionDocumentReader documentReader = createBeanDefinitionDocumentReader(); documentReader.setEnvironment(this.getEnvironment()); int countBefore = getRegistry().getBeanDefinitionCount(); documentReader.registerBeanDefinitions(doc, createReaderContext(resource)); return getRegistry().getBeanDefinitionCount() - countBefore; }
public final Environment getEnvironment() { return this.reader.getEnvironment(); }