CommunityManagerWSThreadLocalizer.java :  » Portal » Open-Portal » com » sun » portal » community » filter » Java Open Source

Java Open Source » Portal » Open Portal 
Open Portal » com » sun » portal » community » filter » CommunityManagerWSThreadLocalizer.java
/**
 * Copyright 2003 Sun Microsystems, Inc. All
 * rights reserved. Use of this product is subject
 * to license terms. Federal Acquisitions:
 * Commercial Software -- Government Users
 * Subject to Standard License Terms and
 * Conditions.
 *
 * Sun, Sun Microsystems, the Sun logo, and Sun ONE
 * are trademarks or registered trademarks of Sun Microsystems,
 * Inc. in the United States and other countries.
 */

package com.sun.portal.community.filter;

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

public class CommunityManagerWSThreadLocalizer {

    private static ThreadLocal requestThreadLocal = new ThreadLocal();  
    private static ThreadLocal responseThreadLocal = new ThreadLocal();  
    
    private CommunityManagerWSThreadLocalizer() {
    }
    
    public static void set(HttpServletRequest request, HttpServletResponse response) {
  requestThreadLocal.set(request);
  responseThreadLocal.set(response);
    }

    public static HttpServletRequest getRequest() throws NullPointerException {
  HttpServletRequest request = (HttpServletRequest)requestThreadLocal.get();
        if (request == null) {
            throw new NullPointerException("CommunityManagerWSThreadLocalizer:getRequest request was not present in thread local");
        }
  return request;
    }

    public static HttpServletResponse getResponse() throws NullPointerException {
  HttpServletResponse response = (HttpServletResponse)responseThreadLocal.get();
        if (response == null) {
            throw new NullPointerException("CommunityManagerWSThreadLocalizer:getResponse response was not present in thread local");
        }
  return response;
    }

}
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.