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.behaviors;
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.Characteristics;
018    
019    import java.io.Serializable;
020    import java.util.Properties;
021    
022    public class Automatic extends AbstractBehaviorFactory implements Serializable {
023    
024        public ComponentAdapter createComponentAdapter(ComponentMonitor componentMonitor,
025                                                       LifecycleStrategy lifecycleStrategy,
026                                                       Properties componentProperties,
027                                                       Object componentKey,
028                                                       Class componentImplementation,
029                                                       Parameter... parameters) throws PicoCompositionException {
030            removePropertiesIfPresent(componentProperties, Characteristics.AUTOMATIC);
031            return new Automated(super.createComponentAdapter(componentMonitor,
032                                                lifecycleStrategy,
033                                                componentProperties,
034                                                componentKey,
035                                                componentImplementation,
036                                                parameters));
037        }
038    
039        public ComponentAdapter addComponentAdapter(ComponentMonitor componentMonitor,
040                                                    LifecycleStrategy lifecycleStrategy,
041                                                    Properties componentProperties,
042                                                    ComponentAdapter adapter) {
043            removePropertiesIfPresent(componentProperties, Characteristics.AUTOMATIC);
044            return new Automated(super.addComponentAdapter(componentMonitor,
045                                             lifecycleStrategy,
046                                             componentProperties,
047                                             adapter));
048        }
049    }