org.apache.tapestry.services
Interface AssetSource

All Known Implementing Classes:
AssetSourceImpl

public interface AssetSource

Used to find or create an Asset with a given path.

Assets are defined with a domain, and the domain is indicated by a prefix. The two builtin domains are "context:" (for files inside the web application context) and "classpath:" for files stored on the classpath (typically, inside a JAR, such as a component library).

See Also:
TapestryModule.contributeAssetSource(org.apache.tapestry.ioc.MappedConfiguration, AssetFactory, AssetFactory)

Method Summary
 Asset getAsset(Resource baseResource, String path, Locale locale)
          Finds the asset.
 Asset getClasspathAsset(String path)
          Obtains a classpath alias in the current locale (as defined by the ThreadLocale service).
 Asset getClasspathAsset(String path, Locale locale)
          Convienience for finding assets on the classpath.
 

Method Detail

getAsset

Asset getAsset(Resource baseResource,
               String path,
               Locale locale)
Finds the asset. The path may either be a simple file name or a relative path (relative to the base resource) or it may have a prefix, such as "context:" or "classpath:", in which case it is treated as a complete path within the indicated domain. The resulting Resource is then localized (to the provided Locale) and returned as an Asset.

The AssetSource caches its results, so a single Asset instance may be shared among many different components.

Parameters:
baseResource - base resource for computing relative paths, or null to search the classpath
path - relative to the base resource
locale - locale to localize the final resource to, or null for the thread's current locale
Returns:
the asset
Throws:
RuntimeException - if the asset can not be found

getClasspathAsset

Asset getClasspathAsset(String path,
                        Locale locale)
Convienience for finding assets on the classpath.

Parameters:
path - path to the base resource, relative to classpath root
locale - to localize the resource to
Returns:
the asset

getClasspathAsset

Asset getClasspathAsset(String path)
Obtains a classpath alias in the current locale (as defined by the ThreadLocale service).

Parameters:
path -
Returns:
the asset


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