Class ResourceStreamLocator
- java.lang.Object
-
- org.apache.wicket.core.util.resource.locator.ResourceStreamLocator
-
- All Implemented Interfaces:
IResourceStreamLocator
- Direct Known Subclasses:
OsgiResourceStreamLocator
public class ResourceStreamLocator extends Object implements IResourceStreamLocator
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 addingWebApplicationPath
s orPath
s toResourceSettings.getResourceFinders()
.- Author:
- Juergen Donnerstag, Jonathan Locke
-
-
Constructor Summary
Constructors Constructor Description ResourceStreamLocator()
ConstructorResourceStreamLocator(List<IResourceFinder> finders)
ConstructorResourceStreamLocator(IResourceFinder... finders)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IResourceStream
locate(Class<?> clazz, String path)
Locate a resource, given a path and class.IResourceStream
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.IResourceNameIterator
newResourceNameIterator(String path, Locale locale, String style, String variation, Iterable<String> extensions, boolean strict)
IResourceNameIterator
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 Detail
-
ResourceStreamLocator
public ResourceStreamLocator()
Constructor
-
ResourceStreamLocator
public ResourceStreamLocator(IResourceFinder... finders)
Constructor- Parameters:
finders
- resource finders. These will be tried in the given order.
-
ResourceStreamLocator
public ResourceStreamLocator(List<IResourceFinder> finders)
Constructor- Parameters:
finders
- resource finders. These will be tried in the given order.
-
-
Method Detail
-
locate
public IResourceStream locate(Class<?> clazz, String path)
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:
IResourceStreamLocator.locate(java.lang.Class, java.lang.String)
-
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:
IResourceStreamLocator.locate(java.lang.Class, java.lang.String, java.lang.String, java.lang.String, java.util.Locale, java.lang.String, boolean)
-
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:
IResourceStreamLocator.newResourceNameIterator(java.lang.String, java.util.Locale, java.lang.String, java.lang.String, java.lang.String, boolean)
-
newResourceNameIterator
public IResourceNameIterator newResourceNameIterator(String path, Locale locale, String style, String variation, Iterable<String> extensions, boolean strict)
-
-