Module org.apache.wicket.core
Class ResourceStreamLocator
java.lang.Object
org.apache.wicket.core.util.resource.locator.ResourceStreamLocator
- All Implemented Interfaces:
IResourceStreamLocator
- Direct Known Subclasses:
OsgiResourceStreamLocator
Locates Wicket resources.
Contains the logic to locate a resource based on a path, a variation, a style (see
Session
), a locale and an extension string. The full filename will be
built like: <path>_<variation>_<style>_<locale>.<extension>.
Resource matches will be attempted in the following order:
- <path>_<variation>_<style>_<locale>.<extension>
- <path>_<style>_<locale>.<extension>
- <path>_<locale>.<extension>
- <path>_<style>.<extension>
- <path>.<extension>
Locales may contain a language, a country and a region or variant. Combinations of these components will be attempted in the following order:
- locale.toString() see javadoc for Locale for more details
- <language>_<country>
- <language>
Resources will be actually loaded by the IResourceFinder
s defined in the resource
settings. By default there are finders that look in the classpath and in the classpath in
META-INF/resources. You can add more by adding WebApplicationPath
s or Path
s to
ResourceSettings.getResourceFinders()
.
- Author:
- Juergen Donnerstag, Jonathan Locke
-
Constructor Summary
ConstructorDescriptionConstructorResourceStreamLocator
(List<IResourceFinder> finders) ConstructorResourceStreamLocator
(IResourceFinder... finders) Constructor -
Method Summary
Modifier and TypeMethodDescriptionLocate a resource, given a path and class.locate
(Class<?> clazz, String path, String style, String variation, Locale locale, String extension, boolean strict) Locate a resource by combining the given path, style, variation, locale and extension parameters.newResourceNameIterator
(String path, Locale locale, String style, String variation, Iterable<String> extensions, boolean strict) newResourceNameIterator
(String path, Locale locale, String style, String variation, String extension, boolean strict) Markup resources and Properties files both need to iterate over different combinations of locale, style, etc..
-
Constructor Details
-
ResourceStreamLocator
public ResourceStreamLocator()Constructor -
ResourceStreamLocator
Constructor- Parameters:
finders
- resource finders. These will be tried in the given order.
-
ResourceStreamLocator
Constructor- Parameters:
finders
- resource finders. These will be tried in the given order.
-
-
Method Details
-
locate
Description copied from interface:IResourceStreamLocator
Locate a resource, given a path and class. Typically this method is either called by external clients if they are not interested in a lookup that takes the style and locale into account, or it is called by the implementation ofIResourceStreamLocator.locate(Class, String, String, String, java.util.Locale, String, boolean)
where the latter just takes care of trying out the different combinations for the provided style and locale and uses this method to actually load the resource stream.- Specified by:
locate
in interfaceIResourceStreamLocator
- Parameters:
clazz
- The class loader for delegating the loading of the resourcepath
- The path of the resource- Returns:
- The resource or null
- See Also:
-
locate
public IResourceStream locate(Class<?> clazz, String path, String style, String variation, Locale locale, String extension, boolean strict) Description copied from interface:IResourceStreamLocator
Locate a resource by combining the given path, style, variation, locale and extension parameters. The exact search order depends on the implementation.- Specified by:
locate
in interfaceIResourceStreamLocator
- Parameters:
clazz
- The class loader for delegating the loading of the resourcepath
- The path of the resourcestyle
- Any resource style, such as a skin style (seeSession
)variation
- The component's variation (of the style)locale
- The locale of the resource to loadextension
- A comma separate list of extensionsstrict
- whether the specified attributes must match exactly- Returns:
- The resource or null
- See Also:
-
newResourceNameIterator
public IResourceNameIterator newResourceNameIterator(String path, Locale locale, String style, String variation, String extension, boolean strict) Description copied from interface:IResourceStreamLocator
Markup resources and Properties files both need to iterate over different combinations of locale, style, etc.. And though no single locate(..) method exists which is used by both, they both use ResourceNameIterators.- Specified by:
newResourceNameIterator
in interfaceIResourceStreamLocator
- Parameters:
path
- The path of the resourcelocale
- The locale of the resource to loadstyle
- Any resource style, such as a skin style (seeSession
)variation
- The component's variation (of the style)extension
- A comma separate list of extensionsstrict
- whether the specified attributes must match exactly- Returns:
- resource name iterator
- See Also:
-
newResourceNameIterator
public IResourceNameIterator newResourceNameIterator(String path, Locale locale, String style, String variation, Iterable<String> extensions, boolean strict)
-