    001// Copyright 2006, 2007, 2008, 2009, 2011 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.internal.services;
    016
    017import org.apache.tapestry5.internal.structure.Page;
    018import org.apache.tapestry5.runtime.PageLifecycleListener;
    019
    020/**
    021 * Per-thread service that caches page instances for the duration of the request, and is also responsible for tracking
    022 * the active page (the page which will ultimately render the response).
    023 * <p/>
    024 * Since {@link org.apache.tapestry5.internal.structure.Page} is internal, most user-code should use the
    025 * {@link org.apache.tapestry5.services.ComponentSource} service instead.
    026 * <p>
    027 * Starting in 5.2, page instances are shared (with externalized mutable state), not pooled, but the cache is still
    028 * useful for managing the page's {@linkplain PageLifecycleListener lifecycle}.
    029 */
    030public interface RequestPageCache
    031{
    032    /**
    033     * Gets the page via its page name, in the current locale. The logical page name is resolved to a class name, which
    034     * is used to obtain the page (from the page pool). Note that under certain circumstances, a page may have multiple
    035     * names (even beyond simple case-insensitivity), and RequestPageCache caches correctly.
    036     *
    037     * @param pageName
    038     *            the name of the page to retrieve (this is the logical page name, not the fully qualified class
    039     *            name)
    040     * @return a page instance reserved for this request
    041     * @throws IllegalArgumentException
    042     *             if the name can not be resolved to a page instance
    043     */
    044    Page get(String pageName);
    045}