Spring Framework

org.springframework.beans.factory.config
Class DeprecatedBeanWarner

java.lang.Object
  extended by org.springframework.beans.factory.config.DeprecatedBeanWarner
All Implemented Interfaces:
BeanFactoryPostProcessor

public class DeprecatedBeanWarner
extends java.lang.Object
implements BeanFactoryPostProcessor

Bean factory post processor that logs a warning for @Deprecated beans.

Since:
3.0.3
Author:
Arjen Poutsma

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses.
 
Constructor Summary
DeprecatedBeanWarner()
           
 
Method Summary
protected  boolean isLogEnabled()
          Determine whether the logger field is enabled.
protected  void logDeprecatedBean(java.lang.String beanName, BeanDefinition beanDefinition)
          Logs a warning for a bean annotated with @Deprecated.
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Modify the application context's internal bean factory after its standard initialization.
 void setLoggerName(java.lang.String loggerName)
          Set the name of the logger to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected transient org.apache.commons.logging.Log logger
Logger available to subclasses.

Constructor Detail

DeprecatedBeanWarner

public DeprecatedBeanWarner()
Method Detail

setLoggerName

public void setLoggerName(java.lang.String loggerName)
Set the name of the logger to use. The name will be passed to the underlying logger implementation through Commons Logging, getting interpreted as log category according to the logger's configuration.

This can be specified to not log into the category of this warner class but rather into a specific named category.

See Also:
LogFactory.getLog(String), Logger.getLogger(String), Logger.getLogger(String)

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                            throws BeansException
Description copied from interface: BeanFactoryPostProcessor
Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Parameters:
beanFactory - the bean factory used by the application context
Throws:
BeansException - in case of errors

logDeprecatedBean

protected void logDeprecatedBean(java.lang.String beanName,
                                 BeanDefinition beanDefinition)
Logs a warning for a bean annotated with @Deprecated.

Parameters:
beanName - the name of the deprecated bean
beanDefinition - the definition of the deprecated bean

isLogEnabled

protected boolean isLogEnabled()
Determine whether the logger field is enabled.

Default is true when the "warn" level is enabled. Subclasses can override this to change the level under which logging occurs.


Spring Framework