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.services;
016
017import javax.servlet.http.HttpServletRequest;
018import javax.servlet.http.HttpServletResponse;
019
020/**
021 * Service used to store the current request objects, both the Servlet API versions, and the
022 * Tapestry generic versions.
023 * The service has a per-thread scope.
024 */
025public interface RequestGlobals
026{
027    /**
028     * Stores the servlet API request and response objects, for access via the properties.
029     */
030    void storeServletRequestResponse(HttpServletRequest request, HttpServletResponse response);
031
032    /**
033     * The Servlet API Request. This is exposed as service HTTPServletRequest.
034     */
035    HttpServletRequest getHTTPServletRequest();
036
037    HttpServletResponse getHTTPServletResponse();
038
039    void storeRequestResponse(Request request, Response response);
040
041    /**
042     * The current request. This is exposed as service Request.
043     */
044    Request getRequest();
045
046    /**
047     * The current response. This is exposed as service Response.
048     */
049    Response getResponse();
050
051    /**
052     * Stores the <a href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/ComponentClassResolver.html#canonicalizePageName-java.lang.String-">canonicalized</a>
053     * name of the active page for this request.
054     * 
055     * @param pageName
056     *            name of page (probably extracted from the URL)
057     * @since 5.2.0
058     */
059    void storeActivePageName(String pageName);
060
061    /**
062     * Returns the active page name previously stored.
063     * 
064     * @return canonicalized page name
065     * @since 5.2.0
066     */
067    String getActivePageName();
068}