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    
013    import org.picocontainer.ComponentAdapter;
014    import org.picocontainer.PicoContainer;
015    import org.picocontainer.PicoCompositionException;
016    import org.picocontainer.behaviors.AbstractBehavior;
017    
018    import java.lang.reflect.Type;
019    
020    /**
021     * Component Adapter that uses java synchronized around getComponentInstance().
022     * @author Aslak Hellesøy
023     * @author Manish Shah
024     */
025    @SuppressWarnings("serial")
026    public class Synchronized<T> extends AbstractBehavior<T> {
027    
028    
029            public Synchronized(ComponentAdapter<T> delegate) {
030            super(delegate);
031        }
032    
033        public synchronized T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException {
034            return super.getComponentInstance(container, into);
035        }
036    
037        public String getDescriptor() {
038            return "Synchronized"; 
039        }
040    
041    }