DesktopRequestThreadLocalizer.java :  » Portal » Open-Portal » com » sun » portal » desktop » Java Open Source

Java Open Source » Portal » Open Portal 
Open Portal » com » sun » portal » desktop » DesktopRequestThreadLocalizer.java
/* 
 * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
 * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
 */
package com.sun.portal.desktop;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//
// this class may introduce some performance troubles using java 1.2, 
// but they are reported to be fixed in java 1.3.
//

public class DesktopRequestThreadLocalizer {
    private static ThreadLocal requestThreadLocal = new ThreadLocal();  
    private static ThreadLocal responseThreadLocal = new ThreadLocal();  

    private DesktopRequestThreadLocalizer() {
  // nothing, cannot be called
    }

  public static HttpServletRequest getRequest() {
      HttpServletRequest req = (HttpServletRequest)requestThreadLocal.get();
      return req;
  }

  public static HttpServletResponse getResponse() {
      HttpServletResponse res = (HttpServletResponse)responseThreadLocal.get();
      return res;
  }

    public static void set(HttpServletRequest req, HttpServletResponse res) {
  requestThreadLocal.set(req);
  responseThreadLocal.set(res);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.