org.apache.cocoon.spring.configurator.impl
Class AbstractElementParser

java.lang.Object
  extended byorg.apache.cocoon.spring.configurator.impl.AbstractElementParser
All Implemented Interfaces:
BeanDefinitionParser
Direct Known Subclasses:
AbstractSettingsElementParser, BeanMapElementParser

public abstract class AbstractElementParser
extends Object
implements BeanDefinitionParser

This is a base class for all bean definition parsers used in Cocoon. It provides some utility methods.

Since:
1.0
Version:
$Id: AbstractElementParser.java 587750 2007-10-24 02:35:22Z vgritsenko $

Field Summary
protected  Log logger
          Logger (we use the same logging mechanism as Spring!)
 
Constructor Summary
AbstractElementParser()
           
 
Method Summary
protected  void addComponent(Class componentClass, String beanName, String initMethod, boolean requiresSettings, BeanDefinitionRegistry registry)
          Add a new bean definition to the registry.
protected  void addComponent(String componentClass, String beanName, String initMethod, boolean requiresSettings, BeanDefinitionRegistry registry)
          Add a new bean definition to the registry.
protected  RootBeanDefinition createBeanDefinition(Class componentClass, String initMethod, boolean requiresSettings)
          Helper method to create a new bean definition.
protected  RootBeanDefinition createBeanDefinition(String componentClass, String initMethod, boolean requiresSettings)
          Helper method to create a new bean definition.
protected  String getAttributeValue(Element element, String attributeName, String defaultValue)
          Get the value of an attribute or if the attribute is not present return the default value.
protected  Element[] getChildElements(Element element, String localName)
          Returns all Element children of an Element that have the given local name.
protected  void register(BeanDefinition beanDef, Element element, BeanDefinitionRegistry registry)
          Register a global bean definition.
protected  void register(BeanDefinition beanDef, String beanName, BeanDefinitionRegistry registry)
          Register a bean definition.
protected  void register(BeanDefinition beanDef, String beanName, String alias, BeanDefinitionRegistry registry)
          Register a bean definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.xml.BeanDefinitionParser
parse
 

Field Detail

logger

protected final Log logger
Logger (we use the same logging mechanism as Spring!)

Constructor Detail

AbstractElementParser

public AbstractElementParser()
Method Detail

getAttributeValue

protected String getAttributeValue(Element element,
                                   String attributeName,
                                   String defaultValue)
Get the value of an attribute or if the attribute is not present return the default value. As Element#getAttribute(String) returns an empty string and not null, we have to check this.


getChildElements

protected Element[] getChildElements(Element element,
                                     String localName)
Returns all Element children of an Element that have the given local name.


register

protected void register(BeanDefinition beanDef,
                        String beanName,
                        BeanDefinitionRegistry registry)
Register a bean definition.

Parameters:
beanDef - The bean definition.
beanName - The name of the bean.
registry - The registry.

register

protected void register(BeanDefinition beanDef,
                        String beanName,
                        String alias,
                        BeanDefinitionRegistry registry)
Register a bean definition.

Parameters:
beanDef - The bean definition.
beanName - The name of the bean.
alias - Optional alias.
registry - The registry.

register

protected void register(BeanDefinition beanDef,
                        Element element,
                        BeanDefinitionRegistry registry)
Register a global bean definition. The provided xml element is searched for an id and/or name attribute to register the bean. This implementation works the same as the default spring implementation.

Parameters:
beanDef - The bean definition.
element - The xml element defining the bean.
registry - The registry.
Since:
1.0.1

createBeanDefinition

protected RootBeanDefinition createBeanDefinition(Class componentClass,
                                                  String initMethod,
                                                  boolean requiresSettings)
Helper method to create a new bean definition.

Parameters:
componentClass - The class of the implementation.
initMethod - Optional initialization method.
requiresSettings - If set to true, this bean has a property "settings" for the settings object.
Returns:
A new root bean definition.

createBeanDefinition

protected RootBeanDefinition createBeanDefinition(String componentClass,
                                                  String initMethod,
                                                  boolean requiresSettings)
Helper method to create a new bean definition.

Parameters:
componentClass - The class of the implementation.
initMethod - Optional initialization method.
requiresSettings - If set to true, this bean has a property "settings" for the settings object.
Returns:
A new root bean definition.

addComponent

protected void addComponent(Class componentClass,
                            String beanName,
                            String initMethod,
                            boolean requiresSettings,
                            BeanDefinitionRegistry registry)
Add a new bean definition to the registry.

Parameters:
componentClass - The class of the implementation.
beanName - The name of the bean.
initMethod - Optional initialization method.
requiresSettings - If set to true, this bean has a property "settings" for the settings object.
registry - The bean registry.

addComponent

protected void addComponent(String componentClass,
                            String beanName,
                            String initMethod,
                            boolean requiresSettings,
                            BeanDefinitionRegistry registry)
Add a new bean definition to the registry.

Parameters:
componentClass - The class of the implementation.
beanName - The name of the bean.
initMethod - Optional initialization method.
requiresSettings - If set to true, this bean has a property "settings" for the settings object.
registry - The bean registry.


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.