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
011package org.picocontainer.behaviors;
012
013import org.picocontainer.ComponentAdapter;
014import org.picocontainer.ComponentMonitor;
015import org.picocontainer.LifecycleStrategy;
016import org.picocontainer.Parameter;
017import org.picocontainer.PicoCompositionException;
018import org.picocontainer.behaviors.Decorated;
019import org.picocontainer.behaviors.AbstractBehaviorFactory;
020
021import 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 */
030public 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}