KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > ThreadLocalReference


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by Joerg Schaible *
9  *****************************************************************************/

10
11 package org.picocontainer.gems;
12
13
14 import org.picocontainer.defaults.ObjectReference;
15
16 import java.io.Serializable JavaDoc;
17
18
19 /**
20  * Implementation of an {@link org.picocontainer.defaults.ObjectReference} as
21  * {@link ThreadLocal}.
22  *
23  * @author Jörg Schaible
24  */

25 public class ThreadLocalReference
26         implements ObjectReference, Serializable JavaDoc {
27
28     private transient ThreadLocal JavaDoc instance = new ThreadLocal JavaDoc();
29
30     /**
31      * @see org.picocontainer.defaults.ObjectReference#get()
32      */

33     public Object JavaDoc get() {
34         return instance.get();
35     }
36
37     /**
38      * @see org.picocontainer.defaults.ObjectReference#set(java.lang.Object)
39      */

40     public void set(Object JavaDoc item) {
41         instance.set(item);
42     }
43 }
44
Popular Tags