Top Description Fields Constructors Methods
org.springframework.beans.factory.config

public Class DeprecatedBeanWarner

extends Object
implements BeanFactoryPostProcessor
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.config.BeanFactoryPostProcessor
Imports
org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanFactory, org.springframework.util.ClassUtils, .StringUtils

Bean factory post processor that logs a warning for @Deprecated beans.
Author
Arjen Poutsma
Since
3.0.3

Field Summary

Modifier and TypeField and Description
protected transient Log
logger

Logger available to subclasses.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
isLogEnabled()

Determine whether the logger field is enabled.

protected void
logDeprecatedBean(String
the name of the deprecated bean
beanName
,
Class<?>
the user-specified type of the deprecated bean
beanType
,
BeanDefinition
the definition of the deprecated bean
beanDefinition
)

Logs a warning for a bean annotated with @Deprecated.

public void
postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context
beanFactory
)

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Modify the application context's internal bean factory after its standard initialization.
public void
setLoggerName(String loggerName)

Set the name of the logger to use.

protected void
writeToLog(String
the message to write
message
)

Actually write to the underlying log.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected transient Log logger

Logger available to subclasses.

Constructor Detail

DeprecatedBeanWarnerback to summary
public DeprecatedBeanWarner()

Method Detail

isLogEnabledback to summary
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.

logDeprecatedBeanback to summary
protected void logDeprecatedBean(String beanName, Class<?> beanType, BeanDefinition beanDefinition)

Logs a warning for a bean annotated with @Deprecated.

Parameters
beanName:String

the name of the deprecated bean

beanType:Class<?>

the user-specified type of the deprecated bean

beanDefinition:BeanDefinition

the definition of the deprecated bean

postProcessBeanFactoryback to summary
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Doc from org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

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.

Parameters
beanFactory:ConfigurableListableBeanFactory

the bean factory used by the application context

Annotations
@Override
Exceptions
BeansException:
in case of errors
setLoggerNameback to summary
public void setLoggerName(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
org.apache.commons.logging.LogFactory#getLog(String), java.util.logging.Logger#getLogger(String)
writeToLogback to summary
protected void writeToLog(String message)

Actually write to the underlying log.

The default implementations logs the message at "warn" level.

Parameters
message:String

the message to write