Search in sources :

Example 1 with CompoundRootAccessor

use of com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor in project struts by apache.

the class OgnlValueStackFactory method createValueStack.

public ValueStack createValueStack(ValueStack stack) {
    ValueStack result = new OgnlValueStack(stack, xworkConverter, compoundRootAccessor, containerAllowsStaticMethodAccess(), containerAllowsStaticFieldAccess());
    container.inject(result);
    return result.getActionContext().withContainer(container).withValueStack(result).getValueStack();
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 2 with CompoundRootAccessor

use of com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor in project struts by apache.

the class OgnlValueStackFactory method createValueStack.

public ValueStack createValueStack() {
    ValueStack stack = new OgnlValueStack(xworkConverter, compoundRootAccessor, textProvider, containerAllowsStaticMethodAccess(), containerAllowsStaticFieldAccess());
    container.inject(stack);
    return stack.getActionContext().withContainer(container).withValueStack(stack).getValueStack();
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 3 with CompoundRootAccessor

use of com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor in project struts by apache.

the class OgnlValueStackFactory method setContainer.

@Inject
protected void setContainer(Container container) throws ClassNotFoundException {
    Set<String> names = container.getInstanceNames(PropertyAccessor.class);
    for (String name : names) {
        Class cls = Class.forName(name);
        if (cls != null) {
            if (Map.class.isAssignableFrom(cls)) {
                PropertyAccessor acc = container.getInstance(PropertyAccessor.class, name);
            }
            OgnlRuntime.setPropertyAccessor(cls, container.getInstance(PropertyAccessor.class, name));
            if (compoundRootAccessor == null && CompoundRoot.class.isAssignableFrom(cls)) {
                compoundRootAccessor = (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, name);
            }
        }
    }
    names = container.getInstanceNames(MethodAccessor.class);
    for (String name : names) {
        Class cls = Class.forName(name);
        if (cls != null) {
            OgnlRuntime.setMethodAccessor(cls, container.getInstance(MethodAccessor.class, name));
        }
    }
    names = container.getInstanceNames(NullHandler.class);
    for (String name : names) {
        Class cls = Class.forName(name);
        if (cls != null) {
            OgnlRuntime.setNullHandler(cls, new OgnlNullHandlerWrapper(container.getInstance(NullHandler.class, name)));
        }
    }
    if (compoundRootAccessor == null) {
        throw new IllegalStateException("Couldn't find the compound root accessor");
    }
    this.container = container;
}
Also used : PropertyAccessor(ognl.PropertyAccessor) NullHandler(com.opensymphony.xwork2.conversion.NullHandler) MethodAccessor(ognl.MethodAccessor) CompoundRoot(com.opensymphony.xwork2.util.CompoundRoot) Inject(com.opensymphony.xwork2.inject.Inject)

Example 4 with CompoundRootAccessor

use of com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor in project struts by apache.

the class ValidateAction method createStubValueStack.

private ValueStack createStubValueStack(final Map<String, Object> actual) {
    ValueStack stack = new OgnlValueStack(container.getInstance(XWorkConverter.class), (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()), container.getInstance(TextProvider.class, "system"), true, true) {

        @Override
        public void setValue(String expr, Object value) {
            actual.put(expr, value);
        }

        @Override
        public void setParameter(String expr, Object value) {
            actual.put(expr, value);
        }
    };
    container.inject(stack);
    return stack;
}
Also used : OgnlValueStack(com.opensymphony.xwork2.ognl.OgnlValueStack) OgnlValueStack(com.opensymphony.xwork2.ognl.OgnlValueStack) ValueStack(com.opensymphony.xwork2.util.ValueStack) XWorkConverter(com.opensymphony.xwork2.conversion.impl.XWorkConverter) CompoundRoot(com.opensymphony.xwork2.util.CompoundRoot) TextProvider(com.opensymphony.xwork2.TextProvider)

Example 5 with CompoundRootAccessor

use of com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor in project struts by apache.

the class OgnlValueStack method readResolve.

private Object readResolve() {
    // TODO: this should be done better
    ActionContext ac = ActionContext.getContext();
    Container cont = ac.getContainer();
    XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
    CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
    TextProvider prov = cont.getInstance(TextProvider.class, "system");
    final boolean allowStaticMethod = BooleanUtils.toBoolean(cont.getInstance(String.class, StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS));
    final boolean allowStaticField = BooleanUtils.toBoolean(cont.getInstance(String.class, StrutsConstants.STRUTS_ALLOW_STATIC_FIELD_ACCESS));
    OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allowStaticMethod, allowStaticField);
    aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
    aStack.setRoot(xworkConverter, accessor, this.root, allowStaticMethod, allowStaticField);
    return aStack;
}
Also used : Container(com.opensymphony.xwork2.inject.Container) CompoundRootAccessor(com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor) XWorkConverter(com.opensymphony.xwork2.conversion.impl.XWorkConverter) ActionContext(com.opensymphony.xwork2.ActionContext) TextProvider(com.opensymphony.xwork2.TextProvider)

Aggregations

ValueStack (com.opensymphony.xwork2.util.ValueStack)3 TextProvider (com.opensymphony.xwork2.TextProvider)2 XWorkConverter (com.opensymphony.xwork2.conversion.impl.XWorkConverter)2 CompoundRoot (com.opensymphony.xwork2.util.CompoundRoot)2 ActionContext (com.opensymphony.xwork2.ActionContext)1 NullHandler (com.opensymphony.xwork2.conversion.NullHandler)1 Container (com.opensymphony.xwork2.inject.Container)1 Inject (com.opensymphony.xwork2.inject.Inject)1 OgnlValueStack (com.opensymphony.xwork2.ognl.OgnlValueStack)1 CompoundRootAccessor (com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor)1 MethodAccessor (ognl.MethodAccessor)1 PropertyAccessor (ognl.PropertyAccessor)1