use of javax.el.VariableMapper in project tomcat70 by apache.
the class AstIdentifier method getMethodExpression.
private final MethodExpression getMethodExpression(EvaluationContext ctx) throws ELException {
Object obj = null;
// case A: ValueExpression exists, getValue which must
// be a MethodExpression
VariableMapper varMapper = ctx.getVariableMapper();
ValueExpression ve = null;
if (varMapper != null) {
ve = varMapper.resolveVariable(this.image);
if (ve != null) {
obj = ve.getValue(ctx);
}
}
// a MethodExpression to be able to invoke
if (ve == null) {
ctx.setPropertyResolved(false);
obj = ctx.getELResolver().getValue(ctx, null, this.image);
}
// finally provide helpful hints
if (obj instanceof MethodExpression) {
return (MethodExpression) obj;
} else if (obj == null) {
throw new MethodNotFoundException("Identity '" + this.image + "' was null and was unable to invoke");
} else {
throw new ELException("Identity '" + this.image + "' does not reference a MethodExpression instance, returned type: " + obj.getClass().getName());
}
}
use of javax.el.VariableMapper in project tomcat70 by apache.
the class AstIdentifier method setValue.
@Override
public void setValue(EvaluationContext ctx, Object value) throws ELException {
VariableMapper varMapper = ctx.getVariableMapper();
if (varMapper != null) {
ValueExpression expr = varMapper.resolveVariable(this.image);
if (expr != null) {
expr.setValue(ctx.getELContext(), value);
return;
}
}
ctx.setPropertyResolved(false);
ctx.getELResolver().setValue(ctx, null, this.image, value);
if (!ctx.isPropertyResolved()) {
throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
}
}
use of javax.el.VariableMapper in project Activiti by Activiti.
the class JuelScriptEngine method createElContext.
private ELContext createElContext(final ScriptContext scriptCtx) {
// Check if the ELContext is already stored on the ScriptContext
Object existingELCtx = scriptCtx.getAttribute("elcontext");
if (existingELCtx instanceof ELContext) {
return (ELContext) existingELCtx;
}
scriptCtx.setAttribute("context", scriptCtx, ScriptContext.ENGINE_SCOPE);
// Built-in function are added to ScriptCtx
scriptCtx.setAttribute("out:print", getPrintMethod(), ScriptContext.ENGINE_SCOPE);
SecurityManager securityManager = System.getSecurityManager();
if (securityManager == null) {
scriptCtx.setAttribute("lang:import", getImportMethod(), ScriptContext.ENGINE_SCOPE);
}
ELContext elContext = new ELContext() {
ELResolver resolver = createElResolver();
VariableMapper varMapper = new ScriptContextVariableMapper(scriptCtx);
FunctionMapper funcMapper = new ScriptContextFunctionMapper(scriptCtx);
@Override
public ELResolver getELResolver() {
return resolver;
}
@Override
public VariableMapper getVariableMapper() {
return varMapper;
}
@Override
public FunctionMapper getFunctionMapper() {
return funcMapper;
}
};
// Store the elcontext in the scriptContext to be able to reuse
scriptCtx.setAttribute("elcontext", elContext, ScriptContext.ENGINE_SCOPE);
return elContext;
}
use of javax.el.VariableMapper in project tomee by apache.
the class StatefulConversationScopedTOMEE1138Test method el.
@Test
public void el() {
final BeanELResolver elResolver = new BeanELResolver();
assertEquals("John", elResolver.getValue(new ELContext() {
@Override
public ELResolver getELResolver() {
return elResolver;
}
@Override
public FunctionMapper getFunctionMapper() {
return new FunctionMapper() {
@Override
public Method resolveFunction(final String prefix, final String localName) {
return null;
}
};
}
@Override
public VariableMapper getVariableMapper() {
return new VariableMapper() {
@Override
public ValueExpression resolveVariable(final String variable) {
return null;
}
@Override
public ValueExpression setVariable(final String variable, final ValueExpression expression) {
return null;
}
};
}
}, conversationByName, "name"));
}
use of javax.el.VariableMapper in project tomcat70 by apache.
the class AstIdentifier method getValue.
@Override
public Object getValue(EvaluationContext ctx) throws ELException {
VariableMapper varMapper = ctx.getVariableMapper();
if (varMapper != null) {
ValueExpression expr = varMapper.resolveVariable(this.image);
if (expr != null) {
return expr.getValue(ctx.getELContext());
}
}
ctx.setPropertyResolved(false);
Object result = ctx.getELResolver().getValue(ctx, null, this.image);
if (!ctx.isPropertyResolved()) {
throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
}
return result;
}
Aggregations