    001// Copyright 2006, 2007, 2008 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.tapestry5.http.internal.services;
    016
    017import org.apache.tapestry5.http.services.Request;
    018import org.apache.tapestry5.http.services.RequestGlobals;
    019import org.apache.tapestry5.http.services.Response;
    020import org.apache.tapestry5.ioc.ScopeConstants;
    021import org.apache.tapestry5.ioc.annotations.Scope;
    022
    023import javax.servlet.http.HttpServletRequest;
    024import javax.servlet.http.HttpServletResponse;
    025
    026/**
    027 * Dumb data holder for per-request data.
    028 */
    029@Scope(ScopeConstants.PERTHREAD)
    030public class RequestGlobalsImpl implements RequestGlobals
    031{
    032    private HttpServletRequest servletRequest;
    033
    034    private HttpServletResponse servletResponse;
    035
    036    private Request request;
    037
    038    private Response response;
    039
    040    private String activePageName;
    041
    042    public void storeServletRequestResponse(HttpServletRequest request, HttpServletResponse response)
    043    {
    044        servletRequest = request;
    045        servletResponse = response;
    046    }
    047
    048    public HttpServletRequest getHTTPServletRequest()
    049    {
    050        return servletRequest;
    051    }
    052
    053    public HttpServletResponse getHTTPServletResponse()
    054    {
    055        return servletResponse;
    056    }
    057
    058    public void storeRequestResponse(Request request, Response response)
    059    {
    060        this.request = request;
    061        this.response = response;
    062    }
    063
    064    public Request getRequest()
    065    {
    066        return request;
    067    }
    068
    069    public Response getResponse()
    070    {
    071        return response;
    072    }
    073
    074    public String getActivePageName()
    075    {
    076        return activePageName;
    077    }
    078
    079    public void storeActivePageName(String pageName)
    080    {
    081        this.activePageName = pageName;
    082    }
    083
    084}