Search in sources :

Example 1 with CacheBuilder

use of com.alicp.jetcache.CacheBuilder in project jetcache by alibaba.

the class AbstractCacheAutoInit method process.

private void process(String prefix, Map cacheBuilders, boolean local) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(applicationContext.getEnvironment(), prefix);
    Map<String, Object> m = resolver.getSubProperties("");
    Set<String> cacheAreaNames = m.keySet().stream().map((s) -> s.substring(0, s.indexOf('.'))).collect(Collectors.toSet());
    for (String cacheArea : cacheAreaNames) {
        if (!typeName.equals(m.get(cacheArea + ".type"))) {
            continue;
        }
        RelaxedPropertyResolver r = new RelaxedPropertyResolver(applicationContext.getEnvironment(), prefix + cacheArea + ".");
        logger.info("init cache area {} , type= {}", cacheArea, typeName);
        CacheBuilder c = initCache(r, local ? "local." + cacheArea : "remote." + cacheArea);
        cacheBuilders.put(cacheArea, c);
    }
}
Also used : Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) BeansException(org.springframework.beans.BeansException) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConfigProvider(com.alicp.jetcache.anno.support.ConfigProvider) Map(java.util.Map) AbstractCacheBuilder(com.alicp.jetcache.AbstractCacheBuilder) PostConstruct(javax.annotation.PostConstruct) CacheBuilder(com.alicp.jetcache.CacheBuilder) ApplicationContextAware(org.springframework.context.ApplicationContextAware) AbstractCacheBuilder(com.alicp.jetcache.AbstractCacheBuilder) CacheBuilder(com.alicp.jetcache.CacheBuilder) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver)

Aggregations

AbstractCacheBuilder (com.alicp.jetcache.AbstractCacheBuilder)1 CacheBuilder (com.alicp.jetcache.CacheBuilder)1 ConfigProvider (com.alicp.jetcache.anno.support.ConfigProvider)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 BeansException (org.springframework.beans.BeansException)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 RelaxedPropertyResolver (org.springframework.boot.bind.RelaxedPropertyResolver)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ApplicationContextAware (org.springframework.context.ApplicationContextAware)1