List of usage examples for org.springframework.cache CacheManager getCache
@Nullable Cache getCache(String name);
From source file:org.eclipse.hono.client.impl.TenantClientImpl.java
/** * Creates a new tenant API client./* w ww . j a v a 2 s . c o m*/ * * @param context The vert.x context to run all interactions with the server on. * @param clientConfig The configuration properties to use. * @param cacheManager A factory for cache instances for tenant configuration results. If {@code null} * the client will not cache any results from the Tenant service. * @param con The AMQP connection to the server. * @param senderCloseHook A handler to invoke if the peer closes the sender link unexpectedly. * @param receiverCloseHook A handler to invoke if the peer closes the receiver link unexpectedly. * @param creationHandler The handler to invoke with the outcome of the creation attempt. * @throws NullPointerException if any of the parameters, except for senderCloseHook and receiverCloseHook, is {@code null}. */ public final static void create(final Context context, final ClientConfigProperties clientConfig, final CacheManager cacheManager, final ProtonConnection con, final Handler<String> senderCloseHook, final Handler<String> receiverCloseHook, final Handler<AsyncResult<TenantClient>> creationHandler) { LOG.debug("creating new tenant API client."); final TenantClientImpl client = new TenantClientImpl(context, clientConfig); if (cacheManager != null) { final Cache cache = cacheManager.getCache(TenantClientImpl.getTargetAddress()); client.setResponseCache(new SpringBasedExpiringValueCache<>(cache)); } client.createLinks(con, senderCloseHook, receiverCloseHook).setHandler(s -> { if (s.succeeded()) { LOG.debug("successfully created tenant API client"); creationHandler.handle(Future.succeededFuture(client)); } else { LOG.debug("failed to create tenant API client", s.cause()); creationHandler.handle(Future.failedFuture(s.cause())); } }); }
From source file:org.eclipse.hono.client.impl.RegistrationClientImpl.java
/** * Creates a new registration client for a tenant. * /*from w w w. ja v a 2 s. c om*/ * @param context The vert.x context to run all interactions with the server on. * @param clientConfig The configuration properties to use. * @param cacheManager A factory for cache instances for registration results. If {@code null} * the client will not cache any results from the Device Registration service. * @param con The AMQP connection to the server. * @param tenantId The tenant to consumer events for. * @param senderCloseHook A handler to invoke if the peer closes the sender link unexpectedly. * @param receiverCloseHook A handler to invoke if the peer closes the receiver link unexpectedly. * @param creationHandler The handler to invoke with the outcome of the creation attempt. * @throws NullPointerException if any of the parameters other than cache manager is {@code null}. */ public static final void create(final Context context, final ClientConfigProperties clientConfig, final CacheManager cacheManager, final ProtonConnection con, final String tenantId, final Handler<String> senderCloseHook, final Handler<String> receiverCloseHook, final Handler<AsyncResult<RegistrationClient>> creationHandler) { LOG.debug("creating new registration client for [{}]", tenantId); final RegistrationClientImpl client = new RegistrationClientImpl(context, clientConfig, tenantId); if (cacheManager != null) { final Cache cache = cacheManager.getCache(RegistrationClientImpl.getTargetAddress(tenantId)); client.setResponseCache(new SpringBasedExpiringValueCache<>(cache)); } client.createLinks(con, senderCloseHook, receiverCloseHook).setHandler(s -> { if (s.succeeded()) { LOG.debug("successfully created registration client for [{}]", tenantId); creationHandler.handle(Future.succeededFuture(client)); } else { LOG.debug("failed to create registration client for [{}]", tenantId, s.cause()); creationHandler.handle(Future.failedFuture(s.cause())); } }); }
From source file:ru.org.linux.user.UserDaoIntegrationTestConfiguration.java
@Bean(name = "usersCache") public Cache usersCache(CacheManager cacheManager) { return cacheManager.getCache(USERS_CACHE); }
From source file:prospring3.caching.CoursesManager2.java
@Autowired private void setCache(CacheManager cacheManager) { this.cache = cacheManager.getCache(CacheConfig.CACHE_NAME); }
From source file:io.github.howiefh.jeews.modules.oauth2.service.OAuthService.java
@Autowired public OAuthService(CacheManager cacheManager) { this.cache = cacheManager.getCache("code-cache"); }
From source file:pl.edu.icm.comac.vis.server.service.TestConfig.java
@Bean(name = "typeCache") public Cache buildTypeCache(CacheManager manager) { return manager.getCache("typeCache"); }
From source file:fi.helsinki.opintoni.cache.SpringFeedFetcherCache.java
public SpringFeedFetcherCache(String cacheName, CacheManager cacheManager) { this.cacheName = cacheName; this.cacheManager = cacheManager; this.cache = cacheManager.getCache(cacheName); }
From source file:org.hsweb.web.controller.monitor.CacheMonitorController.java
protected long getTimes(CacheManager cacheManager, TimesGetter getter) { long times = cacheManager.getCacheNames().parallelStream().map(name -> cacheManager.getCache(name)) .filter(cache -> cache instanceof MonitorCache).map(cache -> (MonitorCache) cache) .mapToLong(getter::get).reduce((i1, i2) -> i1 + i2).orElseGet(() -> 0); return times; }
From source file:org.hsweb.web.controller.monitor.CacheMonitorController.java
protected Cache getCache(String managerName, String cacheName) { CacheManager cacheManager = cacheManagerMap.get(managerName); if (cacheManager != null) { Cache cache = cacheManager.getCache(cacheName); if (cache != null) { return cache; }// ww w. ja va2s . c om } throw new NotFoundException("?"); }
From source file:org.obiba.mica.config.CacheConfiguration.java
@Bean public CacheManager springCacheManager() { log.debug("Starting Spring Cache"); net.sf.ehcache.CacheManager cacheManager = cacheManagerFactory().getObject(); EhCacheCacheManager ehCacheManager = new EhCacheCacheManager(); ehCacheManager.setCacheManager(cacheManager); String[] cacheNames = cacheManager.getCacheNames(); for (String cacheName : cacheNames) { Cache cache = cacheManager.getCache(cacheName); cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache)); }/*www. jav a 2 s.c o m*/ return ehCacheManager; }