Package org.zkoss.util.resource
Interface Loader<K,V>
- All Known Implementing Classes:
AbstractLoader,ContentLoader
public interface Loader<K,V>
A loader that could load a resource to another format.
It is mainly designed to work with
ResourceCache.- Author:
- tomyeh
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classRepresents the more information about an object loaded byload(K). -
Method Summary
Modifier and TypeMethodDescriptionlonggetLastModified(K src) Returns the last modified time, or -1 if reload is required or not exists.Loads the resource.booleanshallCheck(K src, long expiredMillis) Returns whether to callgetLastModified(K).
-
Method Details
-
shallCheck
Returns whether to callgetLastModified(K). If false, it assumes the current cached content is up-to-date.- Parameters:
expiredMillis- how many milli-seconds are expired after the last check. In most cases, just return true if expiredMillis > 0
-
getLastModified
Returns the last modified time, or -1 if reload is required or not exists. -
load
Loads the resource.The returned resource could be anything. It will be returned by
ResourceCache.get(java.lang.Object). However, if you want to have more control (e.g., whether to cache), you can return an instance ofLoader.Resource. Then, the return value ofResourceCache.get(java.lang.Object)will beLoader.Resource.resource.- Returns:
- null if not found
- Throws:
Exception- you might throw any exception which will be passed back to the caller ofResourceCache.get(java.lang.Object)
-