org.apache.tapestry.pageload
Class PageSource

java.lang.Object
  extended byorg.apache.tapestry.pageload.PageSource
All Implemented Interfaces:
IPageSource

public class PageSource
extends java.lang.Object
implements IPageSource

A source for pages for a particular application. Each application should have its own PageSource, storing it into the ServletContextusing a unique key (usually built from the application name).

The PageSource acts as a pool for IPageinstances. Pages are retrieved from the pool using getPage(IRequestCycle, String, IMonitor)and are later returned to the pool using releasePage(IPage).

TBD: Pooled pages stay forever. Need a strategy for cleaning up the pool, tracking which pages have been in the pool the longest, etc.

Author:
Howard Lewis Ship

Constructor Summary
PageSource()
           
 
Method Summary
protected  MultiKey buildKey(IEngine engine, java.lang.String pageName)
          Builds a key for a named page in the application's current locale.
protected  MultiKey buildKey(IPage page)
          Builds a key from an existing page, using the page's name and locale.
 org.apache.hivemind.ClassResolver getClassResolver()
           
 IPage getPage(IRequestCycle cycle, java.lang.String pageName, IMonitor monitor)
          Gets the page from a pool, or otherwise loads the page.
 void releasePage(IPage page)
          Returns the page to the appropriate pool.
 void setClassResolver(org.apache.hivemind.ClassResolver resolver)
           
 void setLoader(IPageLoader loader)
           
 void setPageSpecificationResolver(PageSpecificationResolver resolver)
           
 void setPool(ObjectPool pool)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageSource

public PageSource()
Method Detail

getClassResolver

public org.apache.hivemind.ClassResolver getClassResolver()
Specified by:
getClassResolver in interface IPageSource

buildKey

protected MultiKey buildKey(IEngine engine,
                            java.lang.String pageName)
Builds a key for a named page in the application's current locale.


buildKey

protected MultiKey buildKey(IPage page)
Builds a key from an existing page, using the page's name and locale. This is used when storing a page into the pool.


getPage

public IPage getPage(IRequestCycle cycle,
                     java.lang.String pageName,
                     IMonitor monitor)
Gets the page from a pool, or otherwise loads the page. This operation is threadsafe.

Specified by:
getPage in interface IPageSource
Parameters:
cycle - the current request cycle
pageName - the name of the page. May be qualified with a library id prefix, which may even be nested. Unqualified names are searched for extensively in the application namespace, and then in the framework namespace.
monitor - informed of any page loading activity
See Also:
PageSpecificationResolver.resolve(IRequestCycle, String)

releasePage

public void releasePage(IPage page)
Returns the page to the appropriate pool. Invokes IPage.detach().

Specified by:
releasePage in interface IPageSource

setPool

public void setPool(ObjectPool pool)
Since:
4.0

setClassResolver

public void setClassResolver(org.apache.hivemind.ClassResolver resolver)
Since:
4.0

setPageSpecificationResolver

public void setPageSpecificationResolver(PageSpecificationResolver resolver)
Since:
4.0

setLoader

public void setLoader(IPageLoader loader)
Since:
4.0