List of usage examples for org.springframework.cache.interceptor CacheOperationInvocationContext getArgs
Object[] getArgs();
From source file:example.caching.RuntimeCacheResolver.java
@Override protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) { return Collections.singleton((String) context.getArgs()[1]); }
From source file:org.obiba.mica.dataset.DatasetCacheResolver.java
@Override public Collection<? extends Cache> resolveCaches( CacheOperationInvocationContext<?> cacheOperationInvocationContext) { Collection<Cache> res = Lists.newArrayList(); Optional<Object> dataset = Arrays.stream(cacheOperationInvocationContext.getArgs()) .filter(o -> o instanceof Dataset).findFirst(); if (dataset.isPresent()) { String cacheName = "dataset-" + ((Dataset) dataset.get()).getId(); Cache datasetCache = springCacheManager.getCache(cacheName); if (datasetCache == null) { CacheConfiguration conf = cacheManager.getEhcache("dataset-variables").getCacheConfiguration() .clone();/* www .jav a 2 s . com*/ conf.setName(cacheName); cacheManager.addCache(new net.sf.ehcache.Cache(conf)); net.sf.ehcache.Cache cache = cacheManager.getCache(cacheName); cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache)); datasetCache = new EhCacheCache(cacheManager.getEhcache(cacheName)); } res.add(datasetCache); } return res; }