当前位置: 首页>>代码示例>>Java>>正文


Java Caching.getCachingProvider方法代码示例

本文整理汇总了Java中javax.cache.Caching.getCachingProvider方法的典型用法代码示例。如果您正苦于以下问题:Java Caching.getCachingProvider方法的具体用法?Java Caching.getCachingProvider怎么用?Java Caching.getCachingProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.cache.Caching的用法示例。


在下文中一共展示了Caching.getCachingProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCacheManagerWithNonNullProperties

import javax.cache.Caching; //导入方法依赖的package包/类
@Test // org.jsr107.tck.CacheManagerTest.getCacheManager_nonNullProperties
public void getCacheManagerWithNonNullProperties()
{
    // see https://github.com/jsr107/jsr107tck/issues/102

    // make sure existing cache managers are closed and the non empty properties get picked up
    try
    {
        Caching.getCachingProvider().close();
    }
    catch (CacheException ignore)
    {
        // ignore exception which may happen if the provider is not active
    }

    CachingProvider provider = Caching.getCachingProvider();

    Properties properties = new Properties();
    properties.put("dummy.com", "goofy");

    provider.getCacheManager(provider.getDefaultURI(), provider.getDefaultClassLoader(), properties);
    CacheManager manager = provider.getCacheManager();

    assertEquals(properties, manager.getProperties());
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:26,代码来源:GuavaCacheManagerTest.java

示例2: init

import javax.cache.Caching; //导入方法依赖的package包/类
@Before
public void init()
{
    cachingProvider = Caching.getCachingProvider(GuavaCachingProvider.class.getName());
    assertNotNull(cachingProvider);

    cacheManager = cachingProvider.getCacheManager();
    assertNotNull(cacheManager);

    configuration.setStoreByValue(false);
    configuration.setTypes(String.class, Integer.class);

    cache = cacheManager.createCache("cache", configuration);
    assertNotNull(cache);
    assertEquals("cache", cache.getName());
    assertEquals(cacheManager, cache.getCacheManager());
    assertEquals(configuration, cache.getConfiguration(MutableConfiguration.class));
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:19,代码来源:GuavaCacheTest.java

示例3: call

import javax.cache.Caching; //导入方法依赖的package包/类
@Override
public Collection<ValueObject> call()
    throws Exception
{
    CachingProvider cachingProvider = Caching.getCachingProvider(GuavaCachingProvider.class.getName());

    CacheManager cacheManager = cachingProvider.getCacheManager();

    Cache<KeyObject, ValueObject> cache =
        cacheManager.getCache("workerCache", KeyObject.class, ValueObject.class);

    Set<ValueObject> values = new HashSet<>();

    for (long id = 0; id < TEST_CACHE_SIZE; id++)
    {
        values.add(cache.get(new KeyObject(id)));
    }

    return values;
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:21,代码来源:GuavaCacheConcurrentTest.java

示例4: ehCacheManager

import javax.cache.Caching; //导入方法依赖的package包/类
@Bean
@Primary
public CacheManager ehCacheManager(JiraSyncConfig jiraSyncConfig) throws Exception {
	CachingProvider cachingProvider = Caching.getCachingProvider();
	EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) cachingProvider;
	CacheConfig cacheConfig = jiraSyncConfig.getCache();
	CacheManager cacheManager = getCacheManager(ehcacheCachingProvider, cacheConfig);
	boolean persistentCache = cacheConfig.isPersistent();
	createCache(cacheManager, CACHE_NAME_PROJECTS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_PRIORITIES, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_RESOLUTIONS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_VERSIONS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_FIELDS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_REMOTE_LINKS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_USERS, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_FIELD_ALLOWED_VALUES, ONE_HOUR, persistentCache);
	createCache(cacheManager, CACHE_NAME_MYSELF, ONE_HOUR, false);
	createCache(cacheManager, CACHE_NAME_SERVER_INFO, THIRTY_SECONDS, false);
	return cacheManager;
}
 
开发者ID:cronn-de,项目名称:jira-sync,代码行数:21,代码来源:JiraServiceCacheConfig.java

示例5: createManager

import javax.cache.Caching; //导入方法依赖的package包/类
public CacheManager createManager(Map<String, Configuration<?, ?>> configs, ShutdownManager shutdownManager) {

        CachingProvider provider;
        try {
            // TODO: an explicit config property to pick explicit provider out of available choices... though probably
            // pointless in most cases (do we realistically expect multiple providers on classpath?)
            provider = Caching.getCachingProvider();
        } catch (CacheException e) {
            throw new RuntimeException("'bootique-jcache' doesn't bundle any JCache providers. " +
                    "You must place a JCache 1.0 provider on classpath explicitly.", e);
        }

        shutdownManager.addShutdownHook(provider);

        CacheManager manager = getConfigUri().map(u -> provider.getCacheManager(u, null)).orElse(provider.getCacheManager());
        shutdownManager.addShutdownHook(manager);

        // now load contributed configs
        configs.forEach(manager::createCache);

        return manager;
    }
 
开发者ID:bootique,项目名称:bootique-jcache,代码行数:23,代码来源:JCacheFactory.java

示例6: testReadThroughGetAll

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testReadThroughGetAll() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(true);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        Map<String, String> result = cache.getAll(new HashSet<>(Arrays.asList(key)));
        assertEquals("LOADED_" + key, result.get(key));
        assertEquals("LOADED_" + key, cache.get(key));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:21,代码来源:CacheLoaderTest.java

示例7: shouldWriteThroughUsingInvoke_remove_nonExistingEntry

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void shouldWriteThroughUsingInvoke_remove_nonExistingEntry() {
    RecordingCacheWriter<Integer, String> cacheWriter = new RecordingCacheWriter<>();
    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<Integer, String> config
                = new MutableConfiguration<Integer, String>()
                .setTypes(Integer.class, String.class)
                .setCacheWriterFactory(new FactoryBuilder.SingletonFactory<>(cacheWriter))
                .setWriteThrough(true);

        Cache<Integer, String> cache = cacheManager.createCache("simpleCache", config);
        assertEquals(0, cacheWriter.getWriteCount());
        assertEquals(0, cacheWriter.getDeleteCount());

        cache.invoke(1, new RemoveEntryProcessor<Integer, String, Object>());
        assertEquals(0, cacheWriter.getWriteCount());
        assertEquals(1, cacheWriter.getDeleteCount());
        assertFalse(cacheWriter.hasWritten(1));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:23,代码来源:CacheWriterTest.java

示例8: testReadThrough

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testReadThrough() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(true);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        String result = cache.get(key);
        assertEquals("LOADED_" + key, result);
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:20,代码来源:CacheLoaderTest.java

示例9: setup

import javax.cache.Caching; //导入方法依赖的package包/类
@Before
public void setup() throws SQLException {
    Platform platform = new HSQL();
    CommonDataSource dataSource = DatabaseType.getDataSource(platform);
    EntityModel model = io.requery.test.model.Models.DEFAULT;

    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();
    Configuration configuration = new ConfigurationBuilder(dataSource, model)
        .useDefaultLogging()
        .setWriteExecutor(Executors.newSingleThreadExecutor())
        .setEntityCache(new EntityCacheBuilder(model)
            .useReferenceCache(true)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build())
        .build();

    SchemaModifier tables = new SchemaModifier(configuration);
    tables.createTables(TableCreationMode.DROP_CREATE);
    data = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
 
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:ReactorTest.java

示例10: testSerializeGetPut

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testSerializeGetPut() {
    CachingProvider provider = Caching.getCachingProvider();
    CacheManager cacheManager = provider.getCacheManager();

    EntityCache cache = new EntityCacheBuilder(Models.DEFAULT)
            .useReferenceCache(false)
            .useSerializableCache(true)
            .useCacheManager(cacheManager)
            .build();

    Person p = new Person();
    p.setName("Alice");
    p.setUUID(UUID.randomUUID());
    p.setAddress(new Address());
    p.getAddress().setType(AddressType.HOME);

    int id = 100;
    cache.put(Person.class, id, p);

    Person d = cache.get(Person.class, id);
    Assert.assertNotNull(d);
    Assert.assertNotSame(p, d);
    Assert.assertEquals(p.getName(), d.getName());
    Assert.assertEquals(p.getUUID(), d.getUUID());
}
 
开发者ID:requery,项目名称:requery,代码行数:27,代码来源:EntityCacheTest.java

示例11: testNoReadThrough

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testNoReadThrough() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, String> config
                = new MutableConfiguration<String, String>()
                .setTypes(String.class, String.class)
                .setCacheLoaderFactory(new FactoryBuilder.ClassFactory(MockCacheLoader.class))
                .setReadThrough(false);

        Cache<String, String> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        String result = cache.get(key);
        assertNull(result);
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:20,代码来源:CacheLoaderTest.java

示例12: testParametersInURI

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testParametersInURI() throws URISyntaxException {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(new URI(cachingProvider.getDefaultURI() + "?secret=testsecret"), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, Integer> config
                = new MutableConfiguration<String, Integer>()
                .setTypes(String.class, Integer.class)
                .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
                .setStatisticsEnabled(true);

        Cache<String, Integer> cache = cacheManager.createCache("simpleCache", config);
        BlazingCacheManager manager = cacheManager.unwrap(BlazingCacheManager.class);
        assertEquals("testsecret", manager.getProperties().get("blazingcache.secret"));

        String key = "key";
        Integer value1 = 1;
        cache.put("key", value1);
        Integer value2 = cache.get(key);
        assertEquals(value1, value2);
        cache.remove(key);
        assertNull(cache.get(key));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:26,代码来源:ParametersInURITest.java

示例13: testJSRExample1

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testJSRExample1() {

    CachingProvider cachingProvider = Caching.getCachingProvider();
    Properties p = new Properties();
    try (CacheManager cacheManager = cachingProvider.getCacheManager(cachingProvider.getDefaultURI(), cachingProvider.getDefaultClassLoader(), p)) {
        MutableConfiguration<String, Integer> config
                = new MutableConfiguration<String, Integer>()
                .setTypes(String.class, Integer.class)
                .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(ONE_HOUR))
                .setStatisticsEnabled(true);

        Cache<String, Integer> cache = cacheManager.createCache("simpleCache", config);

        String key = "key";
        Integer value1 = 1;
        cache.put("key", value1);
        Integer value2 = cache.get(key);
        assertEquals(value1, value2);
        cache.remove(key);
        assertNull(cache.get(key));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:24,代码来源:JSRExamplesTest.java

示例14: basicConfiguration

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void basicConfiguration() throws Exception {
  // tag::basicConfigurationExample[]
  CachingProvider provider = Caching.getCachingProvider();  // <1>
  CacheManager cacheManager = provider.getCacheManager();   // <2>
  MutableConfiguration<Long, String> configuration =
      new MutableConfiguration<Long, String>()  // <3>
          .setTypes(Long.class, String.class)   // <4>
          .setStoreByValue(false)   // <5>
          .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));  // <6>
  Cache<Long, String> cache = cacheManager.createCache("jCache", configuration); // <7>
  cache.put(1L, "one"); // <8>
  String value = cache.get(1L); // <9>
  // end::basicConfigurationExample[]
  assertThat(value, is("one"));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:17,代码来源:EhCache107ConfigurationIntegrationDocTest.java

示例15: testClassLoadCount

import javax.cache.Caching; //导入方法依赖的package包/类
@Test
public void testClassLoadCount() throws Exception {
  EhcacheCachingProvider cachingProvider = (EhcacheCachingProvider)Caching.getCachingProvider();
  URI uri = cachingProvider.getDefaultURI();
  ClassLoader classLoader = cachingProvider.getDefaultClassLoader();
  CountingConfigSupplier configSupplier = new CountingConfigSupplier(uri, classLoader);

  assertEquals(configSupplier.configCount, 0);

  cachingProvider.getCacheManager(configSupplier, new Properties());

  assertEquals(configSupplier.configCount, 1);

  cachingProvider.getCacheManager(configSupplier, new Properties());

  assertEquals(configSupplier.configCount, 1);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:18,代码来源:EhCachingProviderTest.java


注:本文中的javax.cache.Caching.getCachingProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。