1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */17packageorg.apache.jetspeed.container.invoker;
1819import java.util.HashMap;
20import java.util.Map;
2122import javax.servlet.http.HttpServletRequest;
23import javax.servlet.http.HttpServletRequestWrapper;
2425/***26 * Local servlet request wrapper. The purpose of this wrapper is to hold 27 * attribute information that is need for each request. In a threaded environment, 28 * each thread needs to have its own copy of this information so that there is 29 * not a timing issue with the original request object. 30 * Also, since the original request is no longer "holding" the attributes, 31 * there is no reason to remove them in the finally block. 32 * The LocalServletRequest object is automatically garbage collected at then 33 * end of this method.34 *35 * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>36 * @author <a href="">David Gurney</a>37 * @version $Id: $38 */39publicclassLocalServletRequestextends HttpServletRequestWrapper
40 {
41private Map attributeMap = new HashMap();
4243private HttpServletRequest originalRequest = null;
4445publicLocalServletRequest(HttpServletRequest request)
46 {
47super(request);
48 originalRequest = request;
49 }
5051public Object getAttribute(String p_sKey)
52 {
53 Object a_oValue = attributeMap.get(p_sKey);
54if (a_oValue == null)
55 {
56 a_oValue = originalRequest.getAttribute(p_sKey);
57 }
5859return a_oValue;
60 }
6162publicvoid removeAttribute(String key)
63 {
64 Object value = attributeMap.remove(key);
65if (value == null)
66 {
67 originalRequest.removeAttribute(key);
68 }
69 }
7071publicvoid setAttribute(String key, Object value)
72 {
73 attributeMap.put(key, value);
74 }
7576 }