public class DesktopRecycle extends Object implements org.zkoss.zk.ui.util.DesktopRecycle
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) and shallReuse(org.zkoss.zk.ui.Desktop, java.lang.String, int).
| Constructor and Description |
|---|
DesktopRecycle() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterRemove(org.zkoss.zk.ui.Session sess,
org.zkoss.zk.ui.Desktop desktop) |
void |
afterService(org.zkoss.zk.ui.Desktop desktop) |
boolean |
beforeRemove(org.zkoss.zk.ui.Execution exec,
org.zkoss.zk.ui.Desktop desktop,
int cause) |
org.zkoss.zk.ui.Desktop |
beforeService(org.zkoss.zk.ui.Execution exec,
String uri) |
protected static String |
getURI(org.zkoss.zk.ui.Desktop desktop)
Returns the request URI of the desktop.
|
protected Map |
newCache(org.zkoss.zk.ui.Session sess)
Instantiates the cache to hold the recycled desktop for the given session.
|
protected boolean |
shallCache(org.zkoss.zk.ui.Desktop desktop,
String uri,
int cause)
Returns whether to cache the desktop of the specified URI, such
that we can reuse it later.
|
protected boolean |
shallExpunge(org.zkoss.zk.ui.Desktop desktop,
String uri,
int secElapsed)
Returns whether to remove it from the cache.
|
protected boolean |
shallReuse(org.zkoss.zk.ui.Desktop desktop,
String uri,
int secElapsed)
Returns whether to re-use the cached desktop.
|
public boolean beforeRemove(org.zkoss.zk.ui.Execution exec,
org.zkoss.zk.ui.Desktop desktop,
int cause)
beforeRemove in interface org.zkoss.zk.ui.util.DesktopRecycleprotected static String getURI(org.zkoss.zk.ui.Desktop desktop)
Desktop.getRequestPath() and Desktop.getQueryString().
For example, if Desktop.getRequestPath() and Desktop.getQueryString()
are "/foo.zul" and "abc=1", then this parameter is "/foo.zul?abc=1".public void afterRemove(org.zkoss.zk.ui.Session sess,
org.zkoss.zk.ui.Desktop desktop)
afterRemove in interface org.zkoss.zk.ui.util.DesktopRecyclepublic org.zkoss.zk.ui.Desktop beforeService(org.zkoss.zk.ui.Execution exec,
String uri)
beforeService in interface org.zkoss.zk.ui.util.DesktopRecyclepublic void afterService(org.zkoss.zk.ui.Desktop desktop)
afterService in interface org.zkoss.zk.ui.util.DesktopRecycleprotected Map newCache(org.zkoss.zk.ui.Session sess)
Default: instantiate a hash map.
protected boolean shallCache(org.zkoss.zk.ui.Desktop desktop,
String uri,
int cause)
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/").
uri - the request URI. It is
a combination of Desktop.getRequestPath() and Desktop.getQueryString().
For example, if Desktop.getRequestPath() and Desktop.getQueryString()
are "/foo.zul" and "abc=1", then this parameter is "/foo.zul?abc=1".protected boolean shallReuse(org.zkoss.zk.ui.Desktop desktop,
String uri,
int secElapsed)
The default implementation return true if the page was served in 10 minutes (600 seconds).
secElapsed - the number of seconds elapsed since the page
was served.protected boolean shallExpunge(org.zkoss.zk.ui.Desktop desktop,
String uri,
int secElapsed)
shallReuse(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).
Copyright © 2026. All rights reserved.