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 Details

    • SPRING_SCHEMA

      public static final String SPRING_SCHEMA
      See Also:
    • SPRING_SCHEMA_COMPAT

      public static final String SPRING_SCHEMA_COMPAT
      See Also:
    • RESERVED_ELEMENT_NAMES

      protected static final String[] RESERVED_ELEMENT_NAMES
      All the reserved Spring XML element names which cannot be overloaded by an XML extension
    • RESERVED_BEAN_ATTRIBUTE_NAMES

      protected static final String[] RESERVED_BEAN_ATTRIBUTE_NAMES
    • namedConstructorArgs

      protected final NamedConstructorArgs namedConstructorArgs
  • Constructor Details

    • XBeanNamespaceHandler

      public XBeanNamespaceHandler()
  • Method Details

    • init

      public void init()
      Specified by:
      init in interface org.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 interface org.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 interface org.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

      protected Class resolveBeanClass(org.springframework.beans.factory.support.AbstractBeanDefinition bd, String beanName)
    • parseBeanFromExtensionElement

      protected org.springframework.beans.factory.config.BeanDefinitionHolder parseBeanFromExtensionElement(Element element)
      Parses the non-standard XML element as a Spring bean definition
    • addSpringAttributeValues

      protected void addSpringAttributeValues(String className, Element element)
    • cloneElement

      protected Element cloneElement(Element element)
      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

      protected Object getValue(String value, String propertyEditor)
    • createPropertyEditor

      protected PropertyEditor createPropertyEditor(String propertyEditor)
    • getLocalName

      protected String getLocalName(Element element)
    • 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

      protected PropertyDescriptor getPropertyDescriptor(String className, String localName)
      Looks up the property decriptor for the given class and property name
    • parseListElement

      protected Object parseListElement(Element element, String name)
    • parseCustomMapElement

      protected Object parseCustomMapElement(MappingMetaData metadata, Element element, String name)
    • addValueToMap

      protected void addValueToMap(Map map, Object keyValue, Object value, String dups)
    • getFirstChildElement

      protected Element getFirstChildElement(Element element)
    • isMap

      protected boolean isMap(Class type)
    • isCollection

      protected boolean isCollection(Class type)
      Returns true if the given type is a collection type or an array
    • parseChildExtensionBean

      protected Object parseChildExtensionBean(Element element)
      Iterates the children of this element to find the first nested bean
    • findNamespaceProperties

      protected MappingMetaData findNamespaceProperties(String namespaceURI, String localName)
      Uses META-INF/services discovery to find a Properties file with the XML marshaling configuration
      Parameters:
      namespaceURI - the namespace URI of the element
      localName - the local name of the element
      Returns:
      the properties configuration of the namespace or null if none could be found
    • loadResource

      protected InputStream loadResource(String uri)
      Loads the resource from the given URI
    • isEmpty

      protected boolean isEmpty(String uri)
    • isDefaultNamespace

      protected boolean isDefaultNamespace(String namespaceUri)
    • declareLifecycleMethods

      protected void declareLifecycleMethods(org.springframework.beans.factory.config.BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element)
    • getElementText

      protected String getElementText(Element element)
      Returns the text of the element