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 015 package org.apache.tapestry.engine; 016 017 import org.apache.hivemind.ClassResolver; 018 import org.apache.tapestry.IPage; 019 import 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 031 public 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 * @return The loaded page. 044 * 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 IPage getPage(IRequestCycle cycle, String pageName); 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 * @param page The page to release. 058 */ 059 void releasePage(IPage page); 060 061 /** 062 * Gets the class resolver used to load all pages / page components. 063 * 064 * @return {@link ClassResolver} instance used to load classes. 065 */ 066 067 ClassResolver getClassResolver(); 068 }