org.apache.tapestry5.internal.services
Class PagePoolImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.services.PagePoolImpl
All Implemented Interfaces:
PagePool, InvalidationListener, UpdateListener

public class PagePoolImpl
extends Object
implements PagePool, InvalidationListener, UpdateListener

Registered as an invalidation listener with the page loader, the component messages source, and the component template source. Any time any of those notice a change, then the entire page pool is wiped.

The master page pool is, itself, divided into individual sub-pools, one for each combination of

This code is designed to handle high volume sites and deal with request fluctuations.

A soft limit on the number of page instances is enforced. Asking for a page instance when the soft limit has been reached (or exceeded) will result in a delay until a page instance (released from another thread) is available. The delay time is configurable.

A hard limit on the number of page instances is enforced. This number may not be exceeded. Requesting a page instance when at the hard limit will result in a runtime exception.

As an UpdateListener, the service will reduce the size of each page's pool by eliminating pages that haven't been used recently.

See Also:
PagePoolCache

Constructor Summary
PagePoolImpl(org.slf4j.Logger logger, PageLoader pageLoader, ThreadLocale threadLocale, int softLimit, long softWait, int hardLimit, long activeWindow)
           
 
Method Summary
 void checkForUpdates()
          On the periodic check for updates call, we clean up the caches, discarding unsued and out of date page instances.
 Page checkout(String pageName)
          Obtains a page instance from the pool via a logical page name.
 void discard(Page page)
          Discards a page, which occurs when there are errors invoking lifecycle methods on the page.
 void objectWasInvalidated()
          Any time templates, classes or messages change, we throw out all instances.
 void release(Page page)
          Releases a previously checked-out page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagePoolImpl

public PagePoolImpl(org.slf4j.Logger logger,
                    PageLoader pageLoader,
                    ThreadLocale threadLocale,
                    @Symbol(value="tapestry.page-pool.soft-limit")
                    int softLimit,
                    @Symbol(value="tapestry.page-pool.soft-wait")@IntermediateType(value=TimeInterval.class)
                    long softWait,
                    @Symbol(value="tapestry.page-pool.hard-limit")
                    int hardLimit,
                    @Symbol(value="tapestry.page-pool.active-window")@IntermediateType(value=TimeInterval.class)
                    long activeWindow)
Method Detail

checkout

public Page checkout(String pageName)
Description copied from interface: PagePool
Obtains a page instance from the pool via a logical page name. A page instance is created if no such page is currently available. The page pool enforces limits on the number of page instances (for any page name / locale combination) and may wait for a page to become available rather than create a new instance. There's also a hard limit, at which point an exception is raised.

Specified by:
checkout in interface PagePool
Parameters:
pageName - the canonical page name
Returns:
a page instance

release

public void release(Page page)
Description copied from interface: PagePool
Releases a previously checked-out page.

Specified by:
release in interface PagePool
Parameters:
page - a previously checked-out page

discard

public void discard(Page page)
Description copied from interface: PagePool
Discards a page, which occurs when there are errors invoking lifecycle methods on the page.

Specified by:
discard in interface PagePool
Parameters:
page - a previously checked-out page

objectWasInvalidated

public void objectWasInvalidated()
Any time templates, classes or messages change, we throw out all instances.

Specified by:
objectWasInvalidated in interface InvalidationListener

checkForUpdates

public void checkForUpdates()
On the periodic check for updates call, we clean up the caches, discarding unsued and out of date page instances.

Specified by:
checkForUpdates in interface UpdateListener


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.