Package org.springframework.expression

Examples of org.springframework.expression.EvaluationContext


    }

    public Object after(Authentication authentication, MethodInvocation mi,
            PostInvocationAttribute postAttr, Object returnedObject) throws AccessDeniedException{
        PostInvocationExpressionAttribute pia = (PostInvocationExpressionAttribute) postAttr;
        EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication, mi);
        Expression postFilter = pia.getFilterExpression();
        Expression postAuthorize = pia.getAuthorizeExpression();

        if (postFilter != null) {
            if (logger.isDebugEnabled()) {
View Full Code Here


        if (weca == null) {
            return ACCESS_ABSTAIN;
        }

        FilterInvocation fi = (FilterInvocation)object;
        EvaluationContext ctx = expressionHandler.createEvaluationContext(authentication, fi);

        return ExpressionUtils.evaluateAsBoolean(weca.getAuthorizeExpression(), ctx) ?
                ACCESS_GRANTED : ACCESS_DENIED;
    }
View Full Code Here

    private Lock getLock(Class<?> targetClass, Method method, Object[] args, Synchronized annotation) {
        logger.debug("Fetching lock for call [{}] on targetClass [{}] with SpEl condition [{}], SpEl discriminator " +
                "[{}], and SpEl id [{}] on thread {}", new Object[]{method.getName(), targetClass.getName(),
                annotation.condition(), annotation.discriminator(), annotation.id(), Thread.currentThread().getId()});

        EvaluationContext context = getEvaluationContext(targetClass, method, args);
        if (conditionPasses(annotation, method, context)) {
            logger.debug("Condition check passes for SpEl condition [{}] on thread {}", annotation.condition(),
                    Thread.currentThread().getId());
            String discriminator = getDiscriminator(annotation, method, context);
            String id = getId(annotation, method, context);
View Full Code Here

    }

    //this method was roughly based on the implementation of:
    //org.springframework.cache.interceptor.LazyParamAwareEvaluationContext#loadArgsAsVariables(...)
    private EvaluationContext getEvaluationContext(Class<?> targetClass, Method method, Object[] args) {
        EvaluationContext context = new StandardEvaluationContext();
        if (ArrayUtils.isEmpty(args)) {
            return context;
        }

        Method targetMethod = getTargetMethod(targetClass, method);
        for (int i = 0; i < args.length; i++) {
            context.setVariable("p" + i, args[i]);
        }

        String[] parameterNames = paramNameDiscoverer.getParameterNames(targetMethod);
        if (parameterNames != null) {
            for (int i = 0; i < parameterNames.length; i++) {
                context.setVariable(parameterNames[i], args[i]);
            }
        }

        return context;
    }
View Full Code Here

  public SitemapNode getNode(String id) { return nodes.get(id); }
 
  public String resolve(String exprStr, Map<String, Object> context) {
    log.debug("Resolving expression: {}", exprStr);
    Expression expr = exprParser.parseExpression(exprStr);
    EvaluationContext evalContext = new StandardEvaluationContext(context);
    return (String) expr.getValue(evalContext);
  }
View Full Code Here

      return combinedArgs;
    }

    protected boolean isConditionPassing(Object result) {
      if (StringUtils.hasText(this.metadata.operation.getCondition())) {
        EvaluationContext evaluationContext = createEvaluationContext(result);
        return evaluator.condition(this.metadata.operation.getCondition(),
            this.methodCacheKey, evaluationContext);
      }
      return true;
    }
View Full Code Here

      }
      else if (this.metadata.operation instanceof CachePutOperation) {
        unless = ((CachePutOperation) this.metadata.operation).getUnless();
      }
      if (StringUtils.hasText(unless)) {
        EvaluationContext evaluationContext = createEvaluationContext(value);
        return !evaluator.unless(unless, this.methodCacheKey, evaluationContext);
      }
      return true;
    }
View Full Code Here

     * Compute the key for the given caching operation.
     * @return the generated key, or {@code null} if none can be generated
     */
    protected Object generateKey(Object result) {
      if (StringUtils.hasText(this.metadata.operation.getKey())) {
        EvaluationContext evaluationContext = createEvaluationContext(result);
        return evaluator.key(this.metadata.operation.getKey(), this.methodCacheKey, evaluationContext);
      }
      return this.metadata.keyGenerator.generate(this.target, this.metadata.method, this.args);
    }
View Full Code Here

    return EVAL_BODY_INCLUDE;
  }

  @Override
  public int doEndTag() throws JspException {
    EvaluationContext evaluationContext =
        (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE);
    if (evaluationContext == null) {
      evaluationContext = createEvaluationContext(this.pageContext);
      this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext);
    }
View Full Code Here

    Method method = ReflectionUtils.findMethod(AnnotatedClass.class, "multipleCaching", Object.class,
        Object.class);
    Object[] args = new Object[] { new Object(), new Object() };
    Collection<ConcurrentMapCache> caches = Collections.singleton(new ConcurrentMapCache("test"));

    EvaluationContext evalCtx = eval.createEvaluationContext(caches, method, args, target, target.getClass());
    Collection<CacheOperation> ops = getOps("multipleCaching");

    Iterator<CacheOperation> it = ops.iterator();

    MethodCacheKey key = new MethodCacheKey(method, AnnotatedClass.class);
View Full Code Here

TOP

Related Classes of org.springframework.expression.EvaluationContext

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.