public interface FailoverManager
Desktops, pages and components are serializables, so you can use the clustering feature supported by the Web server without implementing this interface. In other words, you need to implement this interface only if you want to provide an application-specific way to re-create back.
If you want to use the Web server's clustering feature,
what you need to do is to specify SerializableUiFactory
as the UI factory in zk.xml as follows (and forget FailoverManager
).
<system-config>
<ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
</system-config>
The recovery involves two phases:
isRecoverable(org.zkoss.zk.ui.Session, java.lang.String)
: It tests whether the desktop is recoverable.recover(org.zkoss.zk.ui.Session, org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Desktop)
: If recoverable,
ZK will create the desktop accordingly, prepare the execution
and then invoke this method to do real recovery.Modifier and Type | Method and Description |
---|---|
boolean |
isRecoverable(Session sess,
java.lang.String desktopId)
Tests whether the specified desktop ID is recoverable.
|
void |
recover(Session sess,
Execution exec,
Desktop desktop)
Recovers the specified desktop.
|
void |
start(WebApp wapp)
Starts the failover manager.
|
void |
stop(WebApp wapp)
Stops the failover manager.
|
void start(WebApp wapp)
void stop(WebApp wapp)
boolean isRecoverable(Session sess, java.lang.String desktopId)
Note: when this method called, no execution
(Execution
) is available.
The implementation shall only check whether it is possible to
recover the specified desktop ID.
Then, do the real recovery in recover(org.zkoss.zk.ui.Session, org.zkoss.zk.ui.Execution, org.zkoss.zk.ui.Desktop)
.
sess
- the sessiondesktopId
- the desktop ID to recovervoid recover(Session sess, Execution exec, Desktop desktop) throws UiException
isRecoverable(org.zkoss.zk.ui.Session, java.lang.String)
returns true.
Before calling this method, the desktop and execution
Execution
) are all prepared.
Note: ZK assumes the failover manager can recover the desktop completely, so it won't update the browser whatever have been done in this method.
During the recovering process, you have to do the following:
Recover Desktop
DesktopCtrl.setId(java.lang.String)
to correct the desktop ID.Desktop.setCurrentDirectory(java.lang.String)
to
correct the current directory.
It is the directory of the path of the ZUML page.Desktop.setDeviceType(java.lang.String)
to correct
the device type (default: html).DesktopCtrl.setResponseId(int)
.Recover Page
PageImpl.PageImpl(org.zkoss.zk.ui.metainfo.LanguageDefinition, org.zkoss.zk.ui.metainfo.ComponentDefinitionMap, String, String)
(or your own implementation) to create an instance of Page
.PageCtrl.init(org.zkoss.zk.ui.sys.PageConfig)
to initialized the page.UiException
- if failed to recoverCopyright © 2005-2011 Potix Corporation. All Rights Reserved.