private boolean isConditionPassing(CacheOperationContext context, @Nullable Object result) { boolean passing = context.isConditionPassing(result); if (!passing && logger.isTraceEnabled()) { logger.trace("Cache condition failed on method " + context.metadata.method + " for operation " + context.metadata.operation); } return passing; }
private boolean hasCachePut(CacheOperationContexts contexts) { // Evaluate the conditions *without* the result object because we don't have it yet... Collection<CacheOperationContext> cachePutContexts = contexts.get(CachePutOperation.class); Collection<CacheOperationContext> excluded = new ArrayList<>(); for (CacheOperationContext context : cachePutContexts) { try { if (!context.isConditionPassing(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE)) { excluded.add(context); } } catch (VariableNotAvailableException ex) { // Ignoring failure due to missing result, consider the cache put has to proceed } } // Check if all puts have been excluded by condition return (cachePutContexts.size() != excluded.size()); }
private boolean isConditionPassing(CacheOperationContext context, @Nullable Object result) { boolean passing = context.isConditionPassing(result); if (!passing && logger.isTraceEnabled()) { logger.trace("Cache condition failed on method " + context.metadata.method + " for operation " + context.metadata.operation); } return passing; }
/** * Collect the {@link CachePutRequest} for all {@link CacheOperation} using * the specified result item. * @param contexts the contexts to handle * @param result the result item (never {@code null}) * @param putRequests the collection to update */ private void collectPutRequests(Collection<CacheOperationContext> contexts, @Nullable Object result, Collection<CachePutRequest> putRequests) { for (CacheOperationContext context : contexts) { if (isConditionPassing(context, result)) { Object key = generateKey(context, result); putRequests.add(new CachePutRequest(context, key)); } } }
private boolean hasCachePut(CacheOperationContexts contexts) { // Evaluate the conditions *without* the result object because we don't have it yet... Collection<CacheOperationContext> cachePutContexts = contexts.get(CachePutOperation.class); Collection<CacheOperationContext> excluded = new ArrayList<>(); for (CacheOperationContext context : cachePutContexts) { try { if (!context.isConditionPassing(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE)) { excluded.add(context); } } catch (VariableNotAvailableException ex) { // Ignoring failure due to missing result, consider the cache put has to proceed } } // Check if all puts have been excluded by condition return (cachePutContexts.size() != excluded.size()); }