return _delegate.restoreView(context, viewId, renderKitId);
final Object structure;
final Object state;
ResponseStateManager rsm = _getResponseStateManager(context, renderKitId);
if (_saveAsToken(context))
{
Object token = rsm.getTreeStructureToRestore(context, viewId);
if (token == null)
{
_LOG.finest("No token in the request for view \"{0}\"; " +
"probably a first view.", viewId);
return null;
}
assert(token instanceof String);
_LOG.finer("Restoring saved view state for token {0}", token);
PageState viewState;
// Load from the application cache
if (_APPLICATION_CACHE_TOKEN.equals(token))
{
Map<String, Object> cache = _getApplicationViewCache(context);
Map<String, Object> perSessionCache =
_getPerSessionApplicationViewCache(context);
// Synchronize on the application-level cache.
// =-=AEW This may produce excessive contention
synchronized (cache)
{
// Look first in the per-session cache
viewState = (PageState) perSessionCache.get(viewId);
if (viewState == null)
{
// Nope, it's not there. Look in the application cache
viewState = (PageState) cache.get(viewId);
// And if we find it there, then push it back into
// the per-session cache (it may have expired)
if (viewState != null)
perSessionCache.put(viewId, viewState);
}
}
}
else
{
Map<String, Object> stateMap = new SubKeyMap(
context.getExternalContext().getSessionMap(),
_VIEW_CACHE_KEY + ".");
viewState = (PageState) stateMap.get(token);
// Make sure that if the view state is present, the cache still
// has the token, and vice versa
// NOTE: it's very important that we call through to the
// token cache here, not just inside the assert. If we don't,
// then we don't actually access the token, so it doesn't
// get bumped up to the front in the LRU Cache!
boolean isAvailable =
_getViewCache(context).isAvailable((String) token);
assert ((viewState != null) == isAvailable);
}
if (viewState == null)
{
_LOG.severe("Could not find saved view state for token {0}", token);
return null;
}
_LOG.fine("Successfully found view state for token {0}", token);
UIViewRoot root = viewState.popRoot(context); // bug 4712492
if (root != null)
{
_LOG.finer("UIViewRoot for token {0} already exists. Bypassing restoreState", token);
return root;
}
structure = viewState.getStructure();
state = viewState.getState();
}
else
{
structure = rsm.getTreeStructureToRestore(context, viewId);
state = rsm.getComponentStateToRestore(context);
}
if (structure == null)
{