001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
005// http://www.apache.org/licenses/LICENSE-2.0
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
013package org.apache.tapestry5.internal.services;
015import org.apache.tapestry5.internal.structure.Page;
016import org.apache.tapestry5.runtime.PageLifecycleListener;
019 * Per-thread service that caches page instances for the duration of the request, and is also responsible for tracking
020 * the active page (the page which will ultimately render the response).
021 *
022 * Since {@link org.apache.tapestry5.internal.structure.Page} is internal, most user-code should use the
023 * {@link org.apache.tapestry5.services.ComponentSource} service instead.
024 *
025 * Starting in 5.2, page instances are shared (with externalized mutable state), not pooled, but the cache is still
026 * useful for managing the page's {@linkplain PageLifecycleListener lifecycle}.
027 */
028public interface RequestPageCache
030    /**
031     * Gets the page via its page name, in the current locale. The logical page name is resolved to a class name, which
032     * is used to obtain the page (from the page pool). Note that under certain circumstances, a page may have multiple
033     * names (even beyond simple case-insensitivity), and RequestPageCache caches correctly.
034     * 
035     * @param pageName
036     *            the name of the page to retrieve (this is the logical page name, not the fully qualified class
037     *            name)
038     * @return a page instance reserved for this request
039     * @throws IllegalArgumentException
040     *             if the name can not be resolved to a page instance
041     */
042    Page get(String pageName);