01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: *****************************************************************************/package org.picocontainer.references;
09:
10: import org.picocontainer.ObjectReference;
11:
12: import java.util.Map;
13:
14: /** @author Paul Hammant */
15: public class ThreadLocalMapObjectReference implements ObjectReference {
16: private final ThreadLocal threadLocal;
17: private final Object componentKey;
18:
19: public ThreadLocalMapObjectReference(ThreadLocal threadLocal,
20: Object componentKey) {
21: this .threadLocal = threadLocal;
22: this .componentKey = componentKey;
23: }
24:
25: public Object get() {
26: return ((Map) threadLocal.get()).get(componentKey);
27: }
28:
29: public void set(Object item) {
30: ((Map) threadLocal.get()).put(componentKey, item);
31:
32: }
33: }
|