Package org.springframework.expression

Examples of org.springframework.expression.Expression


        return new SpelExpression(expression, Object.class);
    }

    public <T> T evaluate(Exchange exchange, Class<T> tClass) {
        try {
            Expression expression = parseExpression();
            EvaluationContext evaluationContext = createEvaluationContext(exchange);
            Object value = expression.getValue(evaluationContext);
            // Let Camel handle the type conversion
            return exchange.getContext().getTypeConverter().convertTo(tClass, value);
        } catch (Exception e) {
            throw new ExpressionEvaluationException(this, exchange, e);
        }
View Full Code Here


    }

    private Expression parseExpression() {
        // Support template parsing with #{ } delimiters
        ParserContext parserContext = new TemplateParserContext();
        Expression expression = expressionParser.parseExpression(expressionString, parserContext);
        return expression;
    }
View Full Code Here

        return new SpelExpression(expression, Object.class);
    }

    public <T> T evaluate(Exchange exchange, Class<T> tClass) {
        try {
            Expression expression = parseExpression();
            EvaluationContext evaluationContext = createEvaluationContext(exchange);
            Object value = expression.getValue(evaluationContext);
            // Let Camel handle the type conversion
            return exchange.getContext().getTypeConverter().convertTo(tClass, value);
        } catch (Exception e) {
            throw new ExpressionEvaluationException(this, exchange, e);
        }
View Full Code Here

    }

    private Expression parseExpression() {
        // Support template parsing with #{ } delimiters
        ParserContext parserContext = new TemplateParserContext();
        Expression expression = expressionParser.parseExpression(expressionString, parserContext);
        return expression;
    }
View Full Code Here

        args, targetClass, targetMethodCache);
  }

  public boolean condition(String conditionExpression, Method method, EvaluationContext evalContext) {
    String key = toString(method, conditionExpression);
    Expression condExp = conditionCache.get(key);
    if (condExp == null) {
      condExp = parser.parseExpression(conditionExpression);
      conditionCache.put(key, condExp);
    }
    return condExp.getValue(evalContext, boolean.class);
  }
View Full Code Here

    return condExp.getValue(evalContext, boolean.class);
  }

  public Object key(String keyExpression, Method method, EvaluationContext evalContext) {
    String key = toString(method, keyExpression);
    Expression keyExp = keyCache.get(key);
    if (keyExp == null) {
      keyExp = parser.parseExpression(keyExpression);
      keyCache.put(key, keyExp);
    }
    return keyExp.getValue(evalContext);
  }
View Full Code Here

    this.template = template;
    this.context.addPropertyAccessor(new MapAccessor());
    this.helper = new PropertyPlaceholderHelper("${", "}");
    this.resolver = new PlaceholderResolver() {
      public String resolvePlaceholder(String name) {
        Expression expression = parser.parseExpression(name);
        Object value = expression.getValue(context);
        return value == null ? null : value.toString();
      }
    };
  }
View Full Code Here

    Authentication userAuthentication = new UsernamePasswordAuthenticationToken("user", "pass",
        AuthorityUtils.createAuthorityList("ROLE_USER"));
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    FilterInvocation invocation = new FilterInvocation("/foo", "GET");
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression(
        "#oauth2.hasAnyScope('write') or #oauth2.isUser()");
    assertTrue((Boolean) expression.getValue(context));
  }
View Full Code Here

            request.getResponseTypes(), request.getExtensions());

    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    FilterInvocation invocation = new FilterInvocation("/foo", "GET");
    Expression expression = handler.getExpressionParser()
        .parseExpression("#oauth2.clientHasAnyRole('ROLE_CLIENT')");
    assertTrue((Boolean) expression.getValue(handler.createEvaluationContext(oAuth2Authentication, invocation)));
  }
View Full Code Here

    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false,
        Collections.singleton("read"));
    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    FilterInvocation invocation = new FilterInvocation("/foo", "GET");
    Expression expression = handler.getExpressionParser().parseExpression("#oauth2.hasAnyScope('read')");
    assertTrue((Boolean) expression.getValue(handler.createEvaluationContext(oAuth2Authentication, invocation)));
  }
View Full Code Here

TOP

Related Classes of org.springframework.expression.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.