Class ExtendletLoader<V>

  extended by org.zkoss.web.util.resource.ExtendletLoader<V>
All Implemented Interfaces:

public abstract class ExtendletLoader<V>
extends java.lang.Object
implements Loader<java.lang.String,V>

A skeletal implementation of the loader used to implement an extendlet. All you have to do is to implement parse(, java.lang.String, java.lang.String) and getExtendletContext().

If the real path is not the same as the path specified in URL, you can override getRealPath(java.lang.String).

See Also:

Nested Class Summary
Nested classes/interfaces inherited from interface org.zkoss.util.resource.Loader
Constructor Summary
protected ExtendletLoader()
Method Summary
 int getCheckPeriod()
          Returns the check period, or -1 if the content is never changed.
protected abstract  ExtendletContext getExtendletContext()
          Returns the extendlet context.
 long getLastModified(java.lang.String src)
          Returns the last modified time.
protected  java.lang.String getRealPath(java.lang.String path)
          Returns the real path for the specified path.
 V load(java.lang.String src)
          Loads the resource.
protected abstract  V parse( is, java.lang.String path, java.lang.String orgpath)
          It is called to parse the resource into an intermediate format depending on Extendlet.
 boolean shallCheck(java.lang.String src, long expiredMillis)
          Returns whether to call Loader.getLastModified(K).
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


protected ExtendletLoader()
Method Detail


protected java.lang.String getRealPath(java.lang.String path)
Returns the real path for the specified path.

Default: return path, i.e., the path specified in URL is the real path.

Notice that parse(, java.lang.String, java.lang.String) will receive the original path (rather than the returned path).

path - the path specified in URL. Notice that it does NOT start with "~./". Rather it starts with "/". For example, "/zul/css/zk.wcs".


public boolean shallCheck(java.lang.String src,
                          long expiredMillis)
Description copied from interface: Loader
Returns whether to call Loader.getLastModified(K). If false, it assumes the current cached content is up-to-date.

Specified by:
shallCheck in interface Loader<java.lang.String,V>
expiredMillis - how many milli-seconds are expired after the last check. In most cases, just return true if expiredMillis > 0


public long getLastModified(java.lang.String src)
Returns the last modified time.

Specified by:
getLastModified in interface Loader<java.lang.String,V>


public V load(java.lang.String src)
       throws java.lang.Exception
Description copied from interface: Loader
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 of Loader.Resource. Then, the return value of ResourceCache.get(java.lang.Object) will be Loader.Resource.resource.

Specified by:
load in interface Loader<java.lang.String,V>
null if not found
java.lang.Exception - you might throw any exception which will be passed back to the caller of ResourceCache.get(java.lang.Object)


protected abstract V parse( is,
                           java.lang.String path,
                           java.lang.String orgpath)
                    throws java.lang.Exception
It is called to parse the resource into an intermediate format depending on Extendlet.

The object is returned directly by load(java.lang.String), so you can return an instance of org.zkoss.util.resource.Loader.Resource to have more control on ResourceCache.

is - the content of the resource
path - the path of the resource. It is the value returned by getRealPath(java.lang.String), so called the real path
orgpath - the original path. It is the path passed to the path argument of getRealPath(java.lang.String). It is useful if you want to retrieve the additional information encoded into the URI.


protected abstract ExtendletContext getExtendletContext()
Returns the extendlet context.


public int getCheckPeriod()
Returns the check period, or -1 if the content is never changed. Unit: milliseconds.

Default: It checks if an integer (unit: second) is assigned to a system property called org.zkoss.util.resource.extendlet.checkPeriod. If no such system property, -1 is assumed (never change). For the runtime environment the content is never changed, since all extendlet resources are packed in JAR files.

Copyright © 2005-2011 Potix Corporation. All Rights Reserved. Logo