|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SetterInjectionComponentAdapterFactory.java | - | 100% | 100% | 100% |
|
1 | /***************************************************************************** | |
2 | * Copyright (c) PicoContainer Organization. All rights reserved. * | |
3 | * ------------------------------------------------------------------------- * | |
4 | * The software in this package is published under the terms of the BSD * | |
5 | * style license a copy of which has been included with this distribution in * | |
6 | * the LICENSE.txt file. * | |
7 | * * | |
8 | * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant * | |
9 | *****************************************************************************/ | |
10 | ||
11 | package org.picocontainer.defaults; | |
12 | ||
13 | import org.picocontainer.ComponentAdapter; | |
14 | import org.picocontainer.Parameter; | |
15 | import org.picocontainer.PicoIntrospectionException; | |
16 | ||
17 | import java.io.Serializable; | |
18 | ||
19 | ||
20 | /** | |
21 | * A {@link ComponentAdapterFactory} for JavaBeans. | |
22 | * The factory creates {@link SetterInjectionComponentAdapter}. | |
23 | * | |
24 | * @author Jörg Schaible | |
25 | * @version $Revision: 1279 $ | |
26 | */ | |
27 | public class SetterInjectionComponentAdapterFactory implements ComponentAdapterFactory, Serializable { | |
28 | private final boolean allowNonPublicClasses; | |
29 | ||
30 | 42 | public SetterInjectionComponentAdapterFactory(boolean allowNonPublicClasses) { |
31 | 42 | this.allowNonPublicClasses = allowNonPublicClasses; |
32 | } | |
33 | ||
34 | 42 | public SetterInjectionComponentAdapterFactory() { |
35 | 42 | this(false); |
36 | } | |
37 | ||
38 | /** | |
39 | * Create a {@link SetterInjectionComponentAdapter}. | |
40 | * | |
41 | * @param componentKey The component's key | |
42 | * @param componentImplementation The class of the bean. | |
43 | * @param parameters Any parameters for the setters. If null the adapter solves the | |
44 | * dependencies for all setters internally. Otherwise the number parameters must match | |
45 | * the number of the setter. | |
46 | * @return Returns a new {@link SetterInjectionComponentAdapter}. | |
47 | * @throws PicoIntrospectionException if dependencies cannot be solved | |
48 | * @throws AssignabilityRegistrationException | |
49 | * if the <code>componentKey</code> is a type | |
50 | * that does not match the implementation | |
51 | * @throws NotConcreteRegistrationException | |
52 | * if the implementation is an interface or an | |
53 | * abstract class. | |
54 | */ | |
55 | 20 | public ComponentAdapter createComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters) |
56 | throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { | |
57 | 20 | return new SetterInjectionComponentAdapter(componentKey, componentImplementation, parameters, allowNonPublicClasses); |
58 | } | |
59 | } |
|