org.springbyexample.util.log
Class LoggerBeanPostProcessor

java.lang.Object
  extended by org.springbyexample.util.log.LoggerBeanPostProcessor
All Implemented Interfaces:
BeanPostProcessor, Ordered
Direct Known Subclasses:
AnnotationLoggerBeanPostProcessor, LoggerAwareBeanPostProcessor

public class LoggerBeanPostProcessor
extends Object
implements BeanPostProcessor, Ordered

Injects loggers into new bean instances based on reflection.

Default logger factories configured are SLF4J, Apache Commons, Log4J, and JDK 1.4 Logging.

Author:
Tim Voet, David Winterfeldt

Field Summary
protected  Map<String,String> hLoggerFactories
           
protected  String methodName
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
LoggerBeanPostProcessor()
          Constructor
 
Method Summary
protected  Object getLogger(String loggerName, String loggerType)
          Gets logger based on the logger name and type of logger (class name, ex: 'org.slf4j.Logger').
 int getOrder()
           
 void injectMethod(Object bean, Method method)
          Processes a property descriptor to inject a logger.
 Object postProcessAfterInitialization(Object bean, String beanName)
          This method is used to execute after a bean's initialization callback.
 Object postProcessBeforeInitialization(Object bean, String beanName)
           
protected  void processLogger(Object bean, String methodName)
          Instantiates bean specific loggers and sets them.
 void setLoggerFactoryMap(Map<String,String> hLoggerFactories)
          Set logger factory Map.
 void setMethodName(String methodName)
          Sets target method name to set logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hLoggerFactories

protected Map<String,String> hLoggerFactories

methodName

protected String methodName
Constructor Detail

LoggerBeanPostProcessor

public LoggerBeanPostProcessor()
Constructor

Method Detail

setMethodName

public void setMethodName(String methodName)
Sets target method name to set logger.


setLoggerFactoryMap

public void setLoggerFactoryMap(Map<String,String> hLoggerFactories)
Set logger factory Map.


postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String beanName)
                                       throws BeansException
Specified by:
postProcessBeforeInitialization in interface BeanPostProcessor
Throws:
BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String beanName)
                                      throws BeansException
This method is used to execute after a bean's initialization callback.

Specified by:
postProcessAfterInitialization in interface BeanPostProcessor
Throws:
BeansException
See Also:
BeanPostProcessor.postProcessAfterInitialization(java.lang.Object, java.lang.String)

getOrder

public int getOrder()
Specified by:
getOrder in interface Ordered

processLogger

protected void processLogger(Object bean,
                             String methodName)
Instantiates bean specific loggers and sets them.


injectMethod

public void injectMethod(Object bean,
                         Method method)
Processes a property descriptor to inject a logger.


getLogger

protected Object getLogger(String loggerName,
                           String loggerType)
Gets logger based on the logger name and type of logger (class name, ex: 'org.slf4j.Logger').



Copyright © 2008-2009 Spring by Example. All Rights Reserved.