当前位置: 首页>>代码示例>>Java>>正文


Java ActionContext.setContext方法代码示例

本文整理汇总了Java中com.opensymphony.xwork2.ActionContext.setContext方法的典型用法代码示例。如果您正苦于以下问题:Java ActionContext.setContext方法的具体用法?Java ActionContext.setContext怎么用?Java ActionContext.setContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.opensymphony.xwork2.ActionContext的用法示例。


在下文中一共展示了ActionContext.setContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanupRequest

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Cleans up a request of thread locals
 *
 * @param request servlet request
 */
public void cleanupRequest(HttpServletRequest request) {
    Integer counterVal = (Integer) request.getAttribute(CLEANUP_RECURSION_COUNTER);
    if (counterVal != null) {
        counterVal -= 1;
        request.setAttribute(CLEANUP_RECURSION_COUNTER, counterVal);
        if (counterVal > 0 ) {
            LOG.debug("skipping cleanup counter={}", counterVal);
            return;
        }
    }
    // always clean up the thread request, even if an action hasn't been executed
    try {
        dispatcher.cleanUpRequest(request);
    } finally {
        ActionContext.setContext(null);
        Dispatcher.setInstance(null);
        devModeOverride.remove();
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:25,代码来源:PrepareOperations.java

示例2: execute

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public String execute() throws Exception {
        ActionContext previous = ActionContext.getContext();
        ActionContext.setContext(invocation.getInvocationContext());
        try {
// This is for the new API:
//            return RequestContextImpl.callInContext(invocation, new Callable<String>() {
//                public String call() throws Exception {
//                    return invocation.invoke();
//                }
//            });

            // 源码解析: ActionInvocation调用
            return invocation.invoke();
        } finally {
            if (cleanupContext)
                ActionContext.setContext(previous);
        }
    }
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:StrutsActionProxy.java

示例3: initDispatcher

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static Dispatcher initDispatcher(ServletContext ctx, Map<String,String> params) {
    if (params == null) {
        params = new HashMap<>();
    }
    Dispatcher du = new DispatcherWrapper(ctx, params);
    du.init();
    Dispatcher.setInstance(du);

    // Reset the value stack
    Container container = du.getContainer();
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));
    
    return du;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:17,代码来源:StrutsTestCaseHelper.java

示例4: setUp

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static ConfigurationManager setUp() throws Exception {
    ConfigurationManager configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    Configuration config = configurationManager.getConfiguration();
    Container container = config.getContainer();
    
    // Reset the value stack
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));

    // clear out localization
    LocalizedTextUtil.reset();
    

    //ObjectFactory.setObjectFactory(container.getInstance(ObjectFactory.class));
    return configurationManager;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:19,代码来源:XWorkTestCaseHelper.java

示例5: getStack

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static ValueStack getStack(PageContext pageContext) {
    HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
    ValueStack stack = (ValueStack) req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);

    if (stack == null) {

        HttpServletResponse res = (HttpServletResponse) pageContext.getResponse();
        Dispatcher du = Dispatcher.getInstance();
        if (du == null) {
            throw new ConfigurationException("The Struts dispatcher cannot be found.  This is usually caused by "+
                    "using Struts tags without the associated filter. Struts tags are only usable when the request "+
                    "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.");
        }
        stack = du.getContainer().getInstance(ValueStackFactory.class).createValueStack();
        Map<String, Object> extraContext = du.createContextMap(new RequestMap(req),
                req.getParameterMap(),
                new SessionMap(req),
                new ApplicationMap(pageContext.getServletContext()),
                req,
                res);
        extraContext.put(ServletActionContext.PAGE_CONTEXT, pageContext);
        stack.getContext().putAll(extraContext);
        req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack);

        // also tie this stack/context to the ThreadLocal
        ActionContext.setContext(new ActionContext(stack.getContext()));
    } else {
        // let's make sure that the current page context is in the action context
        Map<String, Object> context = stack.getContext();
        context.put(ServletActionContext.PAGE_CONTEXT, pageContext);

        AttributeMap attrMap = new AttributeMap(context);
        context.put("attr", attrMap);
    }

    return stack;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:38,代码来源:TagUtils.java

示例6: cleanupDispatcher

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Cleans up the dispatcher instance
 */
public void cleanupDispatcher() {
    if (dispatcher == null) {
        throw new StrutsException("Something is seriously wrong, Dispatcher is not initialized (null) ");
    } else {
        try {
            dispatcher.cleanup();
        } finally {
            ActionContext.setContext(null);
        }
    }
}
 
开发者ID:txazo,项目名称:struts2,代码行数:15,代码来源:PrepareOperations.java

示例7: loadConfigurationProviders

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static ConfigurationManager loadConfigurationProviders(ConfigurationManager configurationManager,
        ConfigurationProvider... providers) {
    try {
        tearDown(configurationManager);
    } catch (Exception e) {
        throw new RuntimeException("Cannot clean old configuration", e);
    }
    configurationManager = new ConfigurationManager();
    configurationManager.addContainerProvider(new ContainerProvider() {
        public void destroy() {}
        public void init(Configuration configuration) throws ConfigurationException {}
        public boolean needsReload() { return false; }

        public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
            builder.setAllowDuplicates(true);
        }
        
    });
    configurationManager.addContainerProvider(new XWorkConfigurationProvider());
    for (ConfigurationProvider prov : providers) {
        if (prov instanceof XmlConfigurationProvider) {
            ((XmlConfigurationProvider)prov).setThrowExceptionOnDuplicateBeans(false);
        }
        configurationManager.addContainerProvider(prov);
    }
    Container container = configurationManager.getConfiguration().getContainer();
    
    // Reset the value stack
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    stack.getContext().put(ActionContext.CONTAINER, container);
    ActionContext.setContext(new ActionContext(stack.getContext()));
    
    return configurationManager;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:35,代码来源:XWorkTestCaseHelper.java

示例8: tearDown

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static void tearDown(ConfigurationManager configurationManager) throws Exception {

    //  clear out configuration
    if (configurationManager != null) {
        configurationManager.destroyConfiguration();
    }
    ActionContext.setContext(null);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:9,代码来源:XWorkTestCaseHelper.java

示例9: cleanup

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public void cleanup() {
    ActionContext.setContext(null);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:4,代码来源:InitOperations.java

示例10: tearDown

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static void tearDown() throws Exception {
    Dispatcher.setInstance(null);
    ActionContext.setContext(null);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:5,代码来源:StrutsTestCaseHelper.java

示例11: afterInvocation

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Called after the background thread determines the result code
 * from the ActionInvocation, but before the background thread is
 * marked as done.
 *
 * @throws Exception any exception thrown will be thrown, in turn, by the ExecuteAndWaitInterceptor
 */
protected void afterInvocation() throws Exception {
    ActionContext.setContext(null);
}
 
开发者ID:txazo,项目名称:struts2,代码行数:11,代码来源:BackgroundProcess.java

示例12: beforeInvocation

import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
/**
 * Called before the background thread determines the result code
 * from the ActionInvocation.
 *
 * @throws Exception any exception thrown will be thrown, in turn, by the ExecuteAndWaitInterceptor
 */
protected void beforeInvocation() throws Exception {
    ActionContext.setContext(invocation.getInvocationContext());
}
 
开发者ID:txazo,项目名称:struts2,代码行数:10,代码来源:BackgroundProcess.java


注:本文中的com.opensymphony.xwork2.ActionContext.setContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。