|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Loader<K,V>
A loader that could load a resource to another format.
It is mainly designed to work with ResourceCache
.
Nested Class Summary | |
---|---|
static class |
Loader.Resource<V>
Represents the more information about an object loaded by load(K) . |
Method Summary | |
---|---|
long |
getLastModified(K src)
Returns the last modified time, or -1 if reload is required or not exists. |
V |
load(K src)
Loads the resource. |
boolean |
shallCheck(K src,
long expiredMillis)
Returns whether to call getLastModified(K) . |
Method Detail |
---|
boolean shallCheck(K src, long expiredMillis)
getLastModified(K)
.
If false, it assumes the current cached content is up-to-date.
expiredMillis
- how many milli-seconds are expired after the last
check. In most cases, just return true if expiredMillis > 0long getLastModified(K src)
V load(K src) throws java.lang.Exception
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
of Loader.Resource
. Then, the return value of ResourceCache.get(java.lang.Object)
will be Loader.Resource.resource
.
java.lang.Exception
- you might throw any exception which will be
passed back to the caller of ResourceCache.get(java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |