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     * Original code by                                                          *
009     *****************************************************************************/
010    package org.picocontainer.injectors;
011    
012    import org.picocontainer.Parameter;
013    import org.picocontainer.ComponentMonitor;
014    import org.picocontainer.LifecycleStrategy;
015    
016    import java.lang.reflect.Method;
017    
018    public class AnnotatedMethodInjector extends SetterInjector {
019    
020        private final Class injectionAnnotation;
021    
022        public AnnotatedMethodInjector(Object key,
023                                       Class impl,
024                                       Parameter[] parameters,
025                                       ComponentMonitor monitor,
026                                       LifecycleStrategy lifecycleStrategy, Class injectionAnnotation) {
027            super(key, impl, parameters, monitor, lifecycleStrategy, "");
028            this.injectionAnnotation = injectionAnnotation;
029        }
030    
031        protected final boolean isInjectorMethod(Method method) {
032            return method.getAnnotation(injectionAnnotation) != null;
033        }
034    
035        public String toString() {
036            return "MethodInjection-" + super.toString();
037        }
038    
039    }