01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.context;
06:
07: //
08: // this class may introduce some performance troubles using java 1.2,
09: // but they are reported to be fixed in java 1.3.
10: //
11:
12: public class DesktopAppContextThreadLocalizer {
13: //private static InheritableThreadLocal desktopAppContextThreadLocal = new InheritableThreadLocal();
14: private static ThreadLocal desktopAppContextThreadLocal = new ThreadLocal();
15:
16: private DesktopAppContextThreadLocalizer() {
17: // nothing, cannot be called
18: }
19:
20: public static DesktopAppContext get() {
21: DesktopAppContext dac = (DesktopAppContext) desktopAppContextThreadLocal
22: .get();
23: if (dac == null) {
24: throw new ContextError(
25: "DesktopContextThreadLocalizer.get(): no thread local set for this thread ID="
26: + Thread.currentThread().getName());
27: }
28:
29: return dac;
30: }
31:
32: public static void set(DesktopAppContext dac) {
33: desktopAppContextThreadLocal.set(dac);
34: }
35:
36: public static boolean exists() {
37: DesktopAppContext dac = (DesktopAppContext) desktopAppContextThreadLocal
38: .get();
39: if (dac != null)
40: return true;
41: else
42: return false;
43: }
44: }
|