javax.cache.Caching.getCachingProvider()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中javax.cache.Caching.getCachingProvider()方法的一些代码示例,展示了Caching.getCachingProvider()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caching.getCachingProvider()方法的具体详情如下:
包路径:javax.cache.Caching
类名称:Caching
方法名:getCachingProvider

Caching.getCachingProvider介绍

[英]Obtains the default CachingProvider available via the #getDefaultClassLoader().
[中]通过#getDefaultClassLoader()获取可用的默认CachingProvider。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void afterPropertiesSet() {
  this.cacheManager = Caching.getCachingProvider().getCacheManager(
      this.cacheManagerUri, this.beanClassLoader, this.cacheManagerProperties);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected CachingProvider getCachingProvider() {
  return Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected CachingProvider getCachingProvider() {
  return Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
}

代码示例来源:origin: spring-projects/spring-framework

protected CachingProvider getCachingProvider() {
  return Caching.getCachingProvider("org.ehcache.jcache.JCacheCachingProvider");
}

代码示例来源:origin: spring-projects/spring-framework

protected CachingProvider getCachingProvider() {
  return Caching.getCachingProvider("org.ehcache.jcache.JCacheCachingProvider");
}

代码示例来源:origin: hibernate/hibernate-orm

@SuppressWarnings("WeakerAccess")
protected CachingProvider getCachingProvider(final Map properties){
  final CachingProvider cachingProvider;
  final String provider = getProp( properties, ConfigSettings.PROVIDER );
  if ( provider != null ) {
    cachingProvider = Caching.getCachingProvider( provider );
  }
  else {
    cachingProvider = Caching.getCachingProvider();
  }
  return cachingProvider;
}

代码示例来源:origin: hibernate/hibernate-orm

/**
   * @apiNote Access to the standard CacheManager used by `hibernate-jcache` unless
   * configured differently.
   */
  public static CacheManager locateStandardCacheManager() {
    // unless configured differently, this is how JCacheRegionFactory
    //		will locate the CacheManager to use
    return Caching.getCachingProvider().getCacheManager();
  }
}

代码示例来源:origin: org.springframework/spring-context-support

@Override
public void afterPropertiesSet() {
  this.cacheManager = Caching.getCachingProvider().getCacheManager(
      this.cacheManagerUri, this.beanClassLoader, this.cacheManagerProperties);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void afterPropertiesSet() {
  if (getCacheManager() == null) {
    setCacheManager(Caching.getCachingProvider().getCacheManager());
  }
  super.afterPropertiesSet();
}

代码示例来源:origin: ben-manes/caffeine

@Test
public void getCache() {
 Cache<Integer, Integer> cache = Caching.getCachingProvider()
   .getCacheManager().getCache("test-cache");
 assertThat(cache, is(not(nullValue())));
 @SuppressWarnings("unchecked")
 CaffeineConfiguration<Integer, Integer> config =
   cache.getConfiguration(CaffeineConfiguration.class);
 checkTestCache(config);
}

代码示例来源:origin: org.springframework/spring-context-support

@Override
public void afterPropertiesSet() {
  if (getCacheManager() == null) {
    setCacheManager(Caching.getCachingProvider().getCacheManager());
  }
  super.afterPropertiesSet();
}

代码示例来源:origin: ben-manes/caffeine

@BeforeClass(alwaysRun = true)
public void beforeClass() {
 CachingProvider provider = Caching.getCachingProvider(CaffeineCachingProvider.class.getName());
 cacheManager = provider.getCacheManager(
   provider.getDefaultURI(), provider.getDefaultClassLoader());
}

代码示例来源:origin: ben-manes/caffeine

@BeforeClass
public void beforeClass() {
 CachingProvider provider = Caching.getCachingProvider(PROVIDER_NAME);
 cacheManager = provider.getCacheManager(
   provider.getDefaultURI(), provider.getDefaultClassLoader());
}

代码示例来源:origin: ehcache/ehcache3

@Before
public void setUp() throws Exception {
 cachingProvider = Caching.getCachingProvider();
 cacheManager = cachingProvider.getCacheManager(getClass().getResource("/ehcache-107-integration.xml")
   .toURI(), cachingProvider.getDefaultClassLoader());
}

代码示例来源:origin: ben-manes/caffeine

JCacheProfiler() {
 random = new Random();
 count = new LongAdder();
 CachingProvider provider = Caching.getCachingProvider(CaffeineCachingProvider.class.getName());
 CacheManager cacheManager = provider.getCacheManager(
   provider.getDefaultURI(), provider.getDefaultClassLoader());
 cache = cacheManager.createCache("profiler", new MutableConfiguration<>());
 executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
   .setPriority(Thread.MIN_PRIORITY).setDaemon(true).build());
}

代码示例来源:origin: ben-manes/caffeine

/** Resolves the annotations to the provider as multiple are on the IDE's classpath. */
 void configureCachingProvider() {
  CachingProvider provider = Caching.getCachingProvider(
    CaffeineCachingProvider.class.getName());
  CacheManager cacheManager = provider.getCacheManager(
    provider.getDefaultURI(), provider.getDefaultClassLoader());
  bind(CacheResolverFactory.class).toInstance(new DefaultCacheResolverFactory(cacheManager));
  bind(CacheManager.class).toInstance(cacheManager);
 }
}

代码示例来源:origin: ben-manes/caffeine

@Test
 public void sanity() {
  CachingProvider cachingProvider = Caching.getCachingProvider(
    "com.github.benmanes.caffeine.jcache.spi.CaffeineCachingProvider",
    getClass().getClassLoader());
  Cache<String, Integer> cache = cachingProvider.getCacheManager()
    .getCache("test-cache-2", String.class, Integer.class);
  assertNull(cache.get("a"));
 }
}

代码示例来源:origin: ben-manes/caffeine

@BeforeClass
public void beforeClass() {
 final CachingProvider provider = Caching.getCachingProvider(PROVIDER_NAME);
 cacheManager = provider.getCacheManager();
 cacheManager.destroyCache("cache-not-in-config-file");
 cacheConfig = new MutableConfiguration<>();
 cacheConfig.setTypes(String.class, String.class);
 cacheConfig.setStatisticsEnabled(true);
}

代码示例来源:origin: apache/incubator-dubbo

public JCache(URL url) {
  String method = url.getParameter(Constants.METHOD_KEY, "");
  String key = url.getAddress() + "." + url.getServiceKey() + "." + method;
  // jcache parameter is the full-qualified class name of SPI implementation
  String type = url.getParameter("jcache");
  CachingProvider provider = StringUtils.isEmpty(type) ? Caching.getCachingProvider() : Caching.getCachingProvider(type);
  CacheManager cacheManager = provider.getCacheManager();
  Cache<Object, Object> cache = cacheManager.getCache(key);
  if (cache == null) {
    try {
      //configure the cache
      MutableConfiguration config =
          new MutableConfiguration<Object, Object>()
              .setTypes(Object.class, Object.class)
              .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, url.getMethodParameter(method, "cache.write.expire", 60 * 1000))))
              .setStoreByValue(false)
              .setManagementEnabled(true)
              .setStatisticsEnabled(true);
      cache = cacheManager.createCache(key, config);
    } catch (CacheException e) {
      // concurrent cache initialization
      cache = cacheManager.getCache(key);
    }
  }
  this.store = cache;
}

代码示例来源:origin: apache/incubator-dubbo

public JCache(URL url) {
  String method = url.getParameter(Constants.METHOD_KEY, "");
  String key = url.getAddress() + "." + url.getServiceKey() + "." + method;
  // jcache parameter is the full-qualified class name of SPI implementation
  String type = url.getParameter("jcache");
  CachingProvider provider = StringUtils.isEmpty(type) ? Caching.getCachingProvider() : Caching.getCachingProvider(type);
  CacheManager cacheManager = provider.getCacheManager();
  Cache<Object, Object> cache = cacheManager.getCache(key);
  if (cache == null) {
    try {
      //configure the cache
      MutableConfiguration config =
          new MutableConfiguration<Object, Object>()
              .setTypes(Object.class, Object.class)
              .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, url.getMethodParameter(method, "cache.write.expire", 60 * 1000))))
              .setStoreByValue(false)
              .setManagementEnabled(true)
              .setStatisticsEnabled(true);
      cache = cacheManager.createCache(key, config);
    } catch (CacheException e) {
      // concurrent cache initialization
      cache = cacheManager.getCache(key);
    }
  }
  this.store = cache;
}

相关文章