本文整理了Java中javax.cache.Cache.getName()
方法的一些代码示例,展示了Cache.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.getName()
方法的具体详情如下:
包路径:javax.cache.Cache
类名称:Cache
方法名:getName
[英]Return the name of the cache.
[中]返回缓存的名称。
代码示例来源:origin: spring-projects/spring-framework
@Override
public final String getName() {
return this.cache.getName();
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public String getName() {
return cache.getName();
}
代码示例来源:origin: org.springframework/spring-context-support
@Override
public final String getName() {
return this.cache.getName();
}
代码示例来源:origin: ben-manes/caffeine
/** Returns the object name of the management bean. */
private static ObjectName getObjectName(Cache<?, ?> cache, MBeanType type) {
String cacheManagerName = sanitize(cache.getCacheManager().getURI().toString());
String cacheName = sanitize(cache.getName());
try {
String name = String.format("javax.cache:type=Cache%s,CacheManager=%s,Cache=%s",
type, cacheManagerName, cacheName);
return new ObjectName(name);
} catch (MalformedObjectNameException e) {
String msg = String.format("Illegal ObjectName for cacheManager=[%s], cache=[%s]",
cacheManagerName, cacheName);
throw new CacheException(msg, e);
}
}
代码示例来源:origin: resilience4j/resilience4j
private void onError(Throwable throwable) {
publishCacheEvent(() -> new CacheOnErrorEvent(cache.getName(), throwable));
}
代码示例来源:origin: resilience4j/resilience4j
private void onCacheHit(K cacheKey) {
metrics.onCacheHit();
publishCacheEvent(() -> new CacheOnHitEvent<>(cache.getName(), cacheKey));
}
代码示例来源:origin: resilience4j/resilience4j
private void onCacheMiss(K cacheKey) {
metrics.onCacheMiss();
publishCacheEvent(() -> new CacheOnMissEvent<>(cache.getName(), cacheKey));
}
代码示例来源:origin: ben-manes/caffeine
private void checkConfigurationJmx(Supplier<Cache<?, ?>> cacheSupplier) throws Exception {
Cache<?, ?> cache = cacheSupplier.get();
@SuppressWarnings("unchecked")
CompleteConfiguration<?, ?> configuration = cache.getConfiguration(CompleteConfiguration.class);
assertThat(configuration.isManagementEnabled(), is(true));
assertThat(configuration.isStatisticsEnabled(), is(true));
String name = "javax.cache:Cache=%s,CacheManager=%s,type=CacheStatistics";
ManagementFactory.getPlatformMBeanServer().getObjectInstance(
new ObjectName(String.format(name, cache.getName(), PROVIDER_NAME)));
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public <K, V> Cache<K, V> resolveCache(CacheInvocationContext<? extends Annotation> cacheInvocationContext) {
String cacheName = cacheInvocationContext.getCacheName();
Cache<K, V> mock = mock(Cache.class);
given(mock.getName()).willReturn(cacheName);
return mock;
}
代码示例来源:origin: spring-projects/spring-framework
@SuppressWarnings("unchecked")
public void addCache(String name) {
cacheNames.add(name);
Cache cache = mock(Cache.class);
given(cache.getName()).willReturn(name);
given(cacheManager.getCache(name)).willReturn(cache);
}
代码示例来源:origin: ehcache/ehcache3
@Test
public void testEhcacheCloseRemovesFromCacheManager() throws Exception {
CachingProvider provider = Caching.getCachingProvider();
javax.cache.CacheManager cacheManager =
provider.getCacheManager(this.getClass()
.getResource("/ehcache-107-types.xml")
.toURI(), getClass().getClassLoader());
MutableConfiguration<Long, String> cache1Conf = new MutableConfiguration<>();
javax.cache.Cache<Long, String> cache = cacheManager.createCache("cache1", cache1Conf);
cacheManager.unwrap(org.ehcache.CacheManager.class).removeCache(cache.getName());
try {
assertThat(cacheManager.getCache(cache.getName()), nullValue());
} finally {
cacheManager.close();
}
}
代码示例来源:origin: ehcache/ehcache3
@Test
public void testCacheManagerCloseLenientToEhcacheClosed() throws Exception {
CachingProvider provider = Caching.getCachingProvider();
javax.cache.CacheManager cacheManager =
provider.getCacheManager(this.getClass()
.getResource("/ehcache-107-types.xml")
.toURI(), getClass().getClassLoader());
MutableConfiguration<Long, String> cache1Conf = new MutableConfiguration<>();
javax.cache.Cache<Long, String> cache = cacheManager.createCache("cache1", cache1Conf);
cacheManager.unwrap(org.ehcache.CacheManager.class).removeCache(cache.getName());
cacheManager.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
CacheResolver cacheResolver = mock(CacheResolver.class);
javax.cache.Cache cache;
if (cacheName == null) {
cache = null;
}
else {
cache = mock(javax.cache.Cache.class);
given(cache.getName()).willReturn(cacheName);
}
given(cacheResolver.resolveCache(context)).willReturn(cache);
return cacheResolver;
}
代码示例来源:origin: org.apache.camel/camel-jcache
public JCacheManager(Cache<K, V> cache) {
this.configuration = null;
this.camelContext = null;
this.classLoader = null;
this.cacheName = cache.getName();
this.provider = null;
this.manager = null;
this.cache = cache;
}
代码示例来源:origin: ff4j/ff4j
/** {@inheritDoc} */
public String getCacheProviderName() {
return "jCache:" + featuresCache.getName() +
":" + featuresCache.getCacheManager().getCachingProvider().toString();
}
代码示例来源:origin: javax.cache/cache-tests
@Test
public void testCacheMXBeanManagementTurnedOff() throws Exception {
cache.getCacheManager().enableManagement(cache.getName(), false);
try {
lookupManagementAttribute(cache, CacheConfiguration, "ReadThrough");
fail();
} catch (javax.management.InstanceNotFoundException e) {
//expected. Shouldn't be there
}
}
代码示例来源:origin: javax.cache/cache-tests
@Before
public void moreSetUp() {
cache = getCacheManager().getCache(getTestCacheName(), Long.class, String.class);
cache.getCacheManager().enableStatistics(cache.getName(), true);
statisticsUpdateTimeoutMillis = Integer.valueOf(System.getProperty(STATISTICS_UPDATE_TIMEOUT_PROPERTY,
DEFAULT_STATISTICS_UPDATE_TIMEOUT_SECONDS));
}
代码示例来源:origin: javax.cache/cache-tests
@Test
public void createCache_NameOK() {
String name = "c1";
getCacheManager().createCache(name, new MutableConfiguration());
Cache cache = getCacheManager().getCache(name);
assertEquals(name, cache.getName());
}
代码示例来源:origin: javax.cache/cache-tests
@Test
public void getOrCreateCache_StatusOK() {
String name = "c1";
getCacheManager().createCache(name, new MutableConfiguration());
Cache cache = getCacheManager().getCache(name);
assertNotNull(cache);
assertEquals(name, cache.getName());
}
代码示例来源:origin: javax.cache/cache-tests
@Test
public void cachingProviderGetCache() {
String name = "c1";
Caching.getCachingProvider().getCacheManager().createCache(name, new MutableConfiguration().setTypes(Long.class, String.class));
Cache cache = Caching.getCache(name, Long.class, String.class);
assertEquals(name, cache.getName());
Caching.getCachingProvider().getCacheManager().destroyCache(name);
}
内容来源于网络,如有侵权,请联系作者删除!