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 java.lang.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
IResourceFinders 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 addingWebApplicationPaths orPaths toResourceSettings.getResourceFinders().- Author:
- Juergen Donnerstag, Jonathan Locke
-
-
Constructor Summary
Constructors Constructor Description ResourceStreamLocator()ConstructorResourceStreamLocator(java.util.List<org.apache.wicket.util.file.IResourceFinder> finders)ConstructorResourceStreamLocator(org.apache.wicket.util.file.IResourceFinder... finders)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.wicket.util.resource.IResourceStreamlocate(java.lang.Class<?> clazz, java.lang.String path)Locate a resource, given a path and class.org.apache.wicket.util.resource.IResourceStreamlocate(java.lang.Class<?> clazz, java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String extension, boolean strict)Locate a resource by combining the given path, style, variation, locale and extension parameters.IResourceNameIteratornewResourceNameIterator(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.Iterable<java.lang.String> extensions, boolean strict)IResourceNameIteratornewResourceNameIterator(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.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(org.apache.wicket.util.file.IResourceFinder... finders)
Constructor- Parameters:
finders- resource finders. These will be tried in the given order.
-
ResourceStreamLocator
public ResourceStreamLocator(java.util.List<org.apache.wicket.util.file.IResourceFinder> finders)
Constructor- Parameters:
finders- resource finders. These will be tried in the given order.
-
-
Method Detail
-
locate
public org.apache.wicket.util.resource.IResourceStream locate(java.lang.Class<?> clazz, java.lang.String path)Description copied from interface:IResourceStreamLocatorLocate 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:
locatein 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 org.apache.wicket.util.resource.IResourceStream locate(java.lang.Class<?> clazz, java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String extension, boolean strict)Description copied from interface:IResourceStreamLocatorLocate a resource by combining the given path, style, variation, locale and extension parameters. The exact search order depends on the implementation.- Specified by:
locatein 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(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.String extension, boolean strict)
Description copied from interface:IResourceStreamLocatorMarkup 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:
newResourceNameIteratorin 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(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.Iterable<java.lang.String> extensions, boolean strict)
-
-