當前位置: 首頁>>代碼示例>>Java>>正文


Java CacheManager.close方法代碼示例

本文整理匯總了Java中javax.cache.CacheManager.close方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheManager.close方法的具體用法?Java CacheManager.close怎麽用?Java CacheManager.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.cache.CacheManager的用法示例。


在下文中一共展示了CacheManager.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: close

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Override
public void close()
{
    Iterator<Map.Entry<Pair<URI, ClassLoader>, CacheManager>> i = cacheManagers.entrySet().iterator();

    while (i.hasNext())
    {
        Map.Entry<Pair<URI, ClassLoader>, CacheManager> entry = i.next();

        CacheManager cm = entry.getValue();

        if (cm != null && !cm.isClosed())
        {
            cm.close();
        }

        i.remove();
    }
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:20,代碼來源:GuavaCachingProvider.java

示例2: testCacheManagerWithCustomClassLoader

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testCacheManagerWithCustomClassLoader()
    throws Exception
{
    CacheManager cacheManager1 = cachingProvider.getCacheManager();
    CacheManager cacheManager2 = cachingProvider.getCacheManager(null, ClassLoader.getSystemClassLoader());

    assertNotNull(cacheManager1);
    assertNotNull(cacheManager2);

    assertNotEquals(cacheManager1, cacheManager2);

    cacheManager1.close();
    cacheManager2.close();

    assertTrue(cacheManager1.isClosed());
    assertTrue(cacheManager2.isClosed());
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:19,代碼來源:GuavaCacheManagerTest.java

示例3: testCacheManagerWithCustomProperties

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testCacheManagerWithCustomProperties()
    throws Exception
{
    Properties properties = new Properties();

    properties.setProperty("concurrencyLevel", "1");
    properties.setProperty("initialCapacity", "16");

    CacheManager cacheManager1 = cachingProvider.getCacheManager();
    CacheManager cacheManager2 = cachingProvider.getCacheManager(null, null, properties);

    assertNotNull(cacheManager1);
    assertNotNull(cacheManager2);

    // properties do not form part of the identity of the CacheManager
    assertEquals(cacheManager1, cacheManager2);

    cacheManager1.close();
    cacheManager2.close();

    assertTrue(cacheManager1.isClosed());
    assertTrue(cacheManager2.isClosed());
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:25,代碼來源:GuavaCacheManagerTest.java

示例4: testCacheManagerWithCustomClassLoaderAndProperties

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testCacheManagerWithCustomClassLoaderAndProperties()
    throws Exception
{
    Properties properties = new Properties();

    properties.setProperty("concurrencyLevel", "1");
    properties.setProperty("initialCapacity", "16");

    CacheManager cacheManager1 = cachingProvider.getCacheManager();
    CacheManager cacheManager2 =
        cachingProvider.getCacheManager(null, ClassLoader.getSystemClassLoader(), properties);

    assertNotNull(cacheManager1);
    assertNotNull(cacheManager2);

    assertNotEquals(cacheManager1, cacheManager2);

    cacheManager1.close();
    cacheManager2.close();

    assertTrue(cacheManager1.isClosed());
    assertTrue(cacheManager2.isClosed());
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:25,代碼來源:GuavaCacheManagerTest.java

示例5: close

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Override
	public void close(ClassLoader classLoader)
	{
//		System.out.println("CacheManager.close() cl=" + classLoader);
		synchronized (cacheManagersLock)
		{
			for( Iterator<CacheManager> it = cacheManagers.iterator(); it.hasNext(); )
			{
				CacheManager cacheManager = it.next();
				if (cacheManager.getClassLoader().equals(classLoader))
				{
					cacheManager.close();
					// Hint: It may have happened, that cacheManager.close() already removed itrslef cacheManagers.
					// In that case the next line is a NOP. It is important though, that the underlying Set is a Concurrent Set.
					it.remove();
				}
			}
		}
	}
 
開發者ID:trivago,項目名稱:triava,代碼行數:20,代碼來源:TCacheProvider.java

示例6: close

import javax.cache.CacheManager; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public synchronized void close(URI uri, ClassLoader classLoader) {
    URI managerURI = uri == null ? getDefaultURI() : uri;
    ClassLoader managerClassLoader = classLoader == null ? getDefaultClassLoader() : classLoader;

    HashMap<URI, BlazingCacheManager> cacheManagersByURI = cacheManagersByClassLoader.get(managerClassLoader);
    if (cacheManagersByURI != null) {
        CacheManager cacheManager = cacheManagersByURI.remove(managerURI);

        if (cacheManager != null) {
            cacheManager.close();
        }

        if (cacheManagersByURI.size() == 0) {
            cacheManagersByClassLoader.remove(managerClassLoader);
        }
    }
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:22,代碼來源:BlazingCacheProvider.java

示例7: testReuseCacheManagerGetCache

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testReuseCacheManagerGetCache() throws Exception {
    CachingProvider provider = Caching.getCachingProvider();
    URI uri = provider.getDefaultURI();

    CacheManager cacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
    assertFalse(cacheManager.isClosed());
    cacheManager.close();
    assertTrue(cacheManager.isClosed());

    try {
        cacheManager.getCache("nonExistent", null, null);
        fail();
    } catch (IllegalStateException e) {
        //expected
    }

    CacheManager otherCacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
    assertFalse(otherCacheManager.isClosed());

    assertNotSame(cacheManager, otherCacheManager);
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:23,代碼來源:TCKCacheManagerTest.java

示例8: close

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Override
public void close(ClassLoader classLoader) {
    Map<URI, CacheManager> uri2manager = managers.remove(classLoader);
    if (uri2manager != null) {
        for (CacheManager manager : uri2manager.values()) {
            manager.close();
        }
    }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:10,代碼來源:JCachingProvider.java

示例9: testCacheManager

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testCacheManager()
    throws Exception
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    assertEquals(cacheManager, cachingProvider.getCacheManager());

    cacheManager.close();

    assertTrue(cacheManager.isClosed());
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:13,代碼來源:GuavaCacheManagerTest.java

示例10: testCacheManagerWithDefaultProperties

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void testCacheManagerWithDefaultProperties()
    throws Exception
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    assertNotNull(cacheManager);

    MutableConfiguration<Long, String> configuration =
        new MutableConfiguration<Long, String>().setStoreByValue(false);

    Cache<Long, String> cache = cacheManager.createCache("maximumSizeCacheTest", configuration);

    long maximumSize = Long.valueOf(cacheManager.getProperties().getProperty("maximumSize"));

    assertNotEquals(0, maximumSize);

    for (long l = 1; l <= (maximumSize * 10); l++)
    {
        cache.put(l, "VALUE-" + l);

        if ((l % maximumSize) == 0)
        {
            assertTrue(cache.unwrap(GuavaCache.class).size() <= maximumSize);
        }
    }

    assertTrue(cache.unwrap(GuavaCache.class).size() <= maximumSize);

    cacheManager.close();
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:32,代碼來源:GuavaCacheManagerTest.java

示例11: testClosedCacheManager

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test(expected = IllegalStateException.class)
public void testClosedCacheManager()
    throws Exception
{
    CacheManager cacheManager = cachingProvider.getCacheManager();

    assertNotNull(cacheManager);

    cacheManager.close();

    cacheManager.getCacheNames();
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:13,代碼來源:GuavaCacheManagerTest.java

示例12: testReuseCacheManager

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test // org.jsr107.tck.CacheManagerTest.testReuseCacheManager
public void testReuseCacheManager()
    throws Exception
{
    CachingProvider provider = Caching.getCachingProvider();
    URI uri = provider.getDefaultURI();

    CacheManager cacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
    assertFalse(cacheManager.isClosed());
    cacheManager.close();
    assertTrue(cacheManager.isClosed());

    try
    {
        cacheManager.createCache("Dog", null);
        fail();
    }
    catch (IllegalStateException e)
    {
        //expected
    }

    CacheManager otherCacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
    assertFalse(otherCacheManager.isClosed());

    assertNotSame(cacheManager, otherCacheManager);
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:28,代碼來源:GuavaCacheManagerTest.java

示例13: main

import javax.cache.CacheManager; //導入方法依賴的package包/類
public static void main(String[] args) {
   // Construct a simple local cache manager with default configuration
   CachingProvider jcacheProvider = Caching.getCachingProvider();
   CacheManager cacheManager = jcacheProvider.getCacheManager();
   MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
   configuration.setTypes(String.class, String.class);
   // create a cache using the supplied configuration
   Cache<String, String> cache = cacheManager.createCache("myCache", configuration);
   // Store a value
   cache.put("key", "value");
   // Retrieve the value and print it out
   System.out.printf("key = %s\n", cache.get("key"));
   // Stop the cache manager and release all resources
   cacheManager.close();
}
 
開發者ID:infinispan,項目名稱:infinispan-simple-tutorials,代碼行數:16,代碼來源:InfinispanJCache.java

示例14: removeCache_Stopped

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void removeCache_Stopped() {
    CacheManager cacheManager = getCacheManager();
    cacheManager.close();
    try {
        cacheManager.destroyCache("c1");
        fail();
    } catch (IllegalStateException e) {
        //ok
    }
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:12,代碼來源:TCKCacheManagerTest.java

示例15: close_cachesClosed

import javax.cache.CacheManager; //導入方法依賴的package包/類
@Test
public void close_cachesClosed() {
    CacheManager cacheManager = getCacheManager();

    cacheManager.createCache("c1", new MutableConfiguration());
    Cache cache1 = cacheManager.getCache("c1");
    cacheManager.createCache("c2", new MutableConfiguration());
    Cache cache2 = cacheManager.getCache("c2");

    cacheManager.close();

    ensureClosed(cache1);
    ensureClosed(cache2);
}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:15,代碼來源:TCKCacheManagerTest.java


注:本文中的javax.cache.CacheManager.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。