All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netgrif.application.engine.configuration.NaeCacheResolver Maven / Gradle / Ivy

Go to download

System provides workflow management functions including user, role and data management.

There is a newer version: 6.3.3
Show newest version
package com.netgrif.application.engine.configuration;

import com.netgrif.application.engine.configuration.properties.CacheProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
import org.springframework.cache.interceptor.CacheResolver;

import java.util.Collection;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

public class NaeCacheResolver implements CacheResolver {

    private final CacheManager cacheManager;

    private final CacheProperties cacheProperties;

    public NaeCacheResolver(CacheManager cacheManager, CacheProperties cacheProperties) {
        this.cacheManager = cacheManager;
        this.cacheProperties = cacheProperties;
    }

    @Override
    public Collection resolveCaches(CacheOperationInvocationContext context) {
        Set cacheIds = cacheProperties.getAllCaches();
        return context.getOperation().getCacheNames().stream()
                .filter(cacheIds::contains)
                .map(cacheManager::getCache)
                .filter(Objects::nonNull)
                .collect(Collectors.toSet());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy