All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zkoss.zk.ui.sys.FailoverManager Maven / Gradle / Ivy

There is a newer version: 10.0.0-jakarta
Show newest version
/* FailoverManager.java

	Purpose:
		
	Description:
		
	History:
		Wed Mar 28 14:39:26     2007, Created by tomyeh

Copyright (C) 2007 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
	This program is distributed under LGPL Version 2.1 in the hope that
	it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.zkoss.zk.ui.sys;

import org.zkoss.zk.ui.WebApp;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.UiException;

/**
 * Represents a class that is able to handle fail-over in the
 * application specific way.
 *
 * 

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 {@link org.zkoss.zk.ui.http.SerializableUiFactory} * as the UI factory in zk.xml as follows (and forget {@link FailoverManager}). * *


<system-config>
 <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
</system-config>
* *

The recovery involves two phases: *

    *
  1. {@link #isRecoverable}: It tests whether the desktop is recoverable.
  2. *
  3. {@link #recover}: If recoverable, * ZK will create the desktop accordingly, prepare the execution * and then invoke this method to do real recovery.
  4. *
* * @author tomyeh */ public interface FailoverManager { /** Starts the failover manager. * @since 5.0.0 */ public void start(WebApp wapp); /** Stops the failover manager. * Called only if the server is about to stop. * @since 5.0.0 */ public void stop(WebApp wapp); /** Tests whether the specified desktop ID is recoverable. * *

Note: when this method called, no execution * ({@link Execution}) is available. * The implementation shall only check whether it is possible to * recover the specified desktop ID. * Then, do the real recovery in {@link #recover}. * * @param sess the session * @param desktopId the desktop ID to recover */ public boolean isRecoverable(Session sess, String desktopId); /** Recovers the specified desktop. * It is called only when {@link #isRecoverable} returns true. * Before calling this method, the desktop and execution * {@link 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

*
    *
  • [must] Call {@link DesktopCtrl#setId} to correct the desktop ID.
  • *
  • [optional] Call {@link Desktop#setCurrentDirectory} to * correct the current directory. * It is the directory of the path of the ZUML page.
  • *
  • [optional] Call {@link Desktop#setDeviceType} to correct * the device type (default: html).
  • *
  • [Must] Recover all pages and components.
  • *
  • [Optional] Recover the response ID by use of * {@link DesktopCtrl#setResponseId}.
  • *
  • [Optional] Recover desktop's attributes.
  • *
* *

Recover Page

*
    *
  • [Must] Invoke {@link org.zkoss.zk.ui.impl.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 {@link org.zkoss.zk.ui.Page}.
  • *
  • [Must] Then, invoke {@link org.zkoss.zk.ui.sys.PageCtrl#init} to initialized the page.
  • *
  • [Optional] Recover page's attributes.
  • *
* * @exception UiException if failed to recover */ public void recover(Session sess, Execution exec, Desktop desktop) throws UiException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy