protected Map<String, Object> createContextMap() { Map<String, Object> contextMap; if ((extraContext != null) && (extraContext.containsKey(ActionContext.VALUE_STACK))) { // In case the ValueStack was passed in stack = (ValueStack) extraContext.get(ActionContext.VALUE_STACK); if (stack == null) { throw new IllegalStateException("There was a null Stack set into the extra params."); } contextMap = stack.getContext(); } else { // create the value stack // this also adds the ValueStack to its context stack = valueStackFactory.createValueStack(); // create the action context contextMap = stack.getContext(); } // put extraContext in if (extraContext != null) { contextMap.putAll(extraContext); } //put this DefaultActionInvocation into the context map contextMap.put(ActionContext.ACTION_INVOCATION, this); contextMap.put(ActionContext.CONTAINER, container); return contextMap; }
public static synchronized ValueStack getSharedValueStack() { if (sharedValueStack == null) { // init context ConfigurationManager confManager = new ConfigurationManager(); Configuration conf = confManager.getConfiguration(); sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack(); if (log.isDebugEnabled()) { log.debug("init shared value stack " + sharedValueStack); } } return sharedValueStack; }
public static ValueStack createValuestack() { ValueStack result; ActionContext context = ActionContext.getContext(); if (context == null) { // no action context, create a value stack from scratch ConfigurationManager confManager = new ConfigurationManager("xwork"); Configuration conf = confManager.getConfiguration(); Container container = conf.getContainer(); ValueStackFactory stackFactory = container.getInstance(ValueStackFactory.class); result = stackFactory.createValueStack(); } else { // there is an action context, try to use his value stack result = context.getValueStack(); if (result == null) { // no value stack, create then a new one ValueStackFactory stackFactory = context.getInstance(ValueStackFactory.class); result = stackFactory.createValueStack(); } } return result; }
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; }
/** * Iterates over GXP parameters, pulls value from value stack for each * parameter, and appends the values to an argument list which will * be passed to a method on a GXP. * * @param overrides parameter map pushed onto the value stack * * @return list of arguments */ List getArgListFromValueStack(Map overrides) { ValueStack valueStack = valueStackFactory.createValueStack(ActionContext.getContext().getValueStack()); // add default values to the bottom of the stack. if no action provides // a getter for a param, the default value will be used. valueStack.getRoot().add(this.defaultValues); // push override parameters onto the stack. if (overrides != null && !overrides.isEmpty()) { valueStack.push(overrides); } List args = new ArrayList(params.size()); for (Param param : getParams()) { try { args.add(valueStack.findValue(param.getName(), param.getType())); } catch (Exception e) { throw new RuntimeException("Exception while finding '" + param.getName() + "'.", e); } } return args; }
ValueStack newStack = valueStackFactory.createValueStack(stack); boolean clearableStack = newStack instanceof ClearableValueStack; if (clearableStack) {
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 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; }
ValueStack newStack = valueStackFactory.createValueStack(stack); boolean clearableStack = newStack instanceof ClearableValueStack; if (clearableStack) {
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; }
final ValueStack stack = ac.getValueStack(); ValueStack newStack = valueStackFactory.createValueStack(stack); boolean clearableStack = newStack instanceof ClearableValueStack; if (clearableStack) {
ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack(); stack.getContext().put(ActionContext.CONTAINER, container); ActionContext.setContext(new ActionContext(stack.getContext()));
if (ctx == null) { ValueStack vs = Dispatcher.getInstance().getContainer().getInstance(ValueStackFactory.class).createValueStack(); vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null)); ctx = new ActionContext(vs.getContext());