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 *****************************************************************************/
010package org.picocontainer.behaviors;
011
012import org.picocontainer.ComponentAdapter;
013import org.picocontainer.ComponentMonitor;
014import org.picocontainer.LifecycleStrategy;
015import org.picocontainer.Parameter;
016import org.picocontainer.PicoCompositionException;
017import org.picocontainer.Characteristics;
018
019import java.io.Serializable;
020import java.util.Properties;
021
022@SuppressWarnings("serial")
023public class Automating extends AbstractBehaviorFactory implements Serializable {
024
025
026    public ComponentAdapter createComponentAdapter(ComponentMonitor componentMonitor,
027                                                   LifecycleStrategy lifecycleStrategy,
028                                                   Properties componentProperties,
029                                                   Object componentKey,
030                                                   Class componentImplementation,
031                                                   Parameter... parameters) throws PicoCompositionException {
032        removePropertiesIfPresent(componentProperties, Characteristics.AUTOMATIC);
033        return componentMonitor.newBehavior(new Automated(super.createComponentAdapter(componentMonitor,
034                                            lifecycleStrategy,
035                                            componentProperties,
036                                            componentKey,
037                                            componentImplementation,
038                                            parameters)));
039    }
040
041    public ComponentAdapter addComponentAdapter(ComponentMonitor componentMonitor,
042                                                LifecycleStrategy lifecycleStrategy,
043                                                Properties componentProperties,
044                                                ComponentAdapter adapter) {
045        removePropertiesIfPresent(componentProperties, Characteristics.AUTOMATIC);
046        return componentMonitor.newBehavior(new Automated(super.addComponentAdapter(componentMonitor,
047                                         lifecycleStrategy,
048                                         componentProperties,
049                                         adapter)));
050    }
051}