org.apache.myfaces.trinidadinternal.application
Class StateManagerImpl

java.lang.Object
  extended by javax.faces.application.StateManager
      extended by org.apache.myfaces.trinidadinternal.application.StateManagerImpl

public class StateManagerImpl
extends javax.faces.application.StateManager

StateManager that handles a hybrid client/server strategy: a SerializedView is stored on the server, and only a small token is stored on the client.

Application View cache

In addition, an optional Application view cache is supported. This view cache will, when enabled, perform special caching of all state for non-postback requests (that is, the initial state of all pages). For all pages, their SerializedView state is stored in a Map at application scope, and reused across all users. This simultaneously eliminates the expense of saving the state at all (except for the first request for any page), and significantly reduces memory usage as long as users are largely viewing initial pages only.

In addition, because the viewId is sufficient to identify the page state out of the cache, the token can be completely constant across requests and users. This makes it possible to cache the page content (which is not possible otherwise).

Since application scope objects do not support failover, a mirror of the cache is saved at session scope. The mirror is an LRU map of the last 16 application-scoped entries, but since it stores precisely the same SerializedView instances as the application scope, the additional memory requirements are minimal.

Version:
$Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/application/StateManagerImpl.java#2 $) $Date: 18-nov-2005.16:12:04 $
Author:
The Oracle ADF Faces Team

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.faces.application.StateManager
javax.faces.application.StateManager.SerializedView
 
Field Summary
static java.lang.String CACHE_VIEW_ROOT_INIT_PARAM
           
static java.lang.String CLIENT_STATE_MAX_TOKENS_PARAM_NAME
          Servlet context initialization parameter used by StateManagerImpl to decide how many tokens can be stored per user.
static java.lang.String CLIENT_STATE_METHOD_ALL
          Value indicating that the entire component state will be stored on the client.
static java.lang.String CLIENT_STATE_METHOD_PARAM_NAME
          Servlet context initialization parameter used by StateManagerImpl to decide what sort of state should be saved on the client.
static java.lang.String CLIENT_STATE_METHOD_TOKEN
          Value indicating that only a simple token will be stored on the client.
static java.lang.String USE_APPLICATION_VIEW_CACHE_INIT_PARAM
           
 
Fields inherited from class javax.faces.application.StateManager
STATE_SAVING_METHOD_CLIENT, STATE_SAVING_METHOD_PARAM_NAME, STATE_SAVING_METHOD_SERVER
 
Constructor Summary
StateManagerImpl(javax.faces.application.StateManager delegate)
           
 
Method Summary
protected  java.lang.Object getComponentStateToSave(javax.faces.context.FacesContext context)
           
protected  java.lang.Object getTreeStructureToSave(javax.faces.context.FacesContext context)
           
 boolean isSavingStateInClient(javax.faces.context.FacesContext context)
           
protected  void restoreComponentState(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewRoot, java.lang.String renderKitId)
           
static javax.faces.component.UIComponent restoreComponentTree(javax.faces.context.FacesContext context, java.lang.Object savedState)
           
protected  javax.faces.component.UIViewRoot restoreTreeStructure(javax.faces.context.FacesContext context, java.lang.String viewId, java.lang.String renderKitId)
           
 javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context, java.lang.String viewId, java.lang.String renderKitId)
           
static javax.faces.component.UIViewRoot restoreViewRoot(javax.faces.context.FacesContext context, java.lang.Object saved)
           
static java.lang.Object saveComponentTree(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 javax.faces.application.StateManager.SerializedView saveSerializedView(javax.faces.context.FacesContext context)
           
static java.lang.Object saveViewRoot(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot root)
          Save a view root.
 void writeState(javax.faces.context.FacesContext context, javax.faces.application.StateManager.SerializedView state)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_APPLICATION_VIEW_CACHE_INIT_PARAM

public static final java.lang.String USE_APPLICATION_VIEW_CACHE_INIT_PARAM
See Also:
Constant Field Values

CACHE_VIEW_ROOT_INIT_PARAM

public static final java.lang.String CACHE_VIEW_ROOT_INIT_PARAM
See Also:
Constant Field Values

CLIENT_STATE_METHOD_PARAM_NAME

public static final java.lang.String CLIENT_STATE_METHOD_PARAM_NAME
Servlet context initialization parameter used by StateManagerImpl to decide what sort of state should be saved on the client. Valid values are "token" and "all"; the default is "token".

See Also:
Constant Field Values

CLIENT_STATE_MAX_TOKENS_PARAM_NAME

public static final java.lang.String CLIENT_STATE_MAX_TOKENS_PARAM_NAME
Servlet context initialization parameter used by StateManagerImpl to decide how many tokens can be stored per user. The default is 15.

See Also:
Constant Field Values

CLIENT_STATE_METHOD_TOKEN

public static final java.lang.String CLIENT_STATE_METHOD_TOKEN
Value indicating that only a simple token will be stored on the client.

See Also:
Constant Field Values

CLIENT_STATE_METHOD_ALL

public static final java.lang.String CLIENT_STATE_METHOD_ALL
Value indicating that the entire component state will be stored on the client.

See Also:
Constant Field Values
Constructor Detail

StateManagerImpl

public StateManagerImpl(javax.faces.application.StateManager delegate)
Method Detail

saveComponentTree

public static java.lang.Object saveComponentTree(javax.faces.context.FacesContext context,
                                                 javax.faces.component.UIComponent component)

restoreComponentTree

public static javax.faces.component.UIComponent restoreComponentTree(javax.faces.context.FacesContext context,
                                                                     java.lang.Object savedState)
                                                              throws java.lang.ClassNotFoundException,
                                                                     java.lang.InstantiationException,
                                                                     java.lang.IllegalAccessException
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

saveViewRoot

public static java.lang.Object saveViewRoot(javax.faces.context.FacesContext context,
                                            javax.faces.component.UIViewRoot root)
Save a view root. Doesn't return a SerializedView because SerializedView is a non-static inner class, and this needs to be a static method.


restoreViewRoot

public static javax.faces.component.UIViewRoot restoreViewRoot(javax.faces.context.FacesContext context,
                                                               java.lang.Object saved)
                                                        throws java.lang.ClassNotFoundException,
                                                               java.lang.InstantiationException,
                                                               java.lang.IllegalAccessException
Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

saveSerializedView

public javax.faces.application.StateManager.SerializedView saveSerializedView(javax.faces.context.FacesContext context)
Specified by:
saveSerializedView in class javax.faces.application.StateManager

writeState

public void writeState(javax.faces.context.FacesContext context,
                       javax.faces.application.StateManager.SerializedView state)
                throws java.io.IOException
Specified by:
writeState in class javax.faces.application.StateManager
Throws:
java.io.IOException

restoreView

public javax.faces.component.UIViewRoot restoreView(javax.faces.context.FacesContext context,
                                                    java.lang.String viewId,
                                                    java.lang.String renderKitId)
Specified by:
restoreView in class javax.faces.application.StateManager

isSavingStateInClient

public boolean isSavingStateInClient(javax.faces.context.FacesContext context)
Overrides:
isSavingStateInClient in class javax.faces.application.StateManager

getTreeStructureToSave

protected java.lang.Object getTreeStructureToSave(javax.faces.context.FacesContext context)
Specified by:
getTreeStructureToSave in class javax.faces.application.StateManager

getComponentStateToSave

protected java.lang.Object getComponentStateToSave(javax.faces.context.FacesContext context)
Specified by:
getComponentStateToSave in class javax.faces.application.StateManager

restoreTreeStructure

protected javax.faces.component.UIViewRoot restoreTreeStructure(javax.faces.context.FacesContext context,
                                                                java.lang.String viewId,
                                                                java.lang.String renderKitId)
Specified by:
restoreTreeStructure in class javax.faces.application.StateManager

restoreComponentState

protected void restoreComponentState(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIViewRoot viewRoot,
                                     java.lang.String renderKitId)
Specified by:
restoreComponentState in class javax.faces.application.StateManager


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.