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: * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
09: *****************************************************************************/package org.picocontainer.injectors;
10:
11: import org.picocontainer.ComponentFactory;
12: import org.picocontainer.ComponentAdapter;
13: import org.picocontainer.ComponentMonitor;
14: import org.picocontainer.LifecycleStrategy;
15: import org.picocontainer.Parameter;
16: import org.picocontainer.PicoCompositionException;
17: import org.picocontainer.Characteristics;
18: import org.picocontainer.behaviors.AbstractBehaviorFactory;
19:
20: import java.util.Properties;
21:
22: /**
23: * A {@link org.picocontainer.InjectionFactory} for methods.
24: * The factory creates {@link MethodInjector}.
25: *
26: * @author Paul Hammant
27: */
28: public class MethodInjection implements ComponentFactory {
29:
30: private final String injectionMethodName;
31:
32: public MethodInjection(String injectionMethodName) {
33: this .injectionMethodName = injectionMethodName;
34: }
35:
36: public MethodInjection() {
37: this ("inject");
38: }
39:
40: public <T> ComponentAdapter<T> createComponentAdapter(
41: ComponentMonitor componentMonitor,
42: LifecycleStrategy lifecycleStrategy,
43: Properties componentProperties, Object componentKey,
44: Class<T> componentImplementation, Parameter... parameters)
45: throws PicoCompositionException {
46: boolean useNames = AbstractBehaviorFactory
47: .removePropertiesIfPresent(componentProperties,
48: Characteristics.USE_NAMES);
49: return new MethodInjector(componentKey,
50: componentImplementation, parameters, componentMonitor,
51: lifecycleStrategy, injectionMethodName, useNames);
52: }
53:
54: }
|