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: import com.sun.portal.providers.context.ProviderContext;
08:
09: import com.sun.portal.desktop.context.DesktopAppContextThreadLocalizer;
10:
11: //
12: // this class may introduce some performance troubles using java 1.2,
13: // but they are reported to be fixed in java 1.3.
14: //
15:
16: public class ProviderContextThreadLocalizer {
17: //private static InheritableThreadLocal providerContextThreadLocal = new InheritableThreadLocal();
18: private static ThreadLocal providerContextThreadLocal = new ThreadLocal();
19:
20: private ProviderContextThreadLocalizer() {
21: // nothing, cannot be called
22: }
23:
24: public static ProviderContext get() {
25: ProviderContext pc = (ProviderContext) providerContextThreadLocal
26: .get();
27: if (pc == null) {
28: throw new ContextError(
29: "ProviderContextThreadLocalizer.get(): no thread local set for this thread ID="
30: + Thread.currentThread().getName());
31: }
32:
33: return pc;
34: }
35:
36: public static void set(ProviderContext pc) {
37: providerContextThreadLocal.set(pc);
38: }
39: }
|