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;
06:
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: //
11: // this class may introduce some performance troubles using java 1.2,
12: // but they are reported to be fixed in java 1.3.
13: //
14:
15: public class DesktopRequestThreadLocalizer {
16: private static ThreadLocal requestThreadLocal = new ThreadLocal();
17: private static ThreadLocal responseThreadLocal = new ThreadLocal();
18:
19: private DesktopRequestThreadLocalizer() {
20: // nothing, cannot be called
21: }
22:
23: public static HttpServletRequest getRequest() {
24: HttpServletRequest req = (HttpServletRequest) requestThreadLocal
25: .get();
26: return req;
27: }
28:
29: public static HttpServletResponse getResponse() {
30: HttpServletResponse res = (HttpServletResponse) responseThreadLocal
31: .get();
32: return res;
33: }
34:
35: public static void set(HttpServletRequest req,
36: HttpServletResponse res) {
37: requestThreadLocal.set(req);
38: responseThreadLocal.set(res);
39: }
40: }
|