|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zkmax.ui.util.DesktopRecycle
public class DesktopRecycle
Used 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)
and shallReuse(org.zkoss.zk.ui.Desktop, java.lang.String, int)
.
Constructor Summary | |
---|---|
DesktopRecycle()
|
Method Summary | |
---|---|
void |
afterRemove(Session sess,
Desktop desktop)
Called after a desktop is removed. |
void |
afterService(Desktop desktop)
Called after the request is served. |
boolean |
beforeRemove(Execution exec,
Desktop desktop,
int cause)
Called when the client asks the server to remove a deskdop because of the user's navigating to other URL or refreshing the page. |
Desktop |
beforeService(Execution exec,
java.lang.String path)
Called when an user requests the content of a page. |
protected boolean |
shallCache(Desktop desktop,
java.lang.String path,
int cause)
Returns whether to cache the desktop of the specified path, such that we can reuse it later. |
protected boolean |
shallReuse(Desktop desktop,
java.lang.String path,
int secElapsed)
Returns whether to re-use the cached desktop. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DesktopRecycle()
Method Detail |
---|
public boolean beforeRemove(Execution exec, Desktop desktop, int cause)
DesktopRecycle
The implementation can retrieve the request path by calling
Desktop.getRequestPath()
.
Notice that, when the user refreshes a page, this method might be
called after DesktopRecycle.beforeService(org.zkoss.zk.ui.Execution, java.lang.String)
is called (depending on the browser
and networking). In other words, there is no way it is a brand-new request
from a new window, or it is caused by user's refreshing.
beforeRemove
in interface DesktopRecycle
exec
- the current execution.cause
- the cause. It is reserved for the future extension.
public void afterRemove(Session sess, Desktop desktop)
DesktopRecycle
DesktopRecycle.afterRemove(org.zkoss.zk.ui.Session, org.zkoss.zk.ui.Desktop)
is called.
The implementation has to remove the cached desktop, if any.
When this method is called, there might be no execution available
(Executions.getCurrent()
might return null).
afterRemove
in interface DesktopRecycle
sess
- the session that the desktop belongs to.
Notice that Desktop.getSession()
might be null when this method
is called since it is destroyed.desktop
- the desktop to removepublic Desktop beforeService(Execution exec, java.lang.String path)
DesktopRecycle
beforeService
in interface DesktopRecycle
exec
- the execution. It doesn't not associated with
a desktop, and used only for accessing the request and response.path
- the request path. It is the same as Desktop.getRequestPath()
.
public void afterService(Desktop desktop)
DesktopRecycle
The implementation usually does nothing in this method, unless it wants to re-use it no matter if the same user might open two or more windows to visit the same URL.
When this method is called, there might be no execution available
(Executions.getCurrent()
might return null).
afterService
in interface DesktopRecycle
protected boolean shallCache(Desktop desktop, java.lang.String path, 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/").
protected boolean shallReuse(Desktop desktop, java.lang.String path, int secElapsed)
The default implementation return true if the page was served in 10 minutes (600 seconds).
secElapsed
- the number of seconds ellapsed since the page
was served.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |