Class XBeanNamespaceHandler
java.lang.Object
org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler
- All Implemented Interfaces:
org.springframework.beans.factory.xml.NamespaceHandler
public class XBeanNamespaceHandler
extends Object
implements org.springframework.beans.factory.xml.NamespaceHandler
An enhanced XML parser capable of handling custom XML schemas.
- Since:
- 2.0
- Version:
- $Id$
- Author:
- James Strachan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final NamedConstructorArgs
protected static final String[]
protected static final String[]
All the reserved Spring XML element names which cannot be overloaded by an XML extensionstatic final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttributeProperties
(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, String className, Element element) Parses attribute names and values as being bean property expressionsprotected void
addAttributeProperty
(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element, Attr attribute) protected void
addContentProperty
(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element) protected void
addNestedPropertyElements
(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, String className, Element element) Lets iterate through the children of this element and create any nested child propertiesprotected void
addProperty
(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element, String localName, String value) Add a property onto the current BeanDefinition.protected void
addSpringAttributeValues
(String className, Element element) protected void
addValueToMap
(Map map, Object keyValue, Object value, String dups) protected Element
cloneElement
(Element element) Creates a clone of the element and its attribute (though not its content)static void
configure
(org.springframework.context.support.AbstractApplicationContext context, org.springframework.beans.factory.xml.XmlBeanDefinitionReader reader) Configures the XmlBeanDefinitionReader to work nicely with extensible XML using this reader implementation.protected PropertyEditor
createPropertyEditor
(String propertyEditor) protected void
declareLifecycleMethods
(org.springframework.beans.factory.config.BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element) org.springframework.beans.factory.config.BeanDefinitionHolder
decorate
(Node node, org.springframework.beans.factory.config.BeanDefinitionHolder definition, org.springframework.beans.factory.xml.ParserContext parserContext) protected MappingMetaData
findNamespaceProperties
(String namespaceURI, String localName) Uses META-INF/services discovery to find a Properties file with the XML marshaling configurationprotected String
getElementText
(Element element) Returns the text of the elementprotected Element
getFirstChildElement
(Element element) protected String
getLocalName
(Element element) protected PropertyDescriptor
getPropertyDescriptor
(String className, String localName) Looks up the property decriptor for the given class and property nameprotected Object
void
init()
protected boolean
isCollection
(Class type) Returns true if the given type is a collection type or an arrayprotected boolean
isDefaultNamespace
(String namespaceUri) protected boolean
protected boolean
protected InputStream
loadResource
(String uri) Loads the resource from the given URIorg.springframework.beans.factory.config.BeanDefinition
protected org.springframework.beans.factory.config.BeanDefinitionHolder
parseBeanFromExtensionElement
(Element element) Parses the non-standard XML element as a Spring bean definitionprotected org.springframework.beans.factory.config.BeanDefinitionHolder
parseBeanFromExtensionElement
(Element element, String parentClass, String property) Parses the non-standard XML element as a Spring bean definitionprotected Object
parseChildExtensionBean
(Element element) Iterates the children of this element to find the first nested beanprotected Object
parseCustomMapElement
(MappingMetaData metadata, Element element, String name) protected Object
parseListElement
(Element element, String name) static void
registerCustomEditors
(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) Registers whatever custom editors we needprotected Class
resolveBeanClass
(org.springframework.beans.factory.support.AbstractBeanDefinition bd, String beanName) protected Object
tryParseNestedPropertyViaIntrospection
(MappingMetaData metadata, String className, Element element) Attempts to use introspection to parse the nested property element.
-
Field Details
-
SPRING_SCHEMA
- See Also:
-
SPRING_SCHEMA_COMPAT
- See Also:
-
RESERVED_ELEMENT_NAMES
All the reserved Spring XML element names which cannot be overloaded by an XML extension -
RESERVED_BEAN_ATTRIBUTE_NAMES
-
namedConstructorArgs
-
-
Constructor Details
-
XBeanNamespaceHandler
public XBeanNamespaceHandler()
-
-
Method Details
-
init
public void init()- Specified by:
init
in interfaceorg.springframework.beans.factory.xml.NamespaceHandler
-
parse
public org.springframework.beans.factory.config.BeanDefinition parse(Element element, org.springframework.beans.factory.xml.ParserContext parserContext) - Specified by:
parse
in interfaceorg.springframework.beans.factory.xml.NamespaceHandler
-
decorate
public org.springframework.beans.factory.config.BeanDefinitionHolder decorate(Node node, org.springframework.beans.factory.config.BeanDefinitionHolder definition, org.springframework.beans.factory.xml.ParserContext parserContext) - Specified by:
decorate
in interfaceorg.springframework.beans.factory.xml.NamespaceHandler
-
configure
public static void configure(org.springframework.context.support.AbstractApplicationContext context, org.springframework.beans.factory.xml.XmlBeanDefinitionReader reader) Configures the XmlBeanDefinitionReader to work nicely with extensible XML using this reader implementation. -
registerCustomEditors
public static void registerCustomEditors(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) Registers whatever custom editors we need -
parseBeanFromExtensionElement
protected org.springframework.beans.factory.config.BeanDefinitionHolder parseBeanFromExtensionElement(Element element, String parentClass, String property) Parses the non-standard XML element as a Spring bean definition -
resolveBeanClass
-
parseBeanFromExtensionElement
protected org.springframework.beans.factory.config.BeanDefinitionHolder parseBeanFromExtensionElement(Element element) Parses the non-standard XML element as a Spring bean definition -
addSpringAttributeValues
-
cloneElement
Creates a clone of the element and its attribute (though not its content) -
addAttributeProperties
protected void addAttributeProperties(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, String className, Element element) Parses attribute names and values as being bean property expressions -
addContentProperty
protected void addContentProperty(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element) -
addAttributeProperty
protected void addAttributeProperty(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element, Attr attribute) -
addProperty
protected void addProperty(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, Element element, String localName, String value) Add a property onto the current BeanDefinition. -
getValue
-
createPropertyEditor
-
getLocalName
-
addNestedPropertyElements
protected void addNestedPropertyElements(org.springframework.beans.factory.config.BeanDefinitionHolder definition, MappingMetaData metadata, String className, Element element) Lets iterate through the children of this element and create any nested child properties -
tryParseNestedPropertyViaIntrospection
protected Object tryParseNestedPropertyViaIntrospection(MappingMetaData metadata, String className, Element element) Attempts to use introspection to parse the nested property element. -
getPropertyDescriptor
Looks up the property decriptor for the given class and property name -
parseListElement
-
parseCustomMapElement
-
addValueToMap
-
getFirstChildElement
-
isMap
-
isCollection
Returns true if the given type is a collection type or an array -
parseChildExtensionBean
Iterates the children of this element to find the first nested bean -
findNamespaceProperties
Uses META-INF/services discovery to find a Properties file with the XML marshaling configuration- Parameters:
namespaceURI
- the namespace URI of the elementlocalName
- the local name of the element- Returns:
- the properties configuration of the namespace or null if none could be found
-
loadResource
Loads the resource from the given URI -
isEmpty
-
isDefaultNamespace
-
declareLifecycleMethods
protected void declareLifecycleMethods(org.springframework.beans.factory.config.BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element) -
getElementText
Returns the text of the element
-