Search in sources :

Example 6 with PropertyNotFoundException

use of jakarta.el.PropertyNotFoundException in project tomcat 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));
    }
}
Also used : PropertyNotFoundException(jakarta.el.PropertyNotFoundException) VariableMapper(jakarta.el.VariableMapper) ValueExpression(jakarta.el.ValueExpression)

Example 7 with PropertyNotFoundException

use of jakarta.el.PropertyNotFoundException in project tomcat by apache.

the class AstIdentifier method getValue.

@Override
public Object getValue(EvaluationContext ctx) throws ELException {
    // Lambda parameters
    if (ctx.isLambdaArgument(this.image)) {
        return ctx.getLambdaArgument(this.image);
    }
    // Variable mapper
    VariableMapper varMapper = ctx.getVariableMapper();
    if (varMapper != null) {
        ValueExpression expr = varMapper.resolveVariable(this.image);
        if (expr != null) {
            return expr.getValue(ctx.getELContext());
        }
    }
    // EL Resolvers
    ctx.setPropertyResolved(false);
    Object result;
    /* Putting the Boolean into the ELContext is part of a performance
         * optimisation for ScopedAttributeELResolver. When looking up "foo",
         * the resolver can't differentiate between ${ foo } and ${ foo.bar }.
         * This is important because the expensive class lookup only needs to
         * be performed in the later case. This flag tells the resolver if the
         * lookup can be skipped.
         */
    if (parent instanceof AstValue) {
        ctx.putContext(this.getClass(), Boolean.FALSE);
    } else {
        ctx.putContext(this.getClass(), Boolean.TRUE);
    }
    try {
        result = ctx.getELResolver().getValue(ctx, null, this.image);
    } finally {
        // Always reset the flag to false so the optimisation is not applied
        // inappropriately
        ctx.putContext(this.getClass(), Boolean.FALSE);
    }
    if (ctx.isPropertyResolved()) {
        return result;
    }
    // Import
    result = ctx.getImportHandler().resolveClass(this.image);
    if (result != null) {
        return new ELClass((Class<?>) result);
    }
    result = ctx.getImportHandler().resolveStatic(this.image);
    if (result != null) {
        try {
            return ((Class<?>) result).getField(this.image).get(null);
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
            throw new ELException(e);
        }
    }
    throw new PropertyNotFoundException(MessageFactory.get("error.resolver.unhandled.null", this.image));
}
Also used : ELClass(jakarta.el.ELClass) PropertyNotFoundException(jakarta.el.PropertyNotFoundException) VariableMapper(jakarta.el.VariableMapper) ValueExpression(jakarta.el.ValueExpression) ELException(jakarta.el.ELException)

Example 8 with PropertyNotFoundException

use of jakarta.el.PropertyNotFoundException in project tomcat by apache.

the class JspMethodExpression method getMethodReference.

@Override
public MethodReference getMethodReference(ELContext context) {
    context.notifyBeforeEvaluation(getExpressionString());
    try {
        MethodReference result = this.target.getMethodReference(context);
        context.notifyAfterEvaluation(getExpressionString());
        return result;
    } catch (MethodNotFoundException e) {
        if (e instanceof JspMethodNotFoundException) {
            throw e;
        }
        throw new JspMethodNotFoundException(this.mark, e);
    } catch (PropertyNotFoundException e) {
        if (e instanceof JspPropertyNotFoundException) {
            throw e;
        }
        throw new JspPropertyNotFoundException(this.mark, e);
    } catch (ELException e) {
        if (e instanceof JspELException) {
            throw e;
        }
        throw new JspELException(this.mark, e);
    }
}
Also used : PropertyNotFoundException(jakarta.el.PropertyNotFoundException) MethodReference(jakarta.el.MethodReference) ELException(jakarta.el.ELException) MethodNotFoundException(jakarta.el.MethodNotFoundException)

Example 9 with PropertyNotFoundException

use of jakarta.el.PropertyNotFoundException in project tomcat by apache.

the class JspMethodExpression method getMethodInfo.

@Override
public MethodInfo getMethodInfo(ELContext context) throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException {
    context.notifyBeforeEvaluation(getExpressionString());
    try {
        MethodInfo result = this.target.getMethodInfo(context);
        context.notifyAfterEvaluation(getExpressionString());
        return result;
    } catch (MethodNotFoundException e) {
        if (e instanceof JspMethodNotFoundException) {
            throw e;
        }
        throw new JspMethodNotFoundException(this.mark, e);
    } catch (PropertyNotFoundException e) {
        if (e instanceof JspPropertyNotFoundException) {
            throw e;
        }
        throw new JspPropertyNotFoundException(this.mark, e);
    } catch (ELException e) {
        if (e instanceof JspELException) {
            throw e;
        }
        throw new JspELException(this.mark, e);
    }
}
Also used : PropertyNotFoundException(jakarta.el.PropertyNotFoundException) MethodInfo(jakarta.el.MethodInfo) ELException(jakarta.el.ELException) MethodNotFoundException(jakarta.el.MethodNotFoundException)

Aggregations

PropertyNotFoundException (jakarta.el.PropertyNotFoundException)9 ELException (jakarta.el.ELException)4 ValueExpression (jakarta.el.ValueExpression)4 VariableMapper (jakarta.el.VariableMapper)4 ELResolver (jakarta.el.ELResolver)3 MethodNotFoundException (jakarta.el.MethodNotFoundException)2 ELClass (jakarta.el.ELClass)1 LambdaExpression (jakarta.el.LambdaExpression)1 MethodInfo (jakarta.el.MethodInfo)1 MethodReference (jakarta.el.MethodReference)1 Optional (org.apache.el.stream.Optional)1