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     *****************************************************************************/
009    package org.picocontainer.gems.injectors;
010    
011    import org.picocontainer.injectors.FactoryInjector;
012    import org.picocontainer.injectors.InjectInto;
013    import org.picocontainer.PicoContainer;
014    import org.picocontainer.PicoCompositionException;
015    import org.apache.commons.logging.Log;
016    import org.apache.commons.logging.LogFactory;
017    
018    import java.lang.reflect.Type;
019    
020    /**
021     * This will Inject a Commons-Logging Logger for the injectee's class name
022     */
023    public 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    }