Package org.zkoss.zk.ui.impl

## Class AbstractWebApp

- java.lang.Object
- - org.zkoss.zk.ui.impl.AbstractWebApp

- All Implemented Interfaces:
    `Locator`, `Scope`, `WebAppCtrl`, `WebApp`
  Direct Known Subclasses:
    `SimpleWebApp`

      public abstract class AbstractWebApp
      extends java.lang.Object
      implements WebApp, WebAppCtrl

  A skeletal implementation of `WebApp`.
  Author:
    tomyeh

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `AbstractWebApp()` | Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `destroy()` | Destroys this Web application.
    `java.lang.String` | `getAppName()` | Returns the application name, never null.
    `java.lang.Object` | `getAttribute​(java.lang.String name, boolean recurse)` | Returns the custom attribute associated with this object.
    `AuDecoder` | `getAuDecoder()` | Returns the AU decoder for this Web application, or null if not assigned.
    `java.lang.String` | `getBuild()` | Returns the build identifier, such as 2007121316.
    `static java.lang.String` | `getBuildStamp()` |
    `Configuration` | `getConfiguration()` | Returns the configuration.
    `DesktopCache` | `getDesktopCache​(Session sess)` | Returns the desktop cache.
    `DesktopCacheProvider` | `getDesktopCacheProvider()` | Returns the desktop cache provider.
    `FailoverManager` | `getFailoverManager()` | Returns the failover manager, or null if not available.
    `IdGenerator` | `getIdGenerator()` | Returns the ID generator, or null if not available.
    `SessionCache` | `getSessionCache()` | Returns the session cache (never null).
    `int` | `getSubversion​(int portion)` | Returns a portion of the version in an integer by specifying its index.
    `UiEngine` | `getUiEngine()` | Returns the UI engine for this Web application (never null).
    `UiFactory` | `getUiFactory()` | Returns the UI factory for this Web application (never null).
    `java.lang.String` | `getVersion()` | Returns the ZK version, such as "1.1.0" and "2.0.0".
    `boolean` | `hasAttribute​(java.lang.String name, boolean recurse)` | Returns if a custom attribute is associated with this object.
    `void` | `init​(java.lang.Object context, Configuration config)` | Initializes this Web application.
    `static java.lang.String` | `loadBuild()` | Loads the build identifier.
    `java.lang.Object` | `removeAttribute​(java.lang.String name, boolean recurse)` | Removes the custom attribute associated with this scope.
    `void` | `sessionDestroyed​(Session sess)` | Called when the native session of the specified session has been destroyed
    `void` | `sessionDidActivate​(Session sess)` | Invokes `getDesktopCacheProvider()`'s `DesktopCacheProvider.sessionDidActivate(org.zkoss.zk.ui.Session)`.
    `void` | `sessionWillPassivate​(Session sess)` | Invokes `getDesktopCacheProvider()`'s `DesktopCacheProvider.sessionWillPassivate(org.zkoss.zk.ui.Session)`.
    `void` | `setAppName​(java.lang.String name)` | Sets the application name.
    `java.lang.Object` | `setAttribute​(java.lang.String name, java.lang.Object value, boolean recurse)` | Sets the custom attribute associated with this scope, or the parent scope.
    `void` | `setAuDecoder​(AuDecoder audec)` | Sets the AU decoder for this Web application.
    `void` | `setDesktopCacheProvider​(DesktopCacheProvider provider)` | Sets the desktop provider for this Web application.
    `void` | `setFailoverManager​(FailoverManager failover)` | Sets the failover manager for this Web application.
    `void` | `setIdGenerator​(IdGenerator idgen)` | Sets the ID generator for this Web application.
    `void` | `setSessionCache​(SessionCache cache)` | Sets the session cache for this Web application.
    `void` | `setUiEngine​(UiEngine engine)` | Sets the UI engine for this Web application.
    `void` | `setUiFactory​(UiFactory factory)` | Sets the UI factory for this Web application.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.zkoss.util.resource.Locator

      `getDirectory`

    - ### Methods inherited from interface org.zkoss.zk.ui.ext.Scope

      `addScopeListener, hasAttribute, removeScopeListener`

    - ### Methods inherited from interface org.zkoss.zk.ui.WebApp

      `getAttribute, getAttributes, getInitParameter, getInitParameterNames, getMimeType, getRealPath, getResource, getResourceAsStream, getResourcePaths, getResourceURI, getResourceURI, getServletContext, getUpdateURI, getUpdateURI, getWebApp, log, log, removeAttribute, setAttribute`

- - ### Constructor Detail

    - #### AbstractWebApp

          protected AbstractWebApp()

      Constructor.

      Note: after constructed, it is not initialized completely. For example, `getConfiguration()` returns null.

      WebManager will initialize it later such as initializing a `Configuration` instance by loading zk.xml, and then calling `init(java.lang.Object, org.zkoss.zk.ui.util.Configuration)`.

  - ### Method Detail

    - #### getAppName

          public java.lang.String getAppName()

      Description copied from interface: `WebApp`
      Returns the application name, never null. Developer can set it to any name that describes his application.

      Default: ZK

      Specified by:
        `getAppName` in interface `WebApp`

    - #### setAppName

          public void setAppName​(java.lang.String name)

      Description copied from interface: `WebApp`
      Sets the application name. Developer can set it to any name that describes his application.
      Specified by:
        `setAppName` in interface `WebApp`

    - #### getVersion

          public final java.lang.String getVersion()

      Description copied from interface: `WebApp`
      Returns the ZK version, such as "1.1.0" and "2.0.0".
      Specified by:
        `getVersion` in interface `WebApp`
      See Also:
        `WebApp.getSubversion(int)`, `Utils.parseVersion(java.lang.String)`, `Utils.compareVersion(int[], int[])`

    - #### getBuild

          public java.lang.String getBuild()

      Description copied from interface: `WebApp`
      Returns the build identifier, such as 2007121316.

      Each time ZK is built, a different build identifier is assigned.

      Specified by:
        `getBuild` in interface `WebApp`

    - #### getBuildStamp

          public static final java.lang.String getBuildStamp()

    - #### getSubversion

          public int getSubversion​(int portion)

      Description copied from interface: `WebApp`
      Returns a portion of the version in an integer by specifying its index. For example, getSubversion(0) returns the so-called major version (2 in "2.4.0"), getSubversion(1) returns the so-called minor version (4 in "2.4.0"), and both getSubversion(2) and getSubversion(3) return 0.
      Specified by:
        `getSubversion` in interface `WebApp`
      Parameters:
        `portion` - which portion of the version; starting from 0. If you want to retrieve the major version, specify 0.
      See Also:
        `WebApp.getVersion()`

    - #### getConfiguration

          public final Configuration getConfiguration()

      Description copied from interface: `WebApp`
      Returns the configuration.
      Specified by:
        `getConfiguration` in interface `WebApp`

    - #### getAttribute

          public java.lang.Object getAttribute​(java.lang.String name,
                                               boolean recurse)

      Description copied from interface: `Scope`
      Returns the custom attribute associated with this object.
      Specified by:
        `getAttribute` in interface `Scope`
        `recurse` - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.

    - #### hasAttribute

          public boolean hasAttribute​(java.lang.String name,
                                      boolean recurse)

      Description copied from interface: `Scope`
      Returns if a custom attribute is associated with this object.

      Notice that `null` is a valid value, so you can tell if an attribute is associated by examining the return value of `Scope.getAttribute(java.lang.String)`.

      Specified by:
        `hasAttribute` in interface `Scope`
        `recurse` - whether to search its ancestor scope. If true and the current scope doen't define the attribute, it searches up its ancestor to see any of them has defined the specified attribute.

    - #### setAttribute

          public java.lang.Object setAttribute​(java.lang.String name,
                                               java.lang.Object value,
                                               boolean recurse)

      Description copied from interface: `Scope`
      Sets the custom attribute associated with this scope, or the parent scope.
      Specified by:
        `setAttribute` in interface `Scope`
        `recurse` - whether to look up the parent scope for the existence of the attribute.
        If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is replaced. Otherwise, it is the same as `Scope.setAttribute(String,Object)`.

    - #### removeAttribute

          public java.lang.Object removeAttribute​(java.lang.String name,
                                                  boolean recurse)

      Description copied from interface: `Scope`
      Removes the custom attribute associated with this scope.
      Specified by:
        `removeAttribute` in interface `Scope`
        `recurse` - whether to look up the parent scope for the existence of the attribute.
        If recurse is true and the attribute is defined in one of its ancestor (including page), the attribute is removed. Otherwise, it is the same as `Scope.removeAttribute(String)`.

    - #### init

          public void init​(java.lang.Object context,
                           Configuration config)

      Description copied from interface: `WebAppCtrl`
      Initializes this Web application.
      Specified by:
        `init` in interface `WebAppCtrl`
      Parameters:
        `context` - the servlet context, if servlets are used. Currently, ZK supports only servlets. In the future there might be more to support.
        `config` - the configuration (never null)

    - #### destroy

          public void destroy()

      Description copied from interface: `WebAppCtrl`
      Destroys this Web application.

      Note; once destroyed, this instance cannot be used anymore.

      Specified by:
        `destroy` in interface `WebAppCtrl`

    - #### getUiEngine

          public final UiEngine getUiEngine()

      Description copied from interface: `WebAppCtrl`
      Returns the UI engine for this Web application (never null).
      Specified by:
        `getUiEngine` in interface `WebAppCtrl`

    - #### setUiEngine

          public void setUiEngine​(UiEngine engine)

      Description copied from interface: `WebAppCtrl`
      Sets the UI engine for this Web application. The UI engine is stateful so it is not safe to change it if there are active sessions.
      Specified by:
        `setUiEngine` in interface `WebAppCtrl`
      Parameters:
        `engine` - the UI engine

    - #### getDesktopCache

          public DesktopCache getDesktopCache​(Session sess)

      Description copied from interface: `WebAppCtrl`
      Returns the desktop cache. A shortcut of `WebAppCtrl.getDesktopCacheProvider()`'s `DesktopCacheProvider.getDesktopCache(org.zkoss.zk.ui.Session)`.
      Specified by:
        `getDesktopCache` in interface `WebAppCtrl`

    - #### getDesktopCacheProvider

          public DesktopCacheProvider getDesktopCacheProvider()

      Description copied from interface: `WebAppCtrl`
      Returns the desktop cache provider.
      Specified by:
        `getDesktopCacheProvider` in interface `WebAppCtrl`

    - #### setDesktopCacheProvider

          public void setDesktopCacheProvider​(DesktopCacheProvider provider)

      Description copied from interface: `WebAppCtrl`
      Sets the desktop provider for this Web application.
      Specified by:
        `setDesktopCacheProvider` in interface `WebAppCtrl`
      Parameters:
        `provider` - the desktop cache provider

    - #### getUiFactory

          public UiFactory getUiFactory()

      Description copied from interface: `WebAppCtrl`
      Returns the UI factory for this Web application (never null).
      Specified by:
        `getUiFactory` in interface `WebAppCtrl`

    - #### setUiFactory

          public void setUiFactory​(UiFactory factory)

      Description copied from interface: `WebAppCtrl`
      Sets the UI factory for this Web application.
      Specified by:
        `setUiFactory` in interface `WebAppCtrl`
      Parameters:
        `factory` - the UI factory

    - #### getFailoverManager

          public FailoverManager getFailoverManager()

      Description copied from interface: `WebAppCtrl`
      Returns the failover manager, or null if not available.
      Specified by:
        `getFailoverManager` in interface `WebAppCtrl`

    - #### setFailoverManager

          public void setFailoverManager​(FailoverManager failover)

      Description copied from interface: `WebAppCtrl`
      Sets the failover manager for this Web application.
      Specified by:
        `setFailoverManager` in interface `WebAppCtrl`
      Parameters:
        `failover` - the failover manager. If null, it means no failover manager at all.

    - #### getIdGenerator

          public IdGenerator getIdGenerator()

      Description copied from interface: `WebAppCtrl`
      Returns the ID generator, or null if not available.
      Specified by:
        `getIdGenerator` in interface `WebAppCtrl`

    - #### setIdGenerator

          public void setIdGenerator​(IdGenerator idgen)

      Description copied from interface: `WebAppCtrl`
      Sets the ID generator for this Web application.
      Specified by:
        `setIdGenerator` in interface `WebAppCtrl`
      Parameters:
        `idgen` - the ID generator. If null, it means no (custom) ID generator at all.

    - #### getSessionCache

          public SessionCache getSessionCache()

      Description copied from interface: `WebAppCtrl`
      Returns the session cache (never null). The session cache is used to store ZK sessions.
      Specified by:
        `getSessionCache` in interface `WebAppCtrl`

    - #### setSessionCache

          public void setSessionCache​(SessionCache cache)

      Description copied from interface: `WebAppCtrl`
      Sets the session cache for this Web application.
      Specified by:
        `setSessionCache` in interface `WebAppCtrl`
      Parameters:
        `cache` - the session cache

    - #### getAuDecoder

          public AuDecoder getAuDecoder()

      Description copied from interface: `WebAppCtrl`
      Returns the AU decoder for this Web application, or null if not assigned.
      Specified by:
        `getAuDecoder` in interface `WebAppCtrl`

    - #### setAuDecoder

          public void setAuDecoder​(AuDecoder audec)

      Description copied from interface: `WebAppCtrl`
      Sets the AU decoder for this Web application.

      Default: null (using the system default).

      Specified by:
        `setAuDecoder` in interface `WebAppCtrl`

    - #### sessionWillPassivate

          public void sessionWillPassivate​(Session sess)

      Invokes `getDesktopCacheProvider()`'s `DesktopCacheProvider.sessionWillPassivate(org.zkoss.zk.ui.Session)`.
      Specified by:
        `sessionWillPassivate` in interface `WebAppCtrl`

    - #### sessionDidActivate

          public void sessionDidActivate​(Session sess)

      Invokes `getDesktopCacheProvider()`'s `DesktopCacheProvider.sessionDidActivate(org.zkoss.zk.ui.Session)`.
      Specified by:
        `sessionDidActivate` in interface `WebAppCtrl`

    - #### sessionDestroyed

          public void sessionDestroyed​(Session sess)

      Description copied from interface: `WebAppCtrl`
      Called when the native session of the specified session has been destroyed
      Specified by:
        `sessionDestroyed` in interface `WebAppCtrl`

    - #### loadBuild

          public static java.lang.String loadBuild()

      Loads the build identifier. This method is used only Internally