@Override public void init() { registerBeanDefinitionParser("constant", new ConstantBeanDefinitionParser()); registerBeanDefinitionParser("property-path", new PropertyPathBeanDefinitionParser()); registerBeanDefinitionParser("list", new ListBeanDefinitionParser()); registerBeanDefinitionParser("set", new SetBeanDefinitionParser()); registerBeanDefinitionParser("map", new MapBeanDefinitionParser()); registerBeanDefinitionParser("properties", new PropertiesBeanDefinitionParser()); }
/** * Create the {@link XmlReaderContext} to pass over to the document reader. */ public XmlReaderContext createReaderContext(Resource resource) { return new XmlReaderContext(resource, this.problemReporter, this.eventListener, this.sourceExtractor, this, getNamespaceHandlerResolver()); }
/** * Actually load the specified document using the configured DocumentLoader. * @param inputSource the SAX InputSource to read from * @param resource the resource descriptor for the XML file * @return the DOM Document * @throws Exception when thrown from the DocumentLoader * @see #setDocumentLoader * @see DocumentLoader#loadDocument */ protected Document doLoadDocument(InputSource inputSource, Resource resource) throws Exception { return this.documentLoader.loadDocument(inputSource, getEntityResolver(), this.errorHandler, getValidationModeForResource(resource), isNamespaceAware()); }
/** * Load the bean definitions into the given registry, * based on the specified configuration files. * @param registry the registry to load into * @param configLocations the parsed config locations * @see #setContextConfigLocation */ protected void loadBeanDefinitions(BeanDefinitionRegistry registry, String[] configLocations) { new XmlBeanDefinitionReader(registry).loadBeanDefinitions(configLocations); }
/** * Load bean definitions from the given XML resources. * @param resourceLocations one or more resource locations to load from */ public void load(String... resourceLocations) { this.reader.loadBeanDefinitions(resourceLocations); }
/** * Create a new {@code GroovyBeanDefinitionReader} for the given * {@link BeanDefinitionRegistry}. * @param registry the {@code BeanDefinitionRegistry} to load bean definitions into */ public GroovyBeanDefinitionReader(BeanDefinitionRegistry registry) { super(registry); this.standardXmlBeanDefinitionReader = new XmlBeanDefinitionReader(registry); this.groovyDslXmlBeanDefinitionReader = new XmlBeanDefinitionReader(registry); this.groovyDslXmlBeanDefinitionReader.setValidating(false); }
@Nullable public BeanDefinition parseCustomElement(Element ele, @Nullable BeanDefinition containingBd) { String namespaceUri = getNamespaceURI(ele); if (namespaceUri == null) { return null; } NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri); if (handler == null) { error("Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]", ele); return null; } return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd)); }
/** * Set whether to use XML validation. Default is {@code true}. */ public void setValidating(boolean validating) { this.reader.setValidating(validating); }
/** * Initialize the default settings assuming a {@code null} parent delegate. */ public void initDefaults(Element root) { initDefaults(root, null); }
/** * Initialize the default lazy-init, autowire, dependency check settings, * init-method, destroy-method and merge settings. Support nested 'beans' * element use cases by falling back to the given parent in case the * defaults are not explicitly set locally. * @see #populateDefaults(DocumentDefaultsDefinition, DocumentDefaultsDefinition, org.w3c.dom.Element) * @see #getDefaults() */ public void initDefaults(Element root, @Nullable BeanDefinitionParserDelegate parent) { populateDefaults(this.defaults, (parent != null ? parent.defaults : null), root); this.readerContext.fireDefaultsRegistered(this.defaults); }
/** * Lazily create a default NamespaceHandlerResolver, if not set before. * @see #createDefaultNamespaceHandlerResolver() */ public NamespaceHandlerResolver getNamespaceHandlerResolver() { if (this.namespaceHandlerResolver == null) { this.namespaceHandlerResolver = createDefaultNamespaceHandlerResolver(); } return this.namespaceHandlerResolver; }
/** * Return the environment to use. * @see XmlBeanDefinitionReader#setEnvironment */ public final Environment getEnvironment() { return this.reader.getEnvironment(); }
/** * Note that overloaded methods are supported. */ public static FactoryMethods newInstance(TestBean tb) { return new FactoryMethods(tb, "default", 0); }
@Override public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { if (bean instanceof ProtectedLifecycleBean) { ((ProtectedLifecycleBean) bean).postProcessBeforeInit(); } return bean; }
/** * Note that overloaded methods are supported. */ public FactoryMethods newInstance(TestBean tb) { return FactoryMethods.newInstance(tb); }
/** * Create a new XmlBeanFactory with the given input stream, * which must be parsable using DOM. * @param resource the XML resource to load bean definitions from * @param parentBeanFactory parent bean factory * @throws BeansException in case of loading or parsing errors */ public XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory) throws BeansException { super(parentBeanFactory); this.reader.loadBeanDefinitions(resource); }
/** * Note that overloaded methods are supported. */ public static FactoryMethods newInstance(TestBean tb) { return new FactoryMethods(tb, "default", 0); }
/** * Load bean definitions from the specified XML file. * @param inputSource the SAX InputSource to read from * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ public int loadBeanDefinitions(InputSource inputSource) throws BeanDefinitionStoreException { return loadBeanDefinitions(inputSource, "resource loaded through SAX InputSource"); }
/** * Load bean definitions from the given XML resources. * @param resources one or more resources to load from */ public void load(Resource... resources) { this.reader.loadBeanDefinitions(resources); }