|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser
public class DefaultXmlBeanDefinitionParser
Default implementation of the XmlBeanDefinitionParser
interface.
Parses bean definitions according to the "spring-beans" DTD,
that is, Spring's default XML bean definition format.
The structure, elements and attribute names of the required XML document
are hard-coded in this class. (Of course a transform could be run if necessary
to produce this format). <beans>
doesn't need to be the root
element of the XML document: This class will parse all bean definition elements
in the XML file, not regarding the actual root element.
Constructor Summary | |
---|---|
DefaultXmlBeanDefinitionParser()
|
Method Summary | |
---|---|
protected int |
getAutowireMode(String att)
|
protected BeanDefinitionReader |
getBeanDefinitionReader()
Return the BeanDefinitionReader that this parser has been called from. |
protected String |
getDefaultAutowire()
Return the default autowire setting for the document that's currently parsed. |
protected String |
getDefaultDependencyCheck()
Return the default dependency-check setting for the document that's currently parsed. |
protected String |
getDefaultDestroyMethod()
Return the default destroy-method setting for the document that's currently parsed. |
protected String |
getDefaultInitMethod()
Return the default init-method setting for the document that's currently parsed. |
protected String |
getDefaultLazyInit()
Return the default lazy-init flag for the document that's currently parsed. |
protected int |
getDependencyCheck(String att)
|
protected Resource |
getResource()
Return the descriptor for the XML resource that this parser works on. |
protected void |
importBeanDefinitionResource(Element ele)
Parse an "import" element and load the bean definitions from the given resource into the bean factory. |
protected void |
initDefaults(Element root)
Initialize the default lazy-init, autowire and dependency check settings. |
protected BeanDefinitionHolder |
parseBeanDefinitionElement(Element ele,
boolean isInnerBean)
Parse a standard bean definition into a BeanDefinitionHolder, including bean name and aliases. |
protected BeanDefinition |
parseBeanDefinitionElement(Element ele,
String beanName)
Parse the BeanDefinition itself, without regard to name or aliases. |
protected int |
parseBeanDefinitions(Element root)
Parse the elements at the root level in the document: "import", "alias", "bean". |
protected void |
parseConstructorArgElement(Element ele,
String beanName,
ConstructorArgumentValues cargs)
Parse a constructor-arg element. |
protected ConstructorArgumentValues |
parseConstructorArgElements(Element beanEle,
String beanName)
Parse constructor-arg sub-elements of the given bean element. |
protected Object |
parseKeyElement(Element keyEle,
String beanName)
Parse a key sub-element of a map element. |
protected List |
parseListElement(Element collectionEle,
String beanName)
Parse a list element. |
protected void |
parseLookupOverrideSubElements(Element beanEle,
String beanName,
MethodOverrides overrides)
Parse lookup-override sub-elements of the given bean element. |
protected Map |
parseMapElement(Element mapEle,
String beanName)
Parse a map element. |
protected void |
parsePropertyElement(Element ele,
String beanName,
MutablePropertyValues pvs)
Parse a property element. |
protected MutablePropertyValues |
parsePropertyElements(Element beanEle,
String beanName)
Parse property sub-elements of the given bean element. |
protected Object |
parsePropertySubElement(Element ele,
String beanName)
Parse a value, ref or collection sub-element of a property or constructor-arg element. |
protected Object |
parsePropertyValue(Element ele,
String beanName,
String propertyName)
Get the value of a property element. |
protected Properties |
parsePropsElement(Element propsEle,
String beanName)
Parse a props element. |
protected void |
parseReplacedMethodSubElements(Element beanEle,
String beanName,
MethodOverrides overrides)
Parse replaced-method sub-elements of the given bean element. |
protected Set |
parseSetElement(Element collectionEle,
String beanName)
Parse a set element. |
protected void |
postProcessXml(Element root)
Allow the XML to be extensible by processing any custom element types last, after we finished processing the bean definitions. |
protected void |
preProcessXml(Element root)
Allow the XML to be extensible by processing any custom element types first, before we start to process the bean definitions. |
int |
registerBeanDefinitions(BeanDefinitionReader reader,
Document doc,
Resource resource)
Parses bean definitions according to the "spring-beans" DTD. |
protected void |
setDefaultAutowire(String defaultAutowire)
Set the default autowire setting for the document that's currently parsed. |
protected void |
setDefaultDependencyCheck(String defaultDependencyCheck)
Set the default dependency-check setting for the document that's currently parsed. |
protected void |
setDefaultDestroyMethod(String defaultDestroyMethod)
Set the default destroy-method setting for the document that's currently parsed. |
protected void |
setDefaultInitMethod(String defaultInitMethod)
Set the default init-method setting for the document that's currently parsed. |
protected void |
setDefaultLazyInit(String defaultLazyInit)
Set the default lazy-init flag for the document that's currently parsed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BEAN_NAME_DELIMITERS
public static final String TRUE_VALUE
public static final String DEFAULT_VALUE
public static final String DESCRIPTION_ELEMENT
public static final String AUTOWIRE_BY_NAME_VALUE
public static final String AUTOWIRE_BY_TYPE_VALUE
public static final String AUTOWIRE_CONSTRUCTOR_VALUE
public static final String AUTOWIRE_AUTODETECT_VALUE
public static final String DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE
public static final String DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE
public static final String DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE
public static final String DEFAULT_LAZY_INIT_ATTRIBUTE
public static final String DEFAULT_AUTOWIRE_ATTRIBUTE
public static final String DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE
public static final String DEFAULT_INIT_METHOD_ATTRIBUTE
public static final String DEFAULT_DESTROY_METHOD_ATTRIBUTE
public static final String IMPORT_ELEMENT
public static final String RESOURCE_ATTRIBUTE
public static final String ALIAS_ELEMENT
public static final String NAME_ATTRIBUTE
public static final String ALIAS_ATTRIBUTE
public static final String BEAN_ELEMENT
public static final String ID_ATTRIBUTE
public static final String PARENT_ATTRIBUTE
public static final String CLASS_ATTRIBUTE
public static final String ABSTRACT_ATTRIBUTE
public static final String SINGLETON_ATTRIBUTE
public static final String LAZY_INIT_ATTRIBUTE
public static final String AUTOWIRE_ATTRIBUTE
public static final String DEPENDENCY_CHECK_ATTRIBUTE
public static final String DEPENDS_ON_ATTRIBUTE
public static final String INIT_METHOD_ATTRIBUTE
public static final String DESTROY_METHOD_ATTRIBUTE
public static final String FACTORY_METHOD_ATTRIBUTE
public static final String FACTORY_BEAN_ATTRIBUTE
public static final String CONSTRUCTOR_ARG_ELEMENT
public static final String INDEX_ATTRIBUTE
public static final String TYPE_ATTRIBUTE
public static final String PROPERTY_ELEMENT
public static final String REF_ATTRIBUTE
public static final String VALUE_ATTRIBUTE
public static final String LOOKUP_METHOD_ELEMENT
public static final String REPLACED_METHOD_ELEMENT
public static final String REPLACER_ATTRIBUTE
public static final String ARG_TYPE_ELEMENT
public static final String ARG_TYPE_MATCH_ATTRIBUTE
public static final String REF_ELEMENT
public static final String IDREF_ELEMENT
public static final String BEAN_REF_ATTRIBUTE
public static final String LOCAL_REF_ATTRIBUTE
public static final String PARENT_REF_ATTRIBUTE
public static final String VALUE_ELEMENT
public static final String NULL_ELEMENT
public static final String LIST_ELEMENT
public static final String SET_ELEMENT
public static final String MAP_ELEMENT
public static final String ENTRY_ELEMENT
public static final String KEY_ELEMENT
public static final String KEY_ATTRIBUTE
public static final String KEY_REF_ATTRIBUTE
public static final String VALUE_REF_ATTRIBUTE
public static final String PROPS_ELEMENT
public static final String PROP_ELEMENT
protected final Log logger
Constructor Detail |
---|
public DefaultXmlBeanDefinitionParser()
Method Detail |
---|
public int registerBeanDefinitions(BeanDefinitionReader reader, Document doc, Resource resource) throws BeanDefinitionStoreException
Opens a DOM Document; then initializes the default settings
specified at <beans>
level; then parses
the contained bean definitions.
registerBeanDefinitions
in interface XmlBeanDefinitionParser
reader
- the bean definition reader, containing the bean factory
to work on and the bean class loader to use. Can also be used to load
further bean definition files referenced by the given document.doc
- the DOM documentresource
- descriptor of the original XML resource
(useful for displaying parse errors)
BeanDefinitionStoreException
- in case of parsing errorsprotected final BeanDefinitionReader getBeanDefinitionReader()
protected final Resource getResource()
protected void initDefaults(Element root)
setDefaultLazyInit(java.lang.String)
,
setDefaultAutowire(java.lang.String)
,
setDefaultDependencyCheck(java.lang.String)
protected final void setDefaultLazyInit(String defaultLazyInit)
protected final String getDefaultLazyInit()
protected final void setDefaultAutowire(String defaultAutowire)
protected final String getDefaultAutowire()
protected final void setDefaultDependencyCheck(String defaultDependencyCheck)
protected final String getDefaultDependencyCheck()
protected final void setDefaultInitMethod(String defaultInitMethod)
protected final String getDefaultInitMethod()
protected final void setDefaultDestroyMethod(String defaultDestroyMethod)
protected final String getDefaultDestroyMethod()
protected void preProcessXml(Element root) throws BeanDefinitionStoreException
Default implementation is empty. Subclasses can override this method to convert custom elements into standard Spring bean definitions, for example. Implementors have access to the parser's bean definition reader and the underlying XML resource, through the corresponding accessors.
BeanDefinitionStoreException
getBeanDefinitionReader()
,
getResource()
protected int parseBeanDefinitions(Element root) throws BeanDefinitionStoreException
root
- the DOM root element of the document
BeanDefinitionStoreException
protected void importBeanDefinitionResource(Element ele) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected void postProcessXml(Element root) throws BeanDefinitionStoreException
Default implementation is empty. Subclasses can override this method to convert custom elements into standard Spring bean definitions, for example. Implementors have access to the parser's bean definition reader and the underlying XML resource, through the corresponding accessors.
BeanDefinitionStoreException
getBeanDefinitionReader()
,
getResource()
protected BeanDefinitionHolder parseBeanDefinitionElement(Element ele, boolean isInnerBean) throws BeanDefinitionStoreException
Bean elements specify their canonical name as "id" attribute and their aliases as a delimited "name" attribute.
If no "id" specified, uses the first name in the "name" attribute as canonical name, registering all others as aliases.
Callers should specify whether this element represents an inner bean
definition or not by setting the isInnerBean
argument appropriately
BeanDefinitionStoreException
protected BeanDefinition parseBeanDefinitionElement(Element ele, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected int getDependencyCheck(String att)
protected int getAutowireMode(String att)
protected ConstructorArgumentValues parseConstructorArgElements(Element beanEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected MutablePropertyValues parsePropertyElements(Element beanEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected void parseLookupOverrideSubElements(Element beanEle, String beanName, MethodOverrides overrides) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected void parseReplacedMethodSubElements(Element beanEle, String beanName, MethodOverrides overrides) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected void parseConstructorArgElement(Element ele, String beanName, ConstructorArgumentValues cargs) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected void parsePropertyElement(Element ele, String beanName, MutablePropertyValues pvs) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Object parsePropertyValue(Element ele, String beanName, String propertyName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Object parsePropertySubElement(Element ele, String beanName) throws BeanDefinitionStoreException
ele
- subelement of property element; we don't know which yet
BeanDefinitionStoreException
protected List parseListElement(Element collectionEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Set parseSetElement(Element collectionEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Map parseMapElement(Element mapEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Object parseKeyElement(Element keyEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
protected Properties parsePropsElement(Element propsEle, String beanName) throws BeanDefinitionStoreException
BeanDefinitionStoreException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |