001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry.services.impl;
016
017import javax.servlet.http.HttpServletRequest;
018import javax.servlet.http.HttpServletResponse;
019
020import org.apache.tapestry.IRequestCycle;
021import org.apache.tapestry.services.RequestGlobals;
022import org.apache.tapestry.web.WebRequest;
023import org.apache.tapestry.web.WebResponse;
024
025/**
026 * Wrapper around {@link org.apache.hivemind.service.ThreadLocalStorage}used to store and retrieve
027 * Servlet API info.
028 * 
029 * @author Howard Lewis Ship
030 * @since 4.0
031 */
032public class RequestGlobalsImpl implements RequestGlobals
033{
034    private WebRequest _webRequest;
035
036    private WebResponse _webResponse;
037
038    private HttpServletRequest _request;
039
040    private HttpServletResponse _response;
041
042    private IRequestCycle _requestCycle;
043
044    public WebRequest getWebRequest()
045    {
046        return _webRequest;
047    }
048
049    public WebResponse getWebResponse()
050    {
051        return _webResponse;
052    }
053
054    public HttpServletRequest getRequest()
055    {
056        return _request;
057    }
058
059    public HttpServletResponse getResponse()
060    {
061        return _response;
062    }
063
064    public void store(WebRequest request, WebResponse response)
065    {
066        _webRequest = request;
067        _webResponse = response;
068    }
069
070    public void store(HttpServletRequest request, HttpServletResponse response)
071    {
072        _request = request;
073        _response = response;
074    }
075
076    public IRequestCycle getRequestCycle()
077    {
078        return _requestCycle;
079    }
080
081    public void store(IRequestCycle cycle)
082    {
083        _requestCycle = cycle;
084    }
085}