Search in sources :

Example 1 with Cache

use of org.camunda.bpm.engine.rest.cache.Cache in project camunda-bpm-platform by camunda.

the class HalRelationCacheBootstrap method createCache.

protected Cache createCache(Class<? extends Cache> cacheClass, Map<String, Object> cacheConfiguration) {
    Cache cache = createCacheInstance(cacheClass);
    configureCache(cache, cacheConfiguration);
    return cache;
}
Also used : Cache(org.camunda.bpm.engine.rest.cache.Cache)

Example 2 with Cache

use of org.camunda.bpm.engine.rest.cache.Cache in project camunda-bpm-platform by camunda.

the class HalRelationCacheBootstrap method configureCaches.

public void configureCaches(HalRelationCacheConfiguration configuration) {
    Class<? extends Cache> cacheClass = configuration.getCacheImplementationClass();
    for (Map.Entry<Class<?>, Map<String, Object>> cacheConfiguration : configuration.getCacheConfigurations().entrySet()) {
        Cache cache = createCache(cacheClass, cacheConfiguration.getValue());
        registerCache(cacheConfiguration.getKey(), cache);
    }
}
Also used : Map(java.util.Map) Cache(org.camunda.bpm.engine.rest.cache.Cache)

Example 3 with Cache

use of org.camunda.bpm.engine.rest.cache.Cache in project camunda-bpm-platform by camunda.

the class HalResourceCacheTest method testCacheCreation.

@Test
public void testCacheCreation() {
    String contextParameter = "{" + "\"" + CONFIG_CACHE_IMPLEMENTATION + "\": \"" + DefaultHalResourceCache.class.getName() + "\"," + "\"" + CONFIG_CACHES + "\": {" + "\"" + HalUser.class.getName() + "\": {" + "\"capacity\": 123, \"secondsToLive\": 123" + "}" + "}" + "}";
    contextListener.configureCaches(contextParameter);
    Cache cache = Hal.getInstance().getHalRelationCache(HalUser.class);
    assertNotNull(cache);
    assertEquals(123, ((DefaultHalResourceCache) cache).getCapacity());
    assertEquals(123, ((DefaultHalResourceCache) cache).getSecondsToLive());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Cache(org.camunda.bpm.engine.rest.cache.Cache) DefaultHalResourceCache(org.camunda.bpm.engine.rest.hal.cache.DefaultHalResourceCache) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 4 with Cache

use of org.camunda.bpm.engine.rest.cache.Cache in project camunda-bpm-platform by camunda.

the class HalCachingLinkResolver method resolveLinks.

/**
 * Resolve resources for linked ids, if configured uses a cache.
 */
public List<HalResource<?>> resolveLinks(String[] linkedIds, ProcessEngine processEngine) {
    Cache cache = getCache();
    if (cache == null) {
        return resolveNotCachedLinks(linkedIds, processEngine);
    } else {
        ArrayList<String> notCachedLinkedIds = new ArrayList<String>();
        List<HalResource<?>> resolvedResources = resolveCachedLinks(linkedIds, cache, notCachedLinkedIds);
        if (!notCachedLinkedIds.isEmpty()) {
            List<HalResource<?>> notCachedResources = resolveNotCachedLinks(notCachedLinkedIds.toArray(new String[notCachedLinkedIds.size()]), processEngine);
            resolvedResources.addAll(notCachedResources);
            putIntoCache(notCachedResources);
        }
        sortResolvedResources(resolvedResources);
        return resolvedResources;
    }
}
Also used : ArrayList(java.util.ArrayList) HalResource(org.camunda.bpm.engine.rest.hal.HalResource) Cache(org.camunda.bpm.engine.rest.cache.Cache)

Aggregations

Cache (org.camunda.bpm.engine.rest.cache.Cache)4 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)1 HalResource (org.camunda.bpm.engine.rest.hal.HalResource)1 DefaultHalResourceCache (org.camunda.bpm.engine.rest.hal.cache.DefaultHalResourceCache)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1