01: /**
02: * $Id: ProducerThreadLocalizer.java,v 1.4 2005/11/23 09:54:04 rt130506 Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wsrp.producer.filter;
14:
15: import javax.servlet.ServletRequest;
16: import javax.servlet.ServletResponse;
17: import javax.servlet.ServletContext;
18: import com.sun.portal.wsrp.common.OASISUsernameTokenProfile;
19:
20: public class ProducerThreadLocalizer {
21: private static ThreadLocal requestThreadLocal = new ThreadLocal();
22: private static ThreadLocal responseThreadLocal = new ThreadLocal();
23: private static ThreadLocal contextThreadLocal = new ThreadLocal();
24: private static ThreadLocal tokenProfileThreadLocal = new ThreadLocal();
25:
26: private ProducerThreadLocalizer() {
27: // nothing, cannot be called
28: }
29:
30: public static ServletRequest getRequest() {
31: ServletRequest req = (ServletRequest) requestThreadLocal.get();
32: return req;
33: }
34:
35: public static ServletResponse getResponse() {
36: ServletResponse res = (ServletResponse) responseThreadLocal
37: .get();
38: return res;
39: }
40:
41: public static ServletContext getContext() {
42: ServletContext ctx = (ServletContext) contextThreadLocal.get();
43: return ctx;
44: }
45:
46: public static OASISUsernameTokenProfile getTokenProfile() {
47: OASISUsernameTokenProfile profile = (OASISUsernameTokenProfile) tokenProfileThreadLocal
48: .get();
49: return profile;
50: }
51:
52: public static void setTokenProfile(OASISUsernameTokenProfile profile) {
53: tokenProfileThreadLocal.set(profile);
54: }
55:
56: public static void set(ServletContext ctx, ServletRequest req,
57: ServletResponse res) {
58: contextThreadLocal.set(ctx);
59: requestThreadLocal.set(req);
60: responseThreadLocal.set(res);
61: tokenProfileThreadLocal.set(null);
62: }
63: }
|