org.apache.xbean.spring.context.v2c
Class XBeanNamespaceHandler

java.lang.Object
  extended by 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
protected  NamedConstructorArgs namedConstructorArgs
           
protected static String[] RESERVED_BEAN_ATTRIBUTE_NAMES
           
protected static String[] RESERVED_ELEMENT_NAMES
          All the reserved Spring XML element names which cannot be overloaded by an XML extension
static String SPRING_SCHEMA
           
static String SPRING_SCHEMA_COMPAT
           
 
Constructor Summary
XBeanNamespaceHandler()
           
 
Method Summary
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
protected  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 properties
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.
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 configuration
protected  String getElementText(Element element)
          Returns the text of the element
protected  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 name
protected  Object getValue(String value, String propertyEditor)
           
 void init()
           
protected  boolean isCollection(Class type)
          Returns true if the given type is a collection type or an array
protected  boolean isDefaultNamespace(String namespaceUri)
           
protected  boolean isEmpty(String uri)
           
protected  boolean isMap(Class type)
           
protected  InputStream loadResource(String uri)
          Loads the resource from the given URI
 org.springframework.beans.factory.config.BeanDefinition parse(Element element, org.springframework.beans.factory.xml.ParserContext parserContext)
           
protected  org.springframework.beans.factory.config.BeanDefinitionHolder parseBeanFromExtensionElement(Element element)
          Parses the non-standard XML element as a Spring bean definition
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
protected  Object parseChildExtensionBean(Element element)
          Iterates the children of this element to find the first nested bean
protected  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 need
protected  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPRING_SCHEMA

public static final String SPRING_SCHEMA
See Also:
Constant Field Values

SPRING_SCHEMA_COMPAT

public static final String SPRING_SCHEMA_COMPAT
See Also:
Constant Field Values

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 Detail

XBeanNamespaceHandler

public XBeanNamespaceHandler()
Method Detail

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



Copyright © 2005-2013. All Rights Reserved.