org.apache.tapestry.asset
Class ContextAssetFactory

java.lang.Object
  extended by org.apache.tapestry.asset.ContextAssetFactory
All Implemented Interfaces:
AssetFactory

public class ContextAssetFactory
extends Object
implements AssetFactory

All "context:" prefixed asset paths are interpreted relative to the web context (the web application's root folder).

Since:
4.0
Author:
Howard M. Lewis Ship

Constructor Summary
ContextAssetFactory()
           
 
Method Summary
 boolean assetExists(IComponentSpecification spec, org.apache.hivemind.Resource baseResource, String path, Locale locale)
          Invoked to check if the factory instance can find a matching asset using the appropriate strategy specific to its implementation.
 IAsset createAbsoluteAsset(String path, Locale locale, org.apache.hivemind.Location location)
          Creates a new asset relative to the root of the domain defined by the type of asset.
 IAsset createAsset(org.apache.hivemind.Resource baseResource, IComponentSpecification spec, String path, Locale locale, org.apache.hivemind.Location location)
          Creates a new asset relative to an existing asset.
 IAsset createAsset(org.apache.hivemind.Resource resource, org.apache.hivemind.Location location)
          Creates a new asset based on a known resource.
 void setContextPath(String contextPath)
           
 void setLocalizer(ResourceLocalizer localizer)
           
 void setRequestCycle(IRequestCycle cycle)
           
 void setWebContext(WebContext webContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextAssetFactory

public ContextAssetFactory()
Method Detail

setWebContext

public void setWebContext(WebContext webContext)

assetExists

public boolean assetExists(IComponentSpecification spec,
                           org.apache.hivemind.Resource baseResource,
                           String path,
                           Locale locale)
Description copied from interface: AssetFactory
Invoked to check if the factory instance can find a matching asset using the appropriate strategy specific to its implementation.

Specified by:
assetExists in interface AssetFactory
Parameters:
spec - The optional component specification to check the path against.
baseResource - The resource that the path may be relative to.
path - The asset path, relative to baseResource.
locale - Optional parameter when a localized version is desired. (may be null)
Returns:
True if the requested asset can be found, false otherwise.

createAsset

public IAsset createAsset(org.apache.hivemind.Resource baseResource,
                          IComponentSpecification spec,
                          String path,
                          Locale locale,
                          org.apache.hivemind.Location location)
Description copied from interface: AssetFactory
Creates a new asset relative to an existing asset.

Specified by:
createAsset in interface AssetFactory
Parameters:
baseResource - the base resource from which an asset path may be calculated. Each type of asset is linked to a particular implemenation of Resource, and generates a corresponding implementation of IAsset.
spec - The optional component specification to check the path against.
path - the path relative to the resource (if no leading slash), or an absolute path within the domain of the asset type (i.e, within the classpath, or within the web application).
locale - the desired locale of the asset; the closest match will be used.
location - the location to be associated with the returned asset, or null to not attempt to localize the asset
Returns:
The created asset.

createAbsoluteAsset

public IAsset createAbsoluteAsset(String path,
                                  Locale locale,
                                  org.apache.hivemind.Location location)
Description copied from interface: AssetFactory
Creates a new asset relative to the root of the domain defined by the type of asset.

Specified by:
createAbsoluteAsset in interface AssetFactory
Parameters:
path - the absolute path for the resource
locale - the locale to localize the asset to, or null for no localization
location - the location used to report any errors
Returns:
an IAsset

createAsset

public IAsset createAsset(org.apache.hivemind.Resource resource,
                          org.apache.hivemind.Location location)
Description copied from interface: AssetFactory
Creates a new asset based on a known resource.

Specified by:
createAsset in interface AssetFactory
Parameters:
resource - The resource the asset will represent.
location - Location of the resource. (used for error reporting mostly)
Returns:
The created asset.

setContextPath

public void setContextPath(String contextPath)

setLocalizer

public void setLocalizer(ResourceLocalizer localizer)

setRequestCycle

public void setRequestCycle(IRequestCycle cycle)


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