Search in sources :

Example 1 with CachingMap

use of org.apache.sling.scripting.core.impl.helper.CachingMap in project sling by apache.

the class ScriptCacheImpl method activate.

@Activate
protected void activate(ScriptCacheImplConfiguration configuration, BundleContext bundleCtx) {
    threadPool = threadPoolManager.get("Script Cache Thread Pool");
    bundleContext = bundleCtx;
    additionalExtensions = configuration.org_apache_sling_scripting_cache_additional__extensions();
    int newMaxCacheSize = configuration.org_apache_sling_scripting_cache_size();
    if (newMaxCacheSize != DEFAULT_CACHE_SIZE) {
        // change the map only if there's a configuration change regarding the cache's max size
        CachingMap<CachedScript> newMap = new CachingMap<>(newMaxCacheSize);
        newMap.putAll(internalMap);
        internalMap = newMap;
    }
    ResourceResolver resolver = null;
    try {
        resolver = rrf.getServiceResourceResolver(null);
        searchPaths = resolver.getSearchPath();
    } catch (LoginException e) {
        LOGGER.error("Unable to retrieve a ResourceResolver for determining the search paths.", e);
    } finally {
        if (resolver != null) {
            resolver.close();
        }
    }
    configureCache();
    active = true;
}
Also used : CachingMap(org.apache.sling.scripting.core.impl.helper.CachingMap) CachedScript(org.apache.sling.scripting.api.CachedScript) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) LoginException(org.apache.sling.api.resource.LoginException) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

LoginException (org.apache.sling.api.resource.LoginException)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 CachedScript (org.apache.sling.scripting.api.CachedScript)1 CachingMap (org.apache.sling.scripting.core.impl.helper.CachingMap)1 Activate (org.osgi.service.component.annotations.Activate)1