    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.PicoCompositionException;
    012    import org.picocontainer.PicoContainer;
    013    import org.picocontainer.injectors.FactoryInjector;
    014
    015    import java.lang.reflect.Type;
    016    import java.util.logging.Logger;
    017
    018    /**
    019     * This will Inject a Java-Logging Logger for the injectee's class name
    020     */
    021    public class JavaLoggingInjector extends FactoryInjector<Logger> {
    022
    023        @Override
    024            public java.util.logging.Logger getComponentInstance(final PicoContainer container, final Type into) throws PicoCompositionException {
    025            String name = ((Class) into).getName();
    026            Logger logger = Logger.getLogger(name);
    027            if (logger == null) {
    028                Logger.getLogger(name);
    029            }
    030            return logger;
    031        }
    032
    033    }
    034