Example usage for org.apache.commons.chain.web WebContext getApplicationScope

List of usage examples for org.apache.commons.chain.web WebContext getApplicationScope

Introduction

In this page you can find the example usage for org.apache.commons.chain.web WebContext getApplicationScope.

Prototype

public abstract Map getApplicationScope();

Source Link

Document

Return a mutable Map that maps application scope attribute names to their values.

Usage

From source file:org.apache.struts.chain.AbstractSelectModule.java

/**
 * <p>Cache the <code>ModuleConfig</code> and <code>MessageResources</code>
 * instances for the sub-application module to be used for processing
 * this request.</p>/*from w  w  w.  j  ava  2s.  c o  m*/
 *
 * @param context The <code>Context</code> for the current request
 *
 * @exception IllegalArgumentException if no valid
 *  ModuleConfig or MessageResources can be identified for this request
 *
 * @return <code>false</code> so that processing continues
 */
public boolean execute(Context context) throws Exception {

    // Identify the module prefix for the current module
    String prefix = getPrefix(context);

    // Cache the corresponding ModuleConfig and MessageResources instances
    WebContext wcontext = (WebContext) context;
    ModuleConfig moduleConfig = (ModuleConfig) wcontext.getApplicationScope().get(Globals.MODULE_KEY + prefix);
    if (moduleConfig == null) {
        throw new IllegalArgumentException("No module config for prefix '" + prefix + "'");
    }
    wcontext.put(getModuleConfigKey(), moduleConfig);
    wcontext.getRequestScope().put(Globals.MODULE_KEY, moduleConfig);
    MessageResources messageResources = (MessageResources) wcontext.getApplicationScope()
            .get(Globals.MESSAGES_KEY + prefix);
    if (messageResources != null) {
        wcontext.put(getMessageResourcesKey(), messageResources);
        wcontext.getRequestScope().put(Globals.MESSAGES_KEY, messageResources);
    }

    return (false);

}

From source file:org.apache.struts.chain.CreateAction.java

/**
 * <p>Create (if necessary) and return a <code>Map</code> containing the
 * <code>Action</code> instances for the current application module.</p>
 *
 * @param context The context for this request
 * @param moduleConfig The <code>ModuleConfig</code> for the current
 *  application module/*w  w  w .j  a va2  s .  c  o m*/
 */
protected synchronized Map getActions(Context context, ModuleConfig moduleConfig) {

    WebContext wcontext = (WebContext) context;
    String actionsKey = Constants.ACTIONS_KEY + moduleConfig.getPrefix();
    Map actions = (Map) wcontext.getApplicationScope().get(actionsKey);
    if (actions == null) {
        actions = new HashMap();
        wcontext.getApplicationScope().put(actionKey, actions);
    }
    return (actions);

}