Пример #1
0
  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);
      }
    }

    // case B: evaluate the identity against the ELResolver, again, must be
    // 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());
    }
  }
Пример #2
0
 @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));
   }
 }
Пример #3
0
 @Override
 public boolean isReadOnly(EvaluationContext ctx) throws ELException {
   VariableMapper varMapper = ctx.getVariableMapper();
   if (varMapper != null) {
     ValueExpression expr = varMapper.resolveVariable(this.image);
     if (expr != null) {
       return expr.isReadOnly(ctx.getELContext());
     }
   }
   ctx.setPropertyResolved(false);
   boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image);
   if (!ctx.isPropertyResolved()) {
     throw new PropertyNotFoundException(
         MessageFactory.get("error.resolver.unhandled.null", this.image));
   }
   return result;
 }
Пример #4
0
  @Override
  public ValueReference getValueReference(EvaluationContext ctx) {
    VariableMapper varMapper = ctx.getVariableMapper();

    if (varMapper == null) {
      return null;
    }

    ValueExpression expr = varMapper.resolveVariable(this.image);

    if (expr == null) {
      return null;
    }

    return expr.getValueReference(ctx);
  }
Пример #5
0
 @Override
 public MethodInfo getMethodInfo(EvaluationContext ctx, Class<?>[] paramTypes) throws ELException {
   return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext());
 }
Пример #6
0
 @Override
 public Object invoke(EvaluationContext ctx, Class<?>[] paramTypes, Object[] paramValues)
     throws ELException {
   return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues);
 }