コード例 #1
0
  public synchronized String getToken(FacesContext context) {
    if (_token != null) return _token;

    // Don't need a token when nothing's in the map, and we
    // don't have a parent
    if (isEmpty() && (_sharedData._children == null) && (_sharedData._parent == null)) return null;

    String parentToken;
    TokenCache cache;
    if (_sharedData._parent != null) {
      parentToken = _sharedData._parent.getToken(context);
      cache = _sharedData._parent._getTokenCache();
    } else {
      parentToken = null;
      cache = _getRootTokenCache(context, _sharedData._lifetime);
    }

    Map<String, Object> store = _createMapToStore(context, parentToken);

    String token = cache.addNewEntry(this, store);

    if (parentToken != null) token = parentToken + TokenCache.SEPARATOR_CHAR + token;

    _token = token;

    // With a new token, there cannot be any shared children
    // with a prior request.
    if (_sharedData._children != null) {
      // =-=AEW NEED TO CLONE SHARED DATA
      _LOG.fine("Discarding child PageFlowScopes; new token is {0}", token);
      _sharedData._children = null;
    }

    return _token;
  }
コード例 #2
0
 private static TokenCache _getRootTokenCache(FacesContext context, int lifetime) {
   return TokenCache.getTokenCacheFromSession(
       context.getExternalContext(), _PAGE_FLOW_SCOPE_CACHE, true, lifetime);
 }