FileDocCategorySizeDatePackage
InvocationSessionStore.javaAPI DocExample4142Mon Jul 23 13:26:56 BST 2007org.apache.struts2.util

InvocationSessionStore

public class InvocationSessionStore extends Object
InvocationSessionStore

Fields Summary
private static final String
INVOCATION_MAP_KEY
Constructors Summary
private InvocationSessionStore()



      
    
Methods Summary
static java.util.MapgetInvocationMap()

        Map session = ActionContext.getContext().getSession();

        if (session == null) {
            throw new IllegalStateException("Unable to access the session.");
        }

        Map invocationMap = (Map) session.get(INVOCATION_MAP_KEY);

        if (invocationMap == null) {
            invocationMap = new HashMap();
            setInvocationMap(invocationMap);
        }

        return invocationMap;
    
public static com.opensymphony.xwork2.ActionInvocationloadInvocation(java.lang.String key, java.lang.String token)
Checks the Map in the Session for the key and the token. If the ActionInvocation is saved in the Session, the ValueStack from the ActionProxy associated with the ActionInvocation is set into the ActionContext and the ActionInvocation is returned.

param
key the name the DefaultActionInvocation and ActionContext were saved as
return
the DefaultActionInvocation saved using the key, or null if none was found

        InvocationContext invocationContext = (InvocationContext) getInvocationMap().get(key);

        if ((invocationContext == null) || !invocationContext.token.equals(token)) {
            return null;
        }

        ValueStack stack = invocationContext.invocation.getStack();
        ActionContext.getContext().setValueStack(stack);

        return invocationContext.invocation;
    
static voidsetInvocationMap(java.util.Map invocationMap)

        Map session = ActionContext.getContext().getSession();

        if (session == null) {
            throw new IllegalStateException("Unable to access the session.");
        }

        session.put(INVOCATION_MAP_KEY, invocationMap);
    
public static voidstoreInvocation(java.lang.String key, java.lang.String token, com.opensymphony.xwork2.ActionInvocation invocation)
Stores the DefaultActionInvocation and ActionContext into the Session using the provided key for loading later using {@link #loadInvocation}

param
key
param
invocation

        InvocationContext invocationContext = new InvocationContext(invocation, token);
        Map invocationMap = getInvocationMap();
        invocationMap.put(key, invocationContext);
        setInvocationMap(invocationMap);