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.engine;
016
017import org.apache.hivemind.ClassResolver;
018import org.apache.tapestry.IPage;
019import org.apache.tapestry.IRequestCycle;
020
021/**
022 * Abstracts the process of loading pages from thier specifications as well as pooling of pages once
023 * loaded.
024 * <p>
025 * If the required page is not available, a page source may use an instance of {@link IPageLoader}
026 * to actually load the page (and all of its nested components).
027 * 
028 * @author Howard Lewis Ship
029 */
030
031public interface IPageSource
032{
033    /**
034     * Gets a given page for the engine. This may involve using a previously loaded page from a pool
035     * of available pages, or the page may be loaded as needed.
036     * 
037     * @param cycle
038     *            the current request cycle
039     * @param pageName
040     *            the name of the page. May be qualified with a library id prefix, which may even be
041     *            nested. Unqualified names are searched for extensively in the application
042     *            namespace, and then in the framework namespace.
043     * @param monitor
044     *            informed of any page loading activity
045     * @throws org.apache.tapestry.PageNotFoundException
046     *             if pageName can't be resolved to a page specification (from which a page instance
047     *             can be generated).
048     * @see org.apache.tapestry.resolver.PageSpecificationResolver#resolve(IRequestCycle, String)
049     */
050
051    public IPage getPage(IRequestCycle cycle, String pageName, IMonitor monitor);
052
053    /**
054     * Invoked after the engine is done with the page (typically, after the response to the client
055     * has been sent). The page is returned to the pool for later reuse.
056     */
057
058    public void releasePage(IPage page);
059
060    /**
061     * @since 3.0
062     */
063
064    public ClassResolver getClassResolver();
065
066}