01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Original code by *
09: *****************************************************************************/package org.picocontainer.injectors;
10:
11: import org.picocontainer.Parameter;
12: import org.picocontainer.ComponentMonitor;
13: import org.picocontainer.LifecycleStrategy;
14:
15: import java.lang.annotation.Annotation;
16: import java.lang.reflect.Method;
17:
18: public class AnnotatedMethodInjector extends SetterInjector {
19:
20: /**
21: * Serialization UUID.
22: */
23: private static final long serialVersionUID = -1347829923043944701L;
24:
25: private final Class<? extends Annotation> injectionAnnotation;
26:
27: public AnnotatedMethodInjector(Object key, Class<?> impl,
28: Parameter[] parameters, ComponentMonitor monitor,
29: LifecycleStrategy lifecycleStrategy,
30: Class<? extends Annotation> injectionAnnotation,
31: boolean useNames) {
32: super (key, impl, parameters, monitor, lifecycleStrategy, "",
33: useNames);
34: this .injectionAnnotation = injectionAnnotation;
35: }
36:
37: protected final boolean isInjectorMethod(Method method) {
38: return method.getAnnotation(injectionAnnotation) != null;
39: }
40:
41: public String toString() {
42: return "MethodInjection-" + super.toString();
43: }
44:
45: }
|