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();
}
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();
}
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;
}
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;
}
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;
}
Aggregations