01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.container;
18:
19: import javax.portlet.Portlet;
20: import javax.portlet.PortletRequest;
21: import javax.portlet.PortletResponse;
22:
23: import org.apache.pluto.om.portlet.PortletDefinition;
24:
25: public class PortletRequestContext {
26: private static ThreadLocal context = new ThreadLocal();
27:
28: private PortletDefinition pd;
29: private Portlet portlet;
30: private PortletRequest request;
31: private PortletResponse response;
32:
33: public static PortletRequestContext getContext() {
34: return (PortletRequestContext) context.get();
35: }
36:
37: public static void createContext(PortletDefinition pd,
38: Portlet portlet, PortletRequest request,
39: PortletResponse response) {
40: context.set(new PortletRequestContext(pd, portlet, request,
41: response));
42: }
43:
44: public static void clearContext() {
45: context.set(null);
46: }
47:
48: private PortletRequestContext(PortletDefinition pd,
49: Portlet portlet, PortletRequest request,
50: PortletResponse response) {
51: this .pd = pd;
52: this .portlet = portlet;
53: this .request = request;
54: this .response = response;
55: }
56:
57: public PortletDefinition getPortletDefinition() {
58: return pd;
59: }
60:
61: public Portlet getPortlet() {
62: return portlet;
63: }
64:
65: public PortletRequest getRequest() {
66: return request;
67: }
68:
69: public PortletResponse getResponse() {
70: return response;
71: }
72: }
|