public class AssetSourceImpl extends LockSupport implements AssetSource
Constructor and Description |
---|
AssetSourceImpl(ThreadLocale threadLocale,
Map<String,AssetFactory> configuration,
SymbolSource symbolSource,
org.slf4j.Logger logger,
OperationTracker tracker) |
AssetSourceImpl(ThreadLocale threadLocale,
Map<String,AssetFactory> configuration,
SymbolSource symbolSource,
org.slf4j.Logger logger,
OperationTracker tracker,
Request request) |
Modifier and Type | Method and Description |
---|---|
void |
clearCacheWhenResourcesChange(ResourceChangeTracker tracker) |
Asset |
getAsset(Resource baseResource,
String path,
Locale locale)
Finds the asset.
|
Asset |
getClasspathAsset(String path)
Obtains a classpath asset in the current locale (as defined by the
ThreadLocale service). |
Asset |
getClasspathAsset(String path,
Locale locale)
Convenience for finding assets on the classpath.
|
Asset |
getComponentAsset(ComponentResources resources,
String path,
String libraryName)
Gets an asset that is used with, or injected into, a component, that will be exposed to the client.
|
Asset |
getContextAsset(String path,
Locale locale)
Convenience for finding assets in the context.
|
Asset |
getExpandedAsset(String path)
As with
AssetSource.getUnlocalizedAsset(String) , but symbols
in the path are expanded}. |
Asset |
getUnlocalizedAsset(String path)
Find an asset but does not attempt to localize it.
|
Resource |
resourceForPath(String path)
Finds the asset, either on the classpath or (if prefixed), within the indicated domain.
|
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLock
public AssetSourceImpl(ThreadLocale threadLocale, Map<String,AssetFactory> configuration, SymbolSource symbolSource, org.slf4j.Logger logger, OperationTracker tracker)
public AssetSourceImpl(ThreadLocale threadLocale, Map<String,AssetFactory> configuration, SymbolSource symbolSource, org.slf4j.Logger logger, OperationTracker tracker, Request request)
@PostInjection public void clearCacheWhenResourcesChange(ResourceChangeTracker tracker)
public Asset getClasspathAsset(String path)
AssetSource
ThreadLocale
service).getClasspathAsset
in interface AssetSource
path
- relative to the classpath rootpublic Asset getClasspathAsset(String path, Locale locale)
AssetSource
getClasspathAsset
in interface AssetSource
path
- path to the base resource, relative to classpath rootlocale
- to localize the resource topublic Asset getContextAsset(String path, Locale locale)
AssetSource
getContextAsset
in interface AssetSource
path
- path relative to the base resource (the context root)locale
- to localize the resource to, or null for the locale for the current requestpublic Asset getAsset(Resource baseResource, String path, Locale locale)
AssetSource
getAsset
in interface AssetSource
baseResource
- base resource for computing relative paths, or null to search the classpathpath
- relative to the base resourcelocale
- locale to localize the final resource to, or null for the thread's current localepublic Resource resourceForPath(String path)
AssetSource
resourceForPath
in interface AssetSource
path
- to the resource to provide as an Assetpublic Asset getExpandedAsset(String path)
AssetSource
AssetSource.getUnlocalizedAsset(String)
, but symbols
in the path are expanded}.getExpandedAsset
in interface AssetSource
public Asset getComponentAsset(ComponentResources resources, String path, String libraryName)
AssetSource
META-INF/assets/library-name/
.
This is the preferred location in 5.4, with compatibility for 5.3 that allows assets to be stored on the classpath
alongside Java classes and server-only resources such as templates and message catalogs.
When resolving a resource in a component that is subclass, the point of injection is the class which contains
the injecting annotation (e.g., Inject
with Path
,
or Import
). In other words, the library name for the library containing the class,
rather than the library name of the instantiated subclass (which can be different).getComponentAsset
in interface AssetSource
resources
- resources, used to identify starting location of asset (if path does not include a asset prefix).path
- path to the resource; either fully qualified (with an asset prefix such as "context:"), or relative to the
component's library asset folder (the 5.4 and beyond way), or the to the component's Java class file (the 5.3 and earlier
way, still supported until at least 5.5).
Symbols in the path are expanded.libraryName
- The name of the library containing the component, as per ComponentModel.getLibraryName()
.
For a subclass, the libraryName must reflect the name of the library for the parent class that forms the basis of
injection.public Asset getUnlocalizedAsset(String path)
AssetSource
getUnlocalizedAsset
in interface AssetSource
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.