Example usage for org.springframework.expression EvaluationContext getPropertyAccessors

List of usage examples for org.springframework.expression EvaluationContext getPropertyAccessors

Introduction

In this page you can find the example usage for org.springframework.expression EvaluationContext getPropertyAccessors.

Prototype

List<PropertyAccessor> getPropertyAccessors();

Source Link

Document

Return a list of accessors that will be asked in turn to read/write a property.

Usage

From source file:com.vedri.mtp.frontend.support.stomp.DefaultSubscriptionRegistry.java

private MultiValueMap<String, String> filterSubscriptions(MultiValueMap<String, String> allMatches,
        Message<?> message) {/*from   ww  w.  j  a  v  a  2 s.com*/

    if (!this.selectorHeaderInUse) {
        return allMatches;
    }
    EvaluationContext context = null;
    MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>(allMatches.size());
    for (String sessionId : allMatches.keySet()) {
        for (String subId : allMatches.get(sessionId)) {
            SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId);
            if (info == null) {
                continue;
            }
            Subscription sub = info.getSubscription(subId);
            if (sub == null) {
                continue;
            }
            Expression expression = sub.getSelectorExpression();
            if (expression == null) {
                result.add(sessionId, subId);
                continue;
            }
            if (context == null) {
                context = new StandardEvaluationContext(message);
                context.getPropertyAccessors().add(new SimpMessageHeaderPropertyAccessor());
            }
            try {
                if (expression.getValue(context, boolean.class)) {
                    result.add(sessionId, subId);
                }
            } catch (SpelEvaluationException ex) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Failed to evaluate selector: " + ex.getMessage());
                }
            } catch (Throwable ex) {
                logger.debug("Failed to evaluate selector", ex);
            }
        }
    }
    return result;
}