java.lang.Object | ||
↳ | org.springframework.beans.factory.support.AbstractBeanDefinitionReader | |
↳ | org.springframework.beans.factory.xml.XmlBeanDefinitionReader |
Bean definition reader for XML bean definitions.
Delegates the actual XML document reading to an implementation
of the BeanDefinitionDocumentReader
interface.
Typically applied to a
DefaultListableBeanFactory
or a GenericApplicationContext
.
This class loads a DOM document and applies the BeanDefinitionDocumentReader to it.
The document reader will register each bean definition with the given bean factory,
talking to the latter's implementation of the
BeanDefinitionRegistry
interface.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | VALIDATION_AUTO | Indicates that the validation mode should be detected automatically. | |||||||||
int | VALIDATION_DTD | Indicates that DTD validation should be used. | |||||||||
int | VALIDATION_NONE | Indicates that the validation should be disabled. | |||||||||
int | VALIDATION_XSD | Indicates that XSD validation should be used. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create new XmlBeanDefinitionReader for the given bean factory.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the validation mode to use.
| |||||||||||
Return whether or not the XML parser should be XML namespace aware.
| |||||||||||
Load bean definitions from the specified XML file.
| |||||||||||
Load bean definitions from the specified XML file.
| |||||||||||
Load bean definitions from the specified XML file.
| |||||||||||
Load bean definitions from the specified XML file.
| |||||||||||
Register the bean definitions contained in the given DOM document.
| |||||||||||
Specify the
DocumentLoader to use. | |||||||||||
Specify the
BeanDefinitionDocumentReader implementation to use,
responsible for the actual reading of the XML bean definition document. | |||||||||||
Set a SAX entity resolver to be used for parsing.
| |||||||||||
Set an implementation of the
org.xml.sax.ErrorHandler
interface for custom handling of XML parsing errors and warnings. | |||||||||||
Specify which
ReaderEventListener to use. | |||||||||||
Set whether or not the XML parser should be XML namespace aware.
| |||||||||||
Specify the
NamespaceHandlerResolver to use. | |||||||||||
Specify which
ProblemReporter to use. | |||||||||||
Specify the
SourceExtractor to use. | |||||||||||
Set whether to use XML validation.
| |||||||||||
Set the validation mode to use.
| |||||||||||
Set the validation mode to use by name.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create the
BeanDefinitionDocumentReader to use for actually
reading bean definitions from an XML document. | |||||||||||
Create the default implementation of
NamespaceHandlerResolver used if none is specified. | |||||||||||
Create the
XmlReaderContext to pass over to the document reader. | |||||||||||
Detects which kind of validation to perform on the XML file identified
by the supplied
Resource . | |||||||||||
Actually load bean definitions from the specified XML file.
| |||||||||||
Return the EntityResolver to use, building a default resolver
if none specified.
| |||||||||||
Gets the validation mode for the specified
Resource . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.support.BeanDefinitionReader
| |||||||||||
From interface
org.springframework.core.env.EnvironmentCapable
|
Indicates that the validation mode should be detected automatically.
Indicates that DTD validation should be used.
Indicates that the validation should be disabled.
Indicates that XSD validation should be used.
Create new XmlBeanDefinitionReader for the given bean factory.
registry | the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry |
---|
Return whether or not the XML parser should be XML namespace aware.
Load bean definitions from the specified XML file.
inputSource | the SAX InputSource to read from |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified XML file.
inputSource | the SAX InputSource to read from |
---|---|
resourceDescription | a description of the resource
(can be null or empty) |
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified XML file.
resource | the resource descriptor for the XML file |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified XML file.
encodedResource | the resource descriptor for the XML file, allowing to specify an encoding to use for parsing the file |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Register the bean definitions contained in the given DOM document.
Called by loadBeanDefinitions
.
Creates a new instance of the parser class and invokes
registerBeanDefinitions
on it.
doc | the DOM document |
---|---|
resource | the resource descriptor (for context information) |
BeanDefinitionStoreException | in case of parsing errors |
---|
Specify the DocumentLoader
to use.
The default implementation is DefaultDocumentLoader
which loads Document
instances using JAXP.
Specify the BeanDefinitionDocumentReader
implementation to use,
responsible for the actual reading of the XML bean definition document.
The default is DefaultBeanDefinitionDocumentReader
.
documentReaderClass | the desired BeanDefinitionDocumentReader implementation class |
---|
Set a SAX entity resolver to be used for parsing.
By default, ResourceEntityResolver
will be used. Can be overridden
for custom entity resolution, for example relative to some specific base path.
Set an implementation of the org.xml.sax.ErrorHandler
interface for custom handling of XML parsing errors and warnings.
If not set, a default SimpleSaxErrorHandler is used that simply logs warnings using the logger instance of the view class, and rethrows errors to discontinue the XML transformation.
Specify which ReaderEventListener
to use.
The default implementation is EmptyReaderEventListener which discards every event notification. External tools can provide an alternative implementation to monitor the components being registered in the BeanFactory.
Set whether or not the XML parser should be XML namespace aware. Default is "false".
This is typically not needed when schema validation is active. However, without validation, this has to be switched to "true" in order to properly process schema namespaces.
Specify the NamespaceHandlerResolver
to use.
If none is specified, a default instance will be created through
createDefaultNamespaceHandlerResolver()
.
Specify which ProblemReporter
to use.
The default implementation is FailFastProblemReporter
which exhibits fail fast behaviour. External tools can provide an alternative implementation
that collates errors and warnings for display in the tool UI.
Specify the SourceExtractor
to use.
The default implementation is NullSourceExtractor
which simply returns null
as the source object. This means that - during normal runtime execution -
no additional source metadata is attached to the bean configuration metadata.
Set whether to use XML validation. Default is true
.
This method switches namespace awareness on if validation is turned off, in order to still process schema namespaces properly in such a scenario.
Set the validation mode to use. Defaults to VALIDATION_AUTO
.
Note that this only activates or deactivates validation itself.
If you are switching validation off for schema files, you might need to
activate schema namespace support explicitly: see setNamespaceAware(boolean)
.
Set the validation mode to use by name. Defaults to VALIDATION_AUTO
.
Create the BeanDefinitionDocumentReader
to use for actually
reading bean definitions from an XML document.
The default implementation instantiates the specified "documentReaderClass".
Create the default implementation of NamespaceHandlerResolver
used if none is specified.
Default implementation returns an instance of DefaultNamespaceHandlerResolver
.
Create the XmlReaderContext
to pass over to the document reader.
Detects which kind of validation to perform on the XML file identified
by the supplied Resource
. If the file has a DOCTYPE
definition then DTD validation is used otherwise XSD validation is assumed.
Override this method if you would like to customize resolution
of the VALIDATION_AUTO
mode.
Actually load bean definitions from the specified XML file.
inputSource | the SAX InputSource to read from |
---|---|
resource | the resource descriptor for the XML file |
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Return the EntityResolver to use, building a default resolver if none specified.
Gets the validation mode for the specified Resource
. If no explicit
validation mode has been configured then the validation mode is
detected
.
Override this method if you would like full control over the validation
mode, even when something other than VALIDATION_AUTO
was set.