Package org.zkoss.zkmax.ui.util
Class DesktopRecycle
- java.lang.Object
-
- org.zkoss.zkmax.ui.util.DesktopRecycle
-
- All Implemented Interfaces:
org.zkoss.zk.ui.util.DesktopRecycle
public class DesktopRecycle extends java.lang.Object implements org.zkoss.zk.ui.util.DesktopRecycleUsed to recycle the desktop if possible.Available in ZK EE
If you want to recycle only particular paths, you could override
shallCache(org.zkoss.zk.ui.Desktop, java.lang.String, int)andshallReuse(org.zkoss.zk.ui.Desktop, java.lang.String, int).- Since:
- 5.0.0
- Author:
- tomyeh
-
-
Constructor Summary
Constructors Constructor Description DesktopRecycle()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterRemove(org.zkoss.zk.ui.Session sess, org.zkoss.zk.ui.Desktop desktop)voidafterService(org.zkoss.zk.ui.Desktop desktop)booleanbeforeRemove(org.zkoss.zk.ui.Execution exec, org.zkoss.zk.ui.Desktop desktop, int cause)org.zkoss.zk.ui.DesktopbeforeService(org.zkoss.zk.ui.Execution exec, java.lang.String uri)protected static java.lang.StringgetURI(org.zkoss.zk.ui.Desktop desktop)Returns the request URI of the desktop.protected java.util.MapnewCache(org.zkoss.zk.ui.Session sess)Instantiates the cache to hold the recycled desktop for the given session.protected booleanshallCache(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int cause)Returns whether to cache the desktop of the specified URI, such that we can reuse it later.protected booleanshallExpunge(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int secElapsed)Returns whether to remove it from the cache.protected booleanshallReuse(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int secElapsed)Returns whether to re-use the cached desktop.
-
-
-
Method Detail
-
beforeRemove
public boolean beforeRemove(org.zkoss.zk.ui.Execution exec, org.zkoss.zk.ui.Desktop desktop, int cause)- Specified by:
beforeRemovein interfaceorg.zkoss.zk.ui.util.DesktopRecycle
-
getURI
protected static java.lang.String getURI(org.zkoss.zk.ui.Desktop desktop)
Returns the request URI of the desktop. It is a combination ofDesktop.getRequestPath()andDesktop.getQueryString(). For example, ifDesktop.getRequestPath()andDesktop.getQueryString()are "/foo.zul" and "abc=1", then this parameter is "/foo.zul?abc=1".- Since:
- 5.0.2
-
afterRemove
public void afterRemove(org.zkoss.zk.ui.Session sess, org.zkoss.zk.ui.Desktop desktop)- Specified by:
afterRemovein interfaceorg.zkoss.zk.ui.util.DesktopRecycle
-
beforeService
public org.zkoss.zk.ui.Desktop beforeService(org.zkoss.zk.ui.Execution exec, java.lang.String uri)- Specified by:
beforeServicein interfaceorg.zkoss.zk.ui.util.DesktopRecycle
-
afterService
public void afterService(org.zkoss.zk.ui.Desktop desktop)
- Specified by:
afterServicein interfaceorg.zkoss.zk.ui.util.DesktopRecycle
-
newCache
protected java.util.Map newCache(org.zkoss.zk.ui.Session sess)
Instantiates the cache to hold the recycled desktop for the given session.Default: instantiate a hash map.
- Since:
- 5.0.7
-
shallCache
protected boolean shallCache(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int cause)Returns whether to cache the desktop of the specified URI, such that we can reuse it later.The default implementation always return true. It means it tries to cache all paths.
If you want to cache only for, say, "/long-op/*", you can return true if path.startsWith("/long-op/").
- Parameters:
uri- the request URI. It is a combination ofDesktop.getRequestPath()andDesktop.getQueryString(). For example, ifDesktop.getRequestPath()andDesktop.getQueryString()are "/foo.zul" and "abc=1", then this parameter is "/foo.zul?abc=1".
-
shallReuse
protected boolean shallReuse(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int secElapsed)Returns whether to re-use the cached desktop.The default implementation return true if the page was served in 10 minutes (600 seconds).
- Parameters:
secElapsed- the number of seconds elapsed since the page was served.
-
shallExpunge
protected boolean shallExpunge(org.zkoss.zk.ui.Desktop desktop, java.lang.String uri, int secElapsed)Returns whether to remove it from the cache. It is called ifshallReuse(org.zkoss.zk.ui.Desktop, java.lang.String, int)returns false.Default: return true if the page was served more than 10 minutes ago (i.e., too old and we have to expunge it).
- Since:
- 5.0.7
-
-