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.ComponentAdapter;
013    import org.picocontainer.ComponentMonitor;
014    import org.picocontainer.LifecycleStrategy;
015    import org.picocontainer.Parameter;
016    import org.picocontainer.PicoCompositionException;
017    import org.picocontainer.InjectionFactory;
018    import org.picocontainer.annotations.Inject;
019    
020    import java.util.Properties;
021    import java.io.Serializable;
022    
023    public class AnnotatedFieldInjection implements InjectionFactory, Serializable {
024    
025        private final Class injectionAnnotation;
026    
027        public AnnotatedFieldInjection(Class injectionAnnotation) {
028            this.injectionAnnotation = injectionAnnotation;
029        }
030    
031        public AnnotatedFieldInjection() {
032            this(Inject.class);
033        }
034    
035        public ComponentAdapter createComponentAdapter(ComponentMonitor componentMonitor,
036                                                       LifecycleStrategy lifecycleStrategy,
037                                                       Properties componentProperties,
038                                                       Object componentKey,
039                                                       Class componentImplementation,
040                                                       Parameter... parameters)
041            throws PicoCompositionException {
042            return new AnnotatedFieldInjector(componentKey, componentImplementation, parameters, componentMonitor, lifecycleStrategy,
043                                              injectionAnnotation);
044        }
045    }