@Override public void release() { try { getCache().getCacheManager().removeCache( getCache().getName() ); } catch (IllegalStateException e) { //When Spring and Hibernate are both involved this will happen in normal shutdown operation. //Do not throw an exception, simply log this one. LOG.debug( "This can happen if multiple frameworks both try to shutdown ehcache", e ); } catch (net.sf.ehcache.CacheException e) { if ( e instanceof NonStopCacheException ) { HibernateNonstopCacheExceptionHandler.getInstance() .handleNonstopCacheException( (NonStopCacheException) e ); } else { throw new CacheException( e ); } } } }
/** * {@inheritDoc} */ public CacheManager getCacheManager() { return underlyingCache.getCacheManager(); }
public QueryManagerImpl(Collection<Ehcache> ehcaches) { CacheManager cm; for (Ehcache ehcache : ehcaches) { cm = ehcache.getCacheManager(); if (cacheManagerEhcacheMap.containsKey(cm)) { cacheManagerEhcacheMap.get(cm).add(ehcache); } else { List<Ehcache> ehcacheList = new ArrayList<Ehcache>(); ehcacheList.add(ehcache); cacheManagerEhcacheMap.put(cm, ehcacheList); } } }
private CacheEventListener createCacheEventReplicator(Ehcache cache) { // the race is not a problem here, since the event replicator will only be created once in the clustered instance factory // this replicator map is simply a locally cached version, several puts for the same cache will result in the same value being put CacheEventListener replicator = replicators.get(cache); if (null == replicator) { replicator = cache.getCacheManager().createTerracottaEventReplicator(cache); replicators.put(cache, replicator); } return replicator; }
private static String getCacheManagerName(Ehcache cache) { final String cacheMgrName; if (cache.getCacheManager().isNamed()) { cacheMgrName = cache.getCacheManager().getName(); } else { cacheMgrName = TerracottaClusteredInstanceFactory.DEFAULT_CACHE_MANAGER_NAME; } return cacheMgrName; }
private JobDetail makeOverseerJob() throws SchedulerException { JobDataMap jdm = new JobDataMap(); jdm.put(PROP_CACHE_MGR_NAME, underlyingCache.getCacheManager().getName()); jdm.put(PROP_CACHE_NAME, underlyingCache.getName()); jdm.put(PROP_CONFIG_OBJECT, config); JobDetail seed = JobBuilder.newJob(OverseerJob.class).storeDurably() .withIdentity(OVERSEER_JOB_NAME, groupName) .usingJobData(jdm).build(); return seed; }
/** * Package protected List of cache peers * * @param cache * @return a list of {@link CachePeer} peers for the given cache, excluding the local peer. */ static List<CachePeer> listRemoteCachePeers(Ehcache cache) { CacheManagerPeerProvider provider = cache.getCacheManager().getCacheManagerPeerProvider("RMI"); return provider.listRemoteCachePeers(cache); }
/** * Divine the name. * * @param cache the cache * @return the string */ public static String divineName(Ehcache cache) { return cache.getCacheManager().getName() + "." + cache.getName(); } }
/** * {@inheritDoc} */ @Override public boolean isLocalHeapCountBased() { return cache.getCacheConfiguration() .getMaxBytesLocalHeap() <= 0 && !(cache.getCacheManager() != null && cache.getCacheManager() .getConfiguration() .isMaxBytesLocalHeapSet()); }
/** * Package protected List of cache peers * * @param cache */ protected List listRemoteCachePeers(Ehcache cache) { CacheManagerPeerProvider provider = cache.getCacheManager().getCacheManagerPeerProvider("RMI"); if (provider == null) { return null; } else { return provider.listRemoteCachePeers(cache); } }
void setUpWanConfig() { if (!cache.getCacheManager().getConfiguration().getTerracottaConfiguration().isWanEnabledTSA()) { toolkitInstanceFactory.markCacheWanDisabled(cache.getCacheManager().getName(), cache.getName()); } }
public void setCache(Ehcache cache) { BlockingCache ref; if (!(cache instanceof BlockingCache)) { ref = new BlockingCache(cache); cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache)); } else { ref = (BlockingCache)cache; } this.cache = ref; }
@Override public ToolkitNotifier<CacheEventNotificationMsg> getOrCreateCacheEventNotifier(Ehcache cache) { return getOrCreateCacheEventNotifier(cache.getCacheManager().getName(), cache.getName()); }
@Override public synchronized AsyncCoordinator getOrCreateAsyncCoordinator(final Ehcache cache, final AsyncConfig config) { return getOrCreateAsyncCoordinator(cache.getCacheManager().getName(), cache.getName(), config); }
@Override public ToolkitNotifier<CacheConfigChangeNotificationMsg> getOrCreateConfigChangeNotifier(Ehcache cache) { return getOrCreateConfigChangeNotifier(cache.getCacheManager().getName(), cache.getName()); }
/** * {@inheritDoc} */ public boolean setTransactionTimeout(int timeout) throws XAException { if (timeout < 0) { throw new EhcacheXAException("timeout must be >= 0, was: " + timeout, XAException.XAER_INVAL); } if (timeout == 0) { this.transactionTimeout = cache.getCacheManager().getTransactionController().getDefaultTransactionTimeout(); } else { this.transactionTimeout = timeout; } return true; }
@Override public ToolkitNotifier<CacheDisposalNotification> getOrCreateCacheDisposalNotifier(Ehcache cache) { return toolkit.getNotifier(EhcacheEntitiesNaming.getToolkitCacheNameFor(cache.getCacheManager().getName(), cache.getName()) + DELIMITER + DISPOSAL_NOTIFIER_SUFFIX, CacheDisposalNotification.class); }
/** * Constructs using a backing CacheConfiguration * * @param cache */ public CacheConfiguration(net.sf.ehcache.Ehcache cache) { cacheConfiguration = cache.getCacheConfiguration(); objectName = createObjectName(cache.getCacheManager().toString(), cache.getName()); }
private Store(Ehcache ehcache, Object storeBean) throws NotCompliantMBeanException { this.objectName = createObjectName(ehcache.getCacheManager().getName(), ehcache.getName()); if (storeBean instanceof DynamicMBean) { this.storeBean = (DynamicMBean) storeBean; } else { this.storeBean = new StandardMBean(storeBean, null); } }
/** * Constructs an object from an ehcache statistics object * * @param ehcache the backing ehcache */ public CacheStatistics(Ehcache ehcache) { this.ehcache = ehcache; this.statistics = ehcache.getStatistics(); objectName = createObjectName(ehcache.getCacheManager().getName(), ehcache.getName()); }