JSF-Spring

de.mindmatters.faces.spring.factory.xml
Class ManagedBeanDefinitionDocumentReader

java.lang.Object
  extended by de.mindmatters.faces.spring.factory.xml.ManagedBeanDefinitionDocumentReader
All Implemented Interfaces:
BeanDefinitionDocumentReader

public class ManagedBeanDefinitionDocumentReader
extends java.lang.Object
implements BeanDefinitionDocumentReader

Faces implementation of the BeanDefinitionDocumentReader interface. Parses bean definitions according to the "faces-config" DTD.

Tries to build and register bean definitions of type ManagedBeanDefinition parsed from the "managed-bean"-elements. Futhermode this parser is able to parse definitions according to the spring beans DTD.

Note:

Author:
Andreas Kuhrwahl
See Also:
ManagedBeanDefinition

Nested Class Summary
static class ManagedBeanDefinitionDocumentReader.FacesHierarchicalMessageSource
          JSF implementation of a HierarchicalMessageSource.
 
Field Summary
static java.lang.String BEAN_ELEMENT
          <managed-bean></managed-bean> element.
static java.lang.String CLASS_ELEMENT
          <managed-bean-class></managed-bean-class> element.
static java.lang.String DEFAULT_LOCALE_ELEMENT
          <default-locale></default-locale> element.
static java.lang.String ID_ATTRIBUTE
          id attribute of the <managed-bean></managed-bean> element.
static java.lang.String KEY_CLASS_ELEMENT
          <key-class></key-class> element.
static java.lang.String KEY_ELEMENT
          <key></key> element.
static java.lang.String LIST_ENTRIES_ELEMENT
          <list-entries></list-entries> element.
static java.lang.String LOCALE_CONFIG_ELEMENT
          <locale-config></locale-config> element.
protected  org.apache.commons.logging.Log logger
          For logging.
static java.lang.String MAP_ENTRIES_ELEMENT
          <map-entries></map-entries> element.
static java.lang.String MAP_ENTRY_ELEMENT
          <map-entry></map-entry> element.
static java.lang.String MESSAGE_BUNDLE_ELEMENT
          <message-bundle></message-bundle> element.
static java.lang.String NAME_ELEMENT
          <managed-bean-name></managed-bean-name> element.
static java.lang.String NULL_VALUE_ELEMENT
          <null-value></null-value> element.
static java.lang.String PROPERTY_CLASS_ELEMENT
          <property-class></property-class> element.
static java.lang.String PROPERTY_ELEMENT
          <managed-property></managed-property> element.
static java.lang.String PROPERTY_NAME_ELEMENT
          <property-name></property-name> element.
static java.lang.String ROOT_ELEMENT
          <faces-config></faces-config> element.
static java.lang.String SCOPE_ELEMENT
          <managed-bean-scope></managed-bean-scope> element.
static java.lang.String SUPPORTED_LOCALE_ELEMENT
          <supported-locale></supported-locale> element.
static java.lang.String VALUE_CLASS_ELEMENT
          <value-class></value-class> element.
static java.lang.String VALUE_ELEMENT
          <value></value> element.
 
Constructor Summary
ManagedBeanDefinitionDocumentReader()
           
 
Method Summary
protected  void addSupportedLocales(ManagedList supportedLocales, org.w3c.dom.Element localeConfigElement, java.lang.String beanName)
          Adds the supported locales to the MessageResource definition defined as a "locale-config" tag in the "faces-config.xml".
protected  BeanDefinitionDocumentReader createDefaultBeanDefinitionDocumentReader()
          Creates a BeanDefinitionDocumentReader that parses bean definitions other than managed beans according to the "faces-config" DTD.
protected  void error(java.lang.String message, org.w3c.dom.Element source)
          Report an error with the given message for the given source element.
protected  void error(java.lang.String message, org.w3c.dom.Element source, java.lang.Throwable cause)
          Report an error with the given message for the given source element.
protected  java.lang.String getDefaultLocale(org.w3c.dom.Element localeConfigElement, java.lang.String beanName)
          Parses and returns the default locale from the given locale config DOM element.
protected  XmlReaderContext getReaderContext()
           
protected static java.lang.String getTextValue(org.w3c.dom.Element element)
          Extract the text value from the given DOM element, ignoring XML comments.
protected  BeanDefinition parseManagedBeanDefinition(org.w3c.dom.Element element, java.lang.String beanName)
          Parses a standard faces managed bean definition.
protected  ConstructorArgumentValues parseManagedBeanListEntries(org.w3c.dom.Element element, java.lang.String beanName)
          Parses list-entries subelements of the given MANAGED-BEAN element.
protected  ConstructorArgumentValues parseManagedBeanMapEntries(org.w3c.dom.Element element, java.lang.String beanName)
          Parses map-entries subelements of the given MANAGED-BEAN element.
protected  void parseManagedBeanPropertyDefinition(MutablePropertyValues propertyValues, org.w3c.dom.Element element, java.lang.String beanName)
          Parses a managed-property.
 void registerBeanDefinitions(org.w3c.dom.Document doc, XmlReaderContext context)
          Read bean definitions from the given DOM document, and register them with the given bean factory.
protected  void registerManagedBeanDefinition(org.w3c.dom.Element element)
          Parses an element definition: We know this is a MANAGED-BEAN element.
protected  void registerManagedBeanDefinitions(org.w3c.dom.Document doc)
          Parses bean definitions from the given DOM document, and register them with the help of the given XmlReaderContext.
protected  void registerMessageBeanDefinitions(org.w3c.dom.NodeList messageBundleElements, org.w3c.dom.NodeList localeConfigElements)
          Loads the MessageSource definition as a RootBeanDefinition defined in the "faces-config.xml" as a "message-bundle" tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_ELEMENT

public static final java.lang.String ROOT_ELEMENT
<faces-config></faces-config> element.

See Also:
Constant Field Values

MESSAGE_BUNDLE_ELEMENT

public static final java.lang.String MESSAGE_BUNDLE_ELEMENT
<message-bundle></message-bundle> element.

See Also:
Constant Field Values

LOCALE_CONFIG_ELEMENT

public static final java.lang.String LOCALE_CONFIG_ELEMENT
<locale-config></locale-config> element.

See Also:
Constant Field Values

DEFAULT_LOCALE_ELEMENT

public static final java.lang.String DEFAULT_LOCALE_ELEMENT
<default-locale></default-locale> element.

See Also:
Constant Field Values

SUPPORTED_LOCALE_ELEMENT

public static final java.lang.String SUPPORTED_LOCALE_ELEMENT
<supported-locale></supported-locale> element.

See Also:
Constant Field Values

BEAN_ELEMENT

public static final java.lang.String BEAN_ELEMENT
<managed-bean></managed-bean> element.

See Also:
Constant Field Values

ID_ATTRIBUTE

public static final java.lang.String ID_ATTRIBUTE
id attribute of the <managed-bean></managed-bean> element.

See Also:
Constant Field Values

NAME_ELEMENT

public static final java.lang.String NAME_ELEMENT
<managed-bean-name></managed-bean-name> element.

See Also:
Constant Field Values

CLASS_ELEMENT

public static final java.lang.String CLASS_ELEMENT
<managed-bean-class></managed-bean-class> element.

See Also:
Constant Field Values

SCOPE_ELEMENT

public static final java.lang.String SCOPE_ELEMENT
<managed-bean-scope></managed-bean-scope> element.

See Also:
Constant Field Values

PROPERTY_ELEMENT

public static final java.lang.String PROPERTY_ELEMENT
<managed-property></managed-property> element.

See Also:
Constant Field Values

PROPERTY_NAME_ELEMENT

public static final java.lang.String PROPERTY_NAME_ELEMENT
<property-name></property-name> element.

See Also:
Constant Field Values

PROPERTY_CLASS_ELEMENT

public static final java.lang.String PROPERTY_CLASS_ELEMENT
<property-class></property-class> element.

See Also:
Constant Field Values

VALUE_ELEMENT

public static final java.lang.String VALUE_ELEMENT
<value></value> element.

See Also:
Constant Field Values

VALUE_CLASS_ELEMENT

public static final java.lang.String VALUE_CLASS_ELEMENT
<value-class></value-class> element.

See Also:
Constant Field Values

NULL_VALUE_ELEMENT

public static final java.lang.String NULL_VALUE_ELEMENT
<null-value></null-value> element.

See Also:
Constant Field Values

MAP_ENTRIES_ELEMENT

public static final java.lang.String MAP_ENTRIES_ELEMENT
<map-entries></map-entries> element.

See Also:
Constant Field Values

MAP_ENTRY_ELEMENT

public static final java.lang.String MAP_ENTRY_ELEMENT
<map-entry></map-entry> element.

See Also:
Constant Field Values

KEY_ELEMENT

public static final java.lang.String KEY_ELEMENT
<key></key> element.

See Also:
Constant Field Values

KEY_CLASS_ELEMENT

public static final java.lang.String KEY_CLASS_ELEMENT
<key-class></key-class> element.

See Also:
Constant Field Values

LIST_ENTRIES_ELEMENT

public static final java.lang.String LIST_ENTRIES_ELEMENT
<list-entries></list-entries> element.

See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
For logging.

Constructor Detail

ManagedBeanDefinitionDocumentReader

public ManagedBeanDefinitionDocumentReader()
Method Detail

getTextValue

protected static java.lang.String getTextValue(org.w3c.dom.Element element)
Extract the text value from the given DOM element, ignoring XML comments.

Parameters:
element - the given DOM element
Returns:
the text value of the given DOM element

error

protected final void error(java.lang.String message,
                           org.w3c.dom.Element source)
Report an error with the given message for the given source element.

Parameters:
message - The message to report
source - The Element source of the error to report

error

protected final void error(java.lang.String message,
                           org.w3c.dom.Element source,
                           java.lang.Throwable cause)
Report an error with the given message for the given source element.

Parameters:
message - The message to report
source - The Element source of the error to report
cause - The cause of the error if any

registerBeanDefinitions

public final void registerBeanDefinitions(org.w3c.dom.Document doc,
                                          XmlReaderContext context)
Read bean definitions from the given DOM document, and register them with the given bean factory.

Specified by:
registerBeanDefinitions in interface BeanDefinitionDocumentReader
Parameters:
doc - the DOM document
context - the current context of the reader. Includes the resource being parsed

createDefaultBeanDefinitionDocumentReader

protected BeanDefinitionDocumentReader createDefaultBeanDefinitionDocumentReader()
Creates a BeanDefinitionDocumentReader that parses bean definitions other than managed beans according to the "faces-config" DTD.

Default implementation returns a DefaultBeanDefinitionDocumentReader. May be overriden in subclasses.

Returns:
the BeanDefinitionDocumentReader

registerManagedBeanDefinitions

protected void registerManagedBeanDefinitions(org.w3c.dom.Document doc)
Parses bean definitions from the given DOM document, and register them with the help of the given XmlReaderContext.

Parameters:
doc - the DOM document

registerManagedBeanDefinition

protected void registerManagedBeanDefinition(org.w3c.dom.Element element)
Parses an element definition: We know this is a MANAGED-BEAN element. Bean elements specify their canonical name as managed-bean-name tag and their aliases as an id attribute (if specified).

Parameters:
element - the DOM element representing a MANAGED-BEAN

parseManagedBeanDefinition

protected BeanDefinition parseManagedBeanDefinition(org.w3c.dom.Element element,
                                                    java.lang.String beanName)
Parses a standard faces managed bean definition.

Parameters:
element - the DOM element representing a MANAGED-BEAN
beanName - the name of the bean represented by the delivered BeanDefinition
Returns:
the created BeanDefinition
See Also:
ManagedBeanDefinition

parseManagedBeanListEntries

protected ConstructorArgumentValues parseManagedBeanListEntries(org.w3c.dom.Element element,
                                                                java.lang.String beanName)
Parses list-entries subelements of the given MANAGED-BEAN element.

Parameters:
element - the DOM element representing a MANAGED-BEAN element
beanName - the name of the bean represented by the delivered BeanDefinition
Returns:
a PropertyValue representing the defined list
See Also:
PropertyValue

parseManagedBeanMapEntries

protected ConstructorArgumentValues parseManagedBeanMapEntries(org.w3c.dom.Element element,
                                                               java.lang.String beanName)
Parses map-entries subelements of the given MANAGED-BEAN element.

Parameters:
element - the DOM element representing a MANAGED-BEAN element
beanName - the name of the bean represented by the delivered BeanDefinition
Returns:
a PropertyValue representing the defined map
See Also:
PropertyValue

parseManagedBeanPropertyDefinition

protected void parseManagedBeanPropertyDefinition(MutablePropertyValues propertyValues,
                                                  org.w3c.dom.Element element,
                                                  java.lang.String beanName)
Parses a managed-property.

Parameters:
propertyValues - MutablePropertyValues representing the properties defined for this managed bean definition
element - the managed property definition
beanName - the name of the bean represented by the delivered BeanDefinition

registerMessageBeanDefinitions

protected void registerMessageBeanDefinitions(org.w3c.dom.NodeList messageBundleElements,
                                              org.w3c.dom.NodeList localeConfigElements)
Loads the MessageSource definition as a RootBeanDefinition defined in the "faces-config.xml" as a "message-bundle" tag.

Parameters:
messageBundleElements - the DOM nodelist representing message bundle definitions
localeConfigElements - the DOM nodelist representing locale config definitions

addSupportedLocales

protected void addSupportedLocales(ManagedList supportedLocales,
                                   org.w3c.dom.Element localeConfigElement,
                                   java.lang.String beanName)
Adds the supported locales to the MessageResource definition defined as a "locale-config" tag in the "faces-config.xml".

Parameters:
supportedLocales - the locale definitions to support
localeConfigElement - the DOM element representing a locale config definition
beanName - the name of the bean represented by the delivered BeanDefinition

getDefaultLocale

protected java.lang.String getDefaultLocale(org.w3c.dom.Element localeConfigElement,
                                            java.lang.String beanName)
Parses and returns the default locale from the given locale config DOM element.

Parameters:
localeConfigElement - the DOM element representing the locale config definition
beanName - the name of the bean represented by the delivered BeanDefinition
Returns:
the locale represented as string

getReaderContext

protected final XmlReaderContext getReaderContext()
Returns:
The XmlReaderContext

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG