本文整理汇总了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();
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例9: cleanup
import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public void cleanup() {
ActionContext.setContext(null);
}
示例10: tearDown
import com.opensymphony.xwork2.ActionContext; //导入方法依赖的package包/类
public static void tearDown() throws Exception {
Dispatcher.setInstance(null);
ActionContext.setContext(null);
}
示例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);
}
示例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());
}