org.apache.myfaces.trinidadinternal.util
Class TokenCacheDebugUtils

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.util.TokenCacheDebugUtils

public final class TokenCacheDebugUtils
extends java.lang.Object

ViewExpiredExceptions are fairly common, and the token cache is used for page state tokens, but the tokens aren't really human readable. In order to make it easier to understand what is in the cache we've added a system property for debugging purposes. When enabled we store a map of token -> viewId on the session which we use to log something more human readable. in order to use this the tester would set the system property to: -Dorg.apache.myfaces.trinidadinternal.DEBUG_TOKEN_CACHE=true TokenCacheDebugUtils provides methods to log human readable debugging info. The goal is to provide as much logging information in a single log message as possible. In order to do this we are pushing log info into a buffer and when we're ready to log we can get the string. To start the log call like so: TokenCacheDebugUtils.startLog("My Custom String"); Then you can call methods like: TokenCacheDebugUtils.logCacheInfo(stateMap, null, "hello world"); TokenCacheDebugUtils.addToLog("foo bar"); Then when you're ready to actually put it in the log you would do this: _LOG.severe(TokenCacheDebugUtils.getLogString());


Method Summary
static void addTokenToViewIdMap(java.lang.String token)
          In order to provide human readable information there is a map which has token to viewId information.
static void addToLog(java.lang.String addString)
          Add a string to the current log buffer This method should only be called when debugTokenCache() is true
static boolean debugTokenCache()
          Checks whether we are debugging the token cache.
static java.lang.String getLogString()
          get the string from the log buffer.
static java.lang.String getTokenToViewIdString(java.lang.String token)
          Generate a string showing the token and the view id we have saved for that token This method should only be called when debugTokenCache() is true
static
<V> void
logCacheInfo(java.util.Map<java.lang.String,V> targetStore, java.util.Map<java.lang.String,java.lang.String> pinned, java.lang.String logAddition)
          Add info about the cache to the log buffer.
static void removeTokenFromViewIdMap(java.lang.String token)
          In order to provide human readable information there is a map which has token to viewId information.
static void startLog(java.lang.String startString)
          Start a log buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

debugTokenCache

public static boolean debugTokenCache()
Checks whether we are debugging the token cache. No other method in TokenCacheDebugUtils should be called unless this method returns true.


addTokenToViewIdMap

public static void addTokenToViewIdMap(java.lang.String token)
In order to provide human readable information there is a map which has token to viewId information. Add the token passed in and associate it in the map with the current view id. This method should only be called when debugTokenCache() is true


removeTokenFromViewIdMap

public static void removeTokenFromViewIdMap(java.lang.String token)
In order to provide human readable information there is a map which has token to viewId information. Remove the view id info from the map for the given token. This method should only be called when debugTokenCache() is true


getTokenToViewIdString

public static java.lang.String getTokenToViewIdString(java.lang.String token)
Generate a string showing the token and the view id we have saved for that token This method should only be called when debugTokenCache() is true


logCacheInfo

public static <V> void logCacheInfo(java.util.Map<java.lang.String,V> targetStore,
                                    java.util.Map<java.lang.String,java.lang.String> pinned,
                                    java.lang.String logAddition)
Add info about the cache to the log buffer. For the target store map, the keys are tokens. For each token we will call getTokenToViewIdString to show what's in the map. For the pinned map the keys and values are tokens, for each key/value pair call getTokenToViewIdString to show what is pinned. This method should only be called when debugTokenCache() is true


addToLog

public static void addToLog(java.lang.String addString)
Add a string to the current log buffer This method should only be called when debugTokenCache() is true


startLog

public static void startLog(java.lang.String startString)
Start a log buffer. The startString passed in will be printed, along with session id and window id information This method should only be called when debugTokenCache() is true


getLogString

public static java.lang.String getLogString()
get the string from the log buffer. This method should only be called when debugTokenCache() is true



Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.