    001    /*****************************************************************************
    002     * Copyright (C) NanoContainer 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 Joerg Schaibe                                            *
    009     *****************************************************************************/
    010
    011    package org.picocontainer.behaviors;
    012
    013    import org.picocontainer.ComponentAdapter;
    014    import org.picocontainer.ComponentMonitor;
    015    import org.picocontainer.LifecycleStrategy;
    016    import org.picocontainer.Parameter;
    017    import org.picocontainer.PicoCompositionException;
    018    import org.picocontainer.behaviors.Decorated;
    019    import org.picocontainer.behaviors.AbstractBehaviorFactory;
    020
    021    import java.util.Properties;
    022
    023
    024    /**
    025     * BehaviorFactory for Decorating. This factory will create {@link org.picocontainer.gems.behaviors.Decorated} that will
    026     * allow you to decorate what you like on the component instance that has been created
    027     *
    028     * @author Paul Hammant
    029     */
    030    public abstract class Decorating extends AbstractBehaviorFactory implements Decorated.Decorator {
    031
    032
    033        public ComponentAdapter createComponentAdapter(ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy,
    034                                                       Properties componentProperties, final Object componentKey,
    035                                                       final Class componentImplementation, final Parameter... parameters) throws PicoCompositionException {
    036            return componentMonitor.newBehavior(new Decorated(super.createComponentAdapter(componentMonitor, lifecycleStrategy,
    037                    componentProperties,componentKey, componentImplementation, parameters), this));
    038        }
    039
    040
    041        public ComponentAdapter addComponentAdapter(ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy,
    042                                                    Properties componentProperties, ComponentAdapter adapter) {
    043            return super.addComponentAdapter(componentMonitor, lifecycleStrategy, componentProperties, adapter);
    044        }
    045    }