KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > SetterInjectionComponentAdapterFactory


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 JavaDoc;
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 JavaDoc {
28     private final boolean allowNonPublicClasses;
29
30     public SetterInjectionComponentAdapterFactory(boolean allowNonPublicClasses) {
31         this.allowNonPublicClasses = allowNonPublicClasses;
32     }
33
34     public SetterInjectionComponentAdapterFactory() {
35         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     public ComponentAdapter createComponentAdapter(Object JavaDoc componentKey, Class JavaDoc componentImplementation, Parameter[] parameters)
56             throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException {
57         return new SetterInjectionComponentAdapter(componentKey, componentImplementation, parameters, allowNonPublicClasses);
58     }
59 }
60
Popular Tags