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     * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant   *
009     *****************************************************************************/
010    
011    package org.picocontainer.behaviors;
012    
013    import org.picocontainer.ComponentAdapter;
014    import org.picocontainer.references.ThreadLocalReference;
015    
016    /**
017     * <p>
018     * This behavior supports caches values per thread.
019     * </p>
020     *
021     * @author Paul Hammant
022     */
023    @SuppressWarnings("serial")
024    public final class ThreadCached<T> extends Stored<T>{
025    
026        public ThreadCached(ComponentAdapter<T> delegate) {
027            super(delegate, new ThreadLocalReference<Instance<T>>());
028        }
029    
030        public String getDescriptor() {
031            return "ThreadCached" + getLifecycleDescriptor();
032        }
033    }