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;
}
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);
}
}
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());
}
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;
}
}
Aggregations