diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java
index 37ef1b40904..ffe9d294d9b 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
package org.springframework.beans.factory.xml;
+import org.w3c.dom.Document;
+
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.core.env.Environment;
-import org.w3c.dom.Document;
-
/**
* SPI for parsing an XML document that contains Spring bean definitions.
* Used by XmlBeanDefinitionReader for actually parsing a DOM document.
@@ -38,20 +38,21 @@ import org.w3c.dom.Document;
public interface BeanDefinitionDocumentReader {
/**
- * Read bean definitions from the given DOM document,
- * and register them with the given bean factory.
+ * Set the Environment to use when reading bean definitions.
+ *
Used for evaluating profile information to determine whether a
+ * {@code } document/element should be included or ignored.
+ */
+ void setEnvironment(Environment environment);
+
+ /**
+ * Read bean definitions from the given DOM document and
+ * register them with the registry in the given reader context.
* @param doc the DOM document
- * @param readerContext the current context of the reader. Includes the resource being parsed
+ * @param readerContext the current context of the reader
+ * (includes the target registry and the resource being parsed)
* @throws BeanDefinitionStoreException in case of parsing errors
*/
void registerBeanDefinitions(Document doc, XmlReaderContext readerContext)
throws BeanDefinitionStoreException;
- /**
- * Set the Environment to use when reading bean definitions. Used for evaluating
- * profile information to determine whether a {@code } document/element should
- * be included or omitted.
- */
- void setEnvironment(Environment environment);
-
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java
index 9900aa16517..a422d5b4fcd 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,16 +72,15 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
public static final String RESOURCE_ATTRIBUTE = "resource";
- /** @see org.springframework.context.annotation.Profile */
public static final String PROFILE_ATTRIBUTE = "profile";
protected final Log logger = LogFactory.getLog(getClass());
- private XmlReaderContext readerContext;
-
private Environment environment;
+ private XmlReaderContext readerContext;
+
private BeanDefinitionParserDelegate delegate;
@@ -104,13 +103,12 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
*/
public void registerBeanDefinitions(Document doc, XmlReaderContext readerContext) {
this.readerContext = readerContext;
-
logger.debug("Loading bean definitions");
Element root = doc.getDocumentElement();
-
doRegisterBeanDefinitions(root);
}
+
/**
* Register each bean definition within the given root {@code } element.
* @throws IllegalStateException if {@code elements will cause recursion in this method. In
+ // Any nested elements will cause recursion in this method. In
// order to propagate and preserve default-* attributes correctly,
// keep track of the current (parent) delegate, which may be null. Create
// the new (child) delegate with a reference to the parent for fallback purposes,
// then ultimately reset this.delegate back to its original (parent) reference.
// this behavior emulates a stack of delegates without actually necessitating one.
BeanDefinitionParserDelegate parent = this.delegate;
- this.delegate = createHelper(readerContext, root, parent);
+ this.delegate = createHelper(this.readerContext, root, parent);
preProcessXml(root);
parseBeanDefinitions(root, this.delegate);
@@ -143,7 +142,9 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
this.delegate = parent;
}
- protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
+ protected BeanDefinitionParserDelegate createHelper(
+ XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
+
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext, environment);
delegate.initDefaults(root, parentDelegate);
return delegate;