org.springframework.config.java.process
Class ConfigurationProcessor

java.lang.Object
  extended by org.springframework.config.java.process.ConfigurationProcessor
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class ConfigurationProcessor
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean

Class that processes Configuration beans.

A Configuration bean contains bean definition methods annotated with the Bean annotation. The Configuration class itself may optionally be annotated with a Configuration annotation setting global defaults.

Bean creation methods may be public or protected.

Typically used for only one configuration class in a single BeanDefinitionRegistry.

Most of the actual work is performed by ConfigurationListeners, which makes the processing of this class extensible. ConfigurationListeners react to configuration methods and classes.

The process work on configurations created from classes but also object instances.

This class implements InitializingBean interface - remember to call InitializingBean.afterPropertiesSet() before any processing.

Author:
Rod Johnson, Costin Leau
See Also:
ConfigurationListener

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
ConfigurationProcessor(org.springframework.context.ConfigurableApplicationContext ac)
          Constructor taking an application context as paramater.
ConfigurationProcessor(org.springframework.beans.factory.config.ConfigurableListableBeanFactory bdr)
          Create a configuration processor.
 
Method Summary
 void afterPropertiesSet()
           
protected  int generateBeanDefinitionFromBeanCreationMethod(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, java.lang.String configurerBeanName, java.lang.Class<?> configurerClass, java.lang.String beanName, java.lang.reflect.Method beanCreationMethod, Bean beanAnnotation)
          Generate the actual bean definition using the given method.
protected  int generateBeanDefinitions(java.lang.String configurationBeanName, java.lang.Class<?> configurationClass)
          Modify metadata by emitting new bean definitions based on the bean creation methods in this Java bytecode.
 BytecodeConfigurationEnhancer getConfigurationEnhancer()
           
 int processBean(java.lang.String beanName)
           
 int processClass(java.lang.Class<?> configurationClass)
          Generate bean definitions from a 'naked' configuration class.
 void setBeanNamingStrategy(BeanNamingStrategy beanNamingStrategy)
          Indicate the naming strategy used for creating the bean names during processing.
 void setConfigurationListenerRegistry(ConfigurationListenerRegistry configurationListenerRegistry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

ConfigurationProcessor

public ConfigurationProcessor(org.springframework.context.ConfigurableApplicationContext ac)
Constructor taking an application context as paramater. Suitable for programatic use.

Parameters:
ac - application context in which the newly created bean definition will reside

ConfigurationProcessor

public ConfigurationProcessor(org.springframework.beans.factory.config.ConfigurableListableBeanFactory bdr)
Create a configuration processor. This is tied to an owning factory.

Parameters:
bdr - owning factory
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

processClass

public int processClass(java.lang.Class<?> configurationClass)
                 throws org.springframework.beans.factory.BeanDefinitionStoreException
Generate bean definitions from a 'naked' configuration class.

Normally this method is used internally on inner classes however, it is possible to use it directly on classes that haven't been manually declared in the enclosing bean factory.

Parameters:
configurationClass - class containing @Configurable or @Bean annotation
Returns:
the number of bean definition generated (including the configuration)
Throws:
org.springframework.beans.factory.BeanDefinitionStoreException - if no bean definitions are found

processBean

public int processBean(java.lang.String beanName)
                throws org.springframework.beans.factory.BeanDefinitionStoreException
Throws:
org.springframework.beans.factory.BeanDefinitionStoreException

generateBeanDefinitions

protected int generateBeanDefinitions(java.lang.String configurationBeanName,
                                      java.lang.Class<?> configurationClass)
Modify metadata by emitting new bean definitions based on the bean creation methods in this Java bytecode. Also, updates the configuration bytecode definition.

Parameters:
configurationBeanName - name of the bean containing the factory methods
configurationClass - class of the configurer bean instance
Returns:
number of bean created

generateBeanDefinitionFromBeanCreationMethod

protected int generateBeanDefinitionFromBeanCreationMethod(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
                                                           java.lang.String configurerBeanName,
                                                           java.lang.Class<?> configurerClass,
                                                           java.lang.String beanName,
                                                           java.lang.reflect.Method beanCreationMethod,
                                                           Bean beanAnnotation)
Generate the actual bean definition using the given method.

Parameters:
beanFactory - containing beanFactory
configurerBeanName - the configuration name
configurerClass - configuration class
beanCreationMethod - method creating the actual bean
beanAnnotation - the Bean annotation available on the creation method.

getConfigurationEnhancer

public BytecodeConfigurationEnhancer getConfigurationEnhancer()

setBeanNamingStrategy

public void setBeanNamingStrategy(BeanNamingStrategy beanNamingStrategy)
Indicate the naming strategy used for creating the bean names during processing.

Parameters:
beanNamingStrategy - bean naming strategy implementation

setConfigurationListenerRegistry

public void setConfigurationListenerRegistry(ConfigurationListenerRegistry configurationListenerRegistry)
Parameters:
configurationListenerRegistry - The configurationListenerRegistry to set.


Copyright © 2005-2007 Spring Framework. All Rights Reserved.