1 package org.apache.maven.archiva.common.spring;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.codehaus.plexus.logging.LogEnabled;
23 import org.codehaus.plexus.logging.Logger;
24 import org.codehaus.plexus.logging.LoggerManager;
25 import org.codehaus.plexus.logging.console.ConsoleLogger;
26 import org.codehaus.plexus.logging.slf4j.Slf4jLogger;
27 import org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager;
28 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
29 import org.springframework.beans.BeansException;
30 import org.springframework.beans.factory.InitializingBean;
31 import org.springframework.beans.factory.config.BeanPostProcessor;
34 * A Spring bean postPorcessor to apply Plexu LogEnabled lifecycle interface
36 * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
39 public class PlexusLogEnabledBeanPostProcessor
40 implements BeanPostProcessor, InitializingBean
42 private LoggerManager loggerManager = new Slf4jLoggerManager();
46 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
48 public void afterPropertiesSet()
51 if ( loggerManager instanceof Initializable )
53 ( (Initializable) loggerManager ).initialize();
59 * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
61 public Object postProcessAfterInitialization( Object bean, String beanName )
69 * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
71 public Object postProcessBeforeInitialization( Object bean, String beanName )
74 if ( bean instanceof LogEnabled )
76 ( (LogEnabled) bean ).enableLogging( loggerManager.getLoggerForComponent( beanName ) );
81 protected void setLoggerManager( LoggerManager loggerManager )
83 this.loggerManager = loggerManager;