@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { return context.getOperation().getCacheNames(); }
@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { return context.getOperation().getCacheNames(); }
@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { return context.getOperation().getCacheNames(); }
@Override protected Collection<String> getCacheNames(final CacheOperationInvocationContext<?> context) { final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (!(authentication instanceof HodAuthentication)) { throw new IllegalStateException("There is no HOD authentication token in the security context holder"); } final HodAuthenticationPrincipal principal = ((HodAuthentication) authentication).getPrincipal(); final Set<String> contextCacheNames = context.getOperation().getCacheNames(); final Collection<String> resolvedCacheNames = contextCacheNames.stream().map(cacheName -> resolveName(cacheName, principal)).collect(Collectors.toCollection(HashSet::new)); return resolvedCacheNames; }
@Bean @Override public CacheResolver cacheResolver() { return context -> context.getOperation().getCacheNames().stream() .peek(name -> log.debug("Requested cache name = '{}', cache manager caches = {}", name, cacheManager().getCacheNames())) .map(name -> cacheManager().getCache(name)) .filter(Objects::nonNull) .peek(cache -> log.debug("Resolved cache {} which is a {} cache", cache.getName(), cache.getClass())) .collect(Collectors.toList()); } }
@Override public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) { List<Cache> caches = new ArrayList<Cache>(); for(String cacheName : context.getOperation().getCacheNames()) { caches.add(cacheManager.getCache(cacheName)); } if(context.getTarget() instanceof UserService2) { caches.add(cacheManager.getCache("user2")); caches.add(cacheManager.getCache("user3")); } return caches; } }
@Override public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext<?> context) { BasicOperation operation = context.getOperation(); Set<String> cacheNames = operation.getCacheNames(); if (cacheNames.isEmpty()) { return Collections.emptyList();