|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.core.util.resource.locator.caching.CachingResourceStreamLocator
public class CachingResourceStreamLocator
Locating resources can take a significant amount of time, especially since there are often several CSS, JavaScript and image resources on any given page. To facilitate localization and styling, Wicket will usually make several attempts at locating each resource (i.e. first with an "en_US" suffix, then "en", and so on); multiply these attempts by the number of resources on the page and this starts to add up.
This locator mitigates this problem by caching (indefinitely) references to
UrlResourceStream
and FileResourceStream
objects as they are found, and
NullResourceStreamReference
for all which are missing so they are not looked up again and
again.
Constructor Summary | |
---|---|
CachingResourceStreamLocator(IResourceStreamLocator resourceStreamLocator)
Construct. |
Method Summary | |
---|---|
IResourceStream |
locate(Class<?> clazz,
String path)
Locate a resource, given a path and class. |
IResourceStream |
locate(Class<?> scope,
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,
String extension,
boolean strict)
Markup resources and Properties files both need to iterate over different combinations of locale, style, etc.. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachingResourceStreamLocator(IResourceStreamLocator resourceStreamLocator)
resourceStreamLocator
- the delegateMethod Detail |
---|
public IResourceStream locate(Class<?> clazz, String path)
IResourceStreamLocator.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.
Checks for IResourceStreamReference
in the cache and returns null
if the
result is NullResourceStreamReference.INSTANCE
, or FileResourceStream
/
UrlResourceStream
if there is an entry in the cache. Otherwise asks the delegate to
find one and puts it in the cache.
locate
in interface IResourceStreamLocator
clazz
- The class loader for delegating the loading of the resourcepath
- The path of the resource
public IResourceStream locate(Class<?> scope, String path, String style, String variation, Locale locale, String extension, boolean strict)
IResourceStreamLocator
locate
in interface IResourceStreamLocator
scope
- The class loader for delegating the loading of the resourcepath
- The path of the resourcestyle
- Any resource style, such as a skin style (see Session
)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
public IResourceNameIterator newResourceNameIterator(String path, Locale locale, String style, String variation, String extension, boolean strict)
IResourceStreamLocator
newResourceNameIterator
in interface IResourceStreamLocator
path
- The path of the resourcelocale
- The locale of the resource to loadstyle
- Any resource style, such as a skin style (see Session
)variation
- The component's variation (of the style)extension
- A comma separate list of extensionsstrict
- whether the specified attributes must match exactly
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |