001/*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved.            *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD      *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file.                                                     *
007 *                                                                           *
008 *****************************************************************************/
009package org.picocontainer.gems.injectors;
010
011import org.picocontainer.injectors.FactoryInjector;
012import org.picocontainer.injectors.InjectInto;
013import org.picocontainer.PicoContainer;
014import org.picocontainer.PicoCompositionException;
015import org.apache.commons.logging.Log;
016import org.apache.commons.logging.LogFactory;
017
018import java.lang.reflect.Type;
019
020/**
021 * This will Inject a Commons-Logging Logger for the injectee's class name
022 */
023public class CommonsLoggingInjector extends FactoryInjector<Log> {
024
025    @Override
026        public Log getComponentInstance(final PicoContainer container, final Type into) throws PicoCompositionException {
027        return LogFactory.getLog((((InjectInto) into).getIntoClass()).getName());
028    }
029}