本文整理了Java中javax.cache.Caching.getCachingProviders()
方法的一些代码示例,展示了Caching.getCachingProviders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caching.getCachingProviders()
方法的具体详情如下:
包路径:javax.cache.Caching
类名称:Caching
方法名:getCachingProviders
[英]Obtains the CachingProviders that are available via the #getDefaultClassLoader().
If a javax.cache.spi.cachingprovider
system property is defined, only that CachingProvider specified by that property is returned. Otherwise all CachingProviders that are available via a ServiceLoader for CachingProviders using the default ClassLoader (including those previously requested via #getCachingProvider(String)) are returned.
[中]获取通过#getDefaultClassLoader()可用的CachingProviders。
如果定义了javax.cache.spi.cachingprovider
系统属性,则仅返回该属性指定的CachingProvider。否则,将返回通过ServiceLoader为使用默认类加载器的CachingProviders提供的所有CachingProvider(包括之前通过#getCachingProvider(String))请求的那些)。
代码示例来源:origin: net.unit8.moshas/moshas
public JCacheTemplateCache() {
Iterator<CachingProvider> cachingProviders = Caching.getCachingProviders().iterator();
if (cachingProviders.hasNext()) {
CachingProvider cachingProvider = cachingProviders.next();
CacheManager cacheManager = cachingProvider.getCacheManager();
Configuration<String, Template> config = new MutableConfiguration<String, Template>()
.setTypes(String.class, Template.class)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 5)));
Cache<String, Template> cache = cacheManager.getCache("TemplateCache", String.class, Template.class);
if (cache == null) {
this.cache = cacheManager.createCache("TemplateCache", config);
} else {
this.cache = cache;
}
} else {
this.cache = null; // to keep compatibility with 0.1.0, but ugly
}
}
代码示例来源:origin: javax.cache/cache-tests
@Test
public void testJCacheCachingProviders() {
Iterable<CachingProvider> iterable = Caching.getCachingProviders();
int i = 0;
for (CachingProvider provider : iterable) {
System.out.println("provider=" + provider.getClass().getCanonicalName());
i++;
}
assertEquals(1, i);
i = 0;
iterable = Caching.getCachingProviders(Caching.getDefaultClassLoader());
for (CachingProvider provider : iterable) {
System.out.println("provider=" + provider.getClass().getCanonicalName());
i++;
}
assertEquals(1, i);
// test case added for code coverage
i = 0;
iterable = Caching.getCachingProviders(null);
for (CachingProvider provider : iterable) {
System.out.println("provider=" + provider.getClass().getCanonicalName());
i++;
}
assertEquals(1, i);
}
代码示例来源:origin: gitblit/fathom
for (CachingProvider provider : Caching.getCachingProviders()) {
providers.add(provider);
String providerClassName = provider.getClass().getName();
内容来源于网络,如有侵权,请联系作者删除!