Map<String, Object> contextMap = new HashMap<String, Object>(); contextMap.put(StrutsStatics.HTTP_REQUEST, yourMockHttpServletRequest); ActionContext.setContext(new ActionContext(contextMap));
@Override protected void onActionSetup(Map<String, Object> contextMap) { super.onActionSetup(contextMap); String sessionId = UUID.randomUUID().toString(); XWorkRequestAttributes attributes = new XWorkRequestAttributes( new ActionContext(contextMap), sessionId); RequestContextHolder.setRequestAttributes(attributes); }
ActionContext.setContext(new ActionContext(vs.getContext()));
protected ActionContext setContext(Container cont) { ActionContext context = ActionContext.getContext(); if (context == null) { ValueStack vs = cont.getInstance(ValueStackFactory.class).createValueStack(); context = new ActionContext(vs.getContext()); ActionContext.setContext(context); } return context; }
public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext, ValueStack vs) { this.beanClass = beanClass; this.includeDefaultContext = includeDefaultContext; validationSupport = new ValidationAwareSupport(); validationContext = new DelegatingValidatorContext(validationSupport); if (vs == null) { // create a standalone value stack ConfigurationManager confManager = new ConfigurationManager(); Configuration conf = confManager.getConfiguration(); vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); if (log.isDebugEnabled()) { log.info("create a standalone value stack " + vs); } } else { if (log.isDebugEnabled()) { log.debug("use given value stack " + vs); } } context = new ActionContext(vs.getContext()); ActionContext.setContext(context); // init validator validator = context.getContainer().getInstance(ActionValidatorManager.class, "no-annotations"); // init context setContextName(contextName); }
public void init(ActionProxy proxy) { this.proxy = proxy; Map<String, Object> contextMap = createContextMap(); // Setting this so that other classes, like object factories, can use the ActionProxy and other // contextual information to operate ActionContext actionContext = ActionContext.getContext(); if (actionContext != null) { actionContext.setActionInvocation(this); } createAction(contextMap); if (pushAction) { stack.push(action); contextMap.put("action", action); } invocationContext = new ActionContext(contextMap); invocationContext.setName(proxy.getActionName()); createInterceptors(proxy); }
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; }
context = new ActionContext(vs.getContext());
protected Dispatcher initDispatcher(Map<String, String> params) { Dispatcher du = new Dispatcher(servletContext, params); du.init(); Dispatcher.setInstance(du); ValueStack stack = ((ValueStackFactory) du.getContainer().getInstance(ValueStackFactory.class)).createValueStack(); stack.getContext().put("com.opensymphony.xwork2.ActionContext.container", du.getContainer()); ActionContext.setContext(new ActionContext(stack.getContext())); configurationManager = du.getConfigurationManager(); configuration = configurationManager.getConfiguration(); container = configuration.getContainer(); return du; }
ActionContext.setContext(new ActionContext(stack.getContext()));
ctx = new ActionContext(vs.getContext()); if (ctx.getActionInvocation() == null) {