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 the committers                                           *
009     *****************************************************************************/
010    package org.picocontainer.containers;
011    
012    import java.util.Properties;
013    import org.picocontainer.ComponentAdapter;
014    import org.picocontainer.MutablePicoContainer;
015    import org.picocontainer.Parameter;
016    import org.picocontainer.PicoCompositionException;
017    import org.picocontainer.PicoContainer;
018    import org.picocontainer.lifecycle.LifecycleState;
019    
020    /**
021     * abstract base class for delegating to mutable containers
022     * @author Paul Hammant
023     */
024    public abstract class AbstractDelegatingMutablePicoContainer extends AbstractDelegatingPicoContainer implements MutablePicoContainer {
025    
026        public AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate) {
027                    super(delegate);
028            }
029    
030            public MutablePicoContainer addComponent(Object componentKey,
031                                                 Object componentImplementationOrInstance,
032                                                 Parameter... parameters) throws PicoCompositionException {
033            return getDelegate().addComponent(componentKey, componentImplementationOrInstance, parameters);
034        }
035    
036        public MutablePicoContainer addComponent(Object implOrInstance) throws PicoCompositionException {
037            return getDelegate().addComponent(implOrInstance);
038        }
039    
040        public MutablePicoContainer addConfig(String name, Object val) {
041            return getDelegate().addConfig(name, val); 
042        }
043    
044        public MutablePicoContainer addAdapter(ComponentAdapter<?> componentAdapter) throws PicoCompositionException {
045            return getDelegate().addAdapter(componentAdapter);
046        }
047    
048        public <T> ComponentAdapter<T> removeComponent(Object componentKey) {
049            return getDelegate().removeComponent(componentKey);
050        }
051    
052        public <T> ComponentAdapter<T> removeComponentByInstance(T componentInstance) {
053            return getDelegate().removeComponentByInstance(componentInstance);
054        }
055    
056        public MutablePicoContainer addChildContainer(PicoContainer child) {
057            return getDelegate().addChildContainer(child);
058        }
059    
060        public boolean removeChildContainer(PicoContainer child) {
061            return getDelegate().removeChildContainer(child);
062        }
063    
064            public MutablePicoContainer change(Properties... properties) {
065                return getDelegate().change(properties);
066            }
067    
068            public MutablePicoContainer as(Properties... properties) {
069                return getDelegate().as(properties);
070            }
071            
072            public void dispose() {
073                    getDelegate().dispose();
074            }
075    
076            public MutablePicoContainer makeChildContainer() {
077    
078                    return null;
079            }
080    
081            public void start() {
082                    getDelegate().start();
083            }
084    
085            public void stop() {
086                    getDelegate().stop();
087            }
088    
089            public MutablePicoContainer getDelegate() {
090                    return (MutablePicoContainer) super.getDelegate();
091            }
092    
093        public void setName(String name) {
094            getDelegate().setName(name);
095        }
096    
097        public void setLifecycleState(LifecycleState lifecycleState) {
098            getDelegate().setLifecycleState(lifecycleState);
099        }
100    
101    }