org.zkoss.web.util.resource
Class ExtendletLoader

java.lang.Object
  extended by org.zkoss.web.util.resource.ExtendletLoader
All Implemented Interfaces:
Loader

public abstract class ExtendletLoader
extends java.lang.Object
implements Loader

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

Since:
3.0.6
Author:
tomyeh
See Also:
Extendlet

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.Object src)
          Returns the last modified time.
 java.lang.Object load(java.lang.Object src)
          Loads the resource.
protected abstract  java.lang.Object parse(java.io.InputStream is, java.lang.String path)
          It is called to parse the resource into an intermediate format depending on Extendlet.
 boolean shallCheck(java.lang.Object src, long expiredMillis)
          Returns whether to call Loader.getLastModified(java.lang.Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendletLoader

protected ExtendletLoader()
Method Detail

shallCheck

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

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

getLastModified

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

Specified by:
getLastModified in interface Loader

load

public java.lang.Object load(java.lang.Object src)
                      throws java.lang.Exception
Description copied from interface: Loader
Loads the resource.

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

parse

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

Parameters:
is - the content of the resource
path - the path of the resource
Throws:
java.lang.Exception

getExtendletContext

protected abstract ExtendletContext getExtendletContext()
Returns the extendlet context.


getCheckPeriod

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-2009 Potix Corporation. All Rights Reserved.