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