Search in sources :

Example 1 with HttpCacheConfigComparator

use of com.adobe.acs.commons.httpcache.config.impl.HttpCacheConfigComparator in project acs-aem-commons by Adobe-Consulting-Services.

the class HttpCacheEngineImpl method bindHttpCacheConfig.

// -------------------<OSGi specific methods>---------------//
/**
 * Binds cache config. Cache config could come and go at run time.
 *
 * @param cacheConfig
 * @param configs
 */
protected void bindHttpCacheConfig(final HttpCacheConfig cacheConfig, final Map<String, Object> configs) {
    // Validate cache config object
    if (!cacheConfig.isValid()) {
        log.info("Http cache config rejected as the request uri is absent.");
        return;
    }
    // Check if the same object is already there in the map.
    if (cacheConfigs.contains(cacheConfig)) {
        log.trace("Http cache config object already exists in the cacheConfigs map and hence ignored.");
        return;
    }
    // Sort cacheConfigs by order
    final CopyOnWriteArrayList<HttpCacheConfig> tmp = new CopyOnWriteArrayList<HttpCacheConfig>(this.cacheConfigs);
    tmp.add(cacheConfig);
    Collections.sort(tmp, new HttpCacheConfigComparator());
    this.cacheConfigs = tmp;
    this.cacheConfigConfigs.put(cacheConfig, configs);
    log.debug("Total number of cache configs added: {}", cacheConfigs.size());
}
Also used : HttpCacheConfigComparator(com.adobe.acs.commons.httpcache.config.impl.HttpCacheConfigComparator) HttpCacheConfig(com.adobe.acs.commons.httpcache.config.HttpCacheConfig) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

HttpCacheConfig (com.adobe.acs.commons.httpcache.config.HttpCacheConfig)1 HttpCacheConfigComparator (com.adobe.acs.commons.httpcache.config.impl.HttpCacheConfigComparator)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1