SourceForge.net Logo

de.mindmatters.faces.spring.context.support
Class ManagedBeanDefinitionParser

java.lang.Object
  extended byde.mindmatters.faces.spring.context.support.ManagedBeanDefinitionParser
All Implemented Interfaces:
XmlBeanDefinitionParser

public class ManagedBeanDefinitionParser
extends java.lang.Object
implements XmlBeanDefinitionParser

Faces implementation of the XmlBeanDefinitionParser 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 and the jsf-spring beans DTD. That is done by delegation to the ScopedBeanDefinitionParser.

Note:

Author:
Andreas Kuhrwahl
See Also:
ManagedBeanDefinition

Nested Class Summary
static class ManagedBeanDefinitionParser.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
ManagedBeanDefinitionParser()
           
 
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  ScopedBeanDefinitionParser createScopedBeanDefinitionParser()
           
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  ManagedBeanDefinition parseManagedBeanDefinition(org.w3c.dom.Element element, java.lang.String beanName)
          Parses a standard faces managed bean definition.
protected  PropertyValue parseManagedBeanListEntries(org.w3c.dom.Element element, java.lang.String beanName)
          Parses list-entries subelements of the given MANAGED-BEAN element.
protected  PropertyValue 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.
 int registerBeanDefinitions(BeanDefinitionReader reader, org.w3c.dom.Document doc, Resource xmlResource)
          
protected  int registerFacesBeanDefinitions(org.w3c.dom.Document doc)
          Parses 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 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

ManagedBeanDefinitionParser

public ManagedBeanDefinitionParser()
Method Detail

registerBeanDefinitions

public final int registerBeanDefinitions(BeanDefinitionReader reader,
                                         org.w3c.dom.Document doc,
                                         Resource xmlResource)

Specified by:
registerBeanDefinitions in interface XmlBeanDefinitionParser

createScopedBeanDefinitionParser

protected ScopedBeanDefinitionParser createScopedBeanDefinitionParser()
Returns:
ScopedBeanDefinitionParser for parsing definitions according to the spring beans DTD and the jsf-spring beans DTD

registerFacesBeanDefinitions

protected int registerFacesBeanDefinitions(org.w3c.dom.Document doc)
Parses bean definitions from the given DOM document, and register them with the given bean factory.

Parameters:
doc - the DOM document
Returns:
the number of bean definitions found
Throws:
BeanDefinitionStoreException - in case of parsing errors

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 id attribute and their aliases as a managed-bean-name tag. If no id specified, use the name in the managed-bean-name tag as canonical name, registering no aliases.

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

parseManagedBeanDefinition

protected ManagedBeanDefinition 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 PropertyValue 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 PropertyValue 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

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG