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


Java EmbeddedCacheManager.getCache方法代碼示例

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


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

示例1: doCreateHttpServerMechanismFactory

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
protected HttpServerAuthenticationMechanismFactory doCreateHttpServerMechanismFactory(Map<String, ?> properties) {
    HttpServerAuthenticationMechanismFactory delegate = super.doCreateHttpServerMechanismFactory(properties);

    String cacheManagerName = UUID.randomUUID().toString();
    EmbeddedCacheManager cacheManager = new DefaultCacheManager(
            GlobalConfigurationBuilder.defaultClusteredBuilder()
                    .globalJmxStatistics().cacheManagerName(cacheManagerName)
                    .transport().nodeName(cacheManagerName).addProperty(JGroupsTransport.CONFIGURATION_FILE, "fast.xml")
                    .build(),
            new ConfigurationBuilder()
                    .clustering()
                    .cacheMode(CacheMode.REPL_SYNC)
                    .build()
    );

    Cache<String, SingleSignOnEntry> cache = cacheManager.getCache();
    SingleSignOnManager manager = new DefaultSingleSignOnManager(cache, new DefaultSingleSignOnSessionIdentifierFactory(), (id, entry) -> cache.put(id, entry));
    SingleSignOnServerMechanismFactory.SingleSignOnConfiguration signOnConfiguration = new SingleSignOnServerMechanismFactory.SingleSignOnConfiguration("JSESSIONSSOID", null, "/", false, false);

    SingleSignOnSessionFactory singleSignOnSessionFactory = new DefaultSingleSignOnSessionFactory(manager, this.keyPairSupplier.get());

    return new SingleSignOnServerMechanismFactory(delegate, singleSignOnSessionFactory, signOnConfiguration);
}
 
開發者ID:wildfly-security,項目名稱:elytron-web,代碼行數:25,代碼來源:FormAuthenticationWithClusteredSSOTest.java

示例2: initCacheInfinispan

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
/**
 * Inits the cache infinispan.
 */
private static void initCacheInfinispan() {
	EmbeddedCacheManager manager = new DefaultCacheManager();
	Configuration config = new Configuration().fluent()
	  .eviction()
	    .maxEntries((int)sCacheItemsLimit).strategy(EvictionStrategy.LRU)
	    /*.wakeUpInterval(5000L)*/ // TODO - fix it 
	  .expiration()
	    .maxIdle(120000L)
	    .build();

	manager.defineConfiguration("name", config);
	ispnCache = manager.getCache("name");


}
 
開發者ID:VladRodionov,項目名稱:bigbase,代碼行數:19,代碼來源:PerfTest.java

示例3: create

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public BenchmarkCache<Integer, Integer> create(int _maxElements) {
  EmbeddedCacheManager m = getCacheMangaer();
  ConfigurationBuilder cb = new ConfigurationBuilder();

  cb.eviction().maxEntries(_maxElements);
  cb.storeAsBinary().disable();
  if (!withExpiry) {
    cb.expiration().disableReaper().lifespan(-1);
  } else {
    cb.expiration().lifespan(5 * 60, TimeUnit.SECONDS);
  }
  switch (algorithm) {
    case LRU: cb.eviction().strategy(EvictionStrategy.LRU); break;
    case LIRS: cb.eviction().strategy(EvictionStrategy.LIRS); break;
    case UNORDERED: cb.eviction().strategy(EvictionStrategy.UNORDERED); break;
  }
  m.defineConfiguration(CACHE_NAME, cb.build());
  Cache<Integer, Integer> _cache = m.getCache(CACHE_NAME);
  return new MyBenchmarkCache(_cache);
}
 
開發者ID:cache2k,項目名稱:cache2k-benchmark,代碼行數:22,代碼來源:InfinispanCacheFactory.java

示例4: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).location(tmpDataDirectory)
         .expiredLocation(tmpExpiredDirectory).implementationType(LevelDBStoreConfiguration.ImplementationType.AUTO).build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof LevelDBStoreConfiguration);
   LevelDBStoreConfiguration leveldbConfig = (LevelDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(tmpDataDirectory, leveldbConfig.location());
   assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:danberindei,項目名稱:infinispan-cachestore-leveldb,代碼行數:24,代碼來源:ConfigurationTest.java

示例5: testLegacyJavaConfig

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Test(enabled = false, description = "ISPN-3388")
public void testLegacyJavaConfig() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).addProperty("location", tmpDataDirectory)
         .addProperty("expiredLocation", tmpExpiredDirectory).addProperty("implementationType", LevelDBStoreConfiguration.ImplementationType.AUTO.toString()).build();

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there legacy java");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:danberindei,項目名稱:infinispan-cachestore-leveldb,代碼行數:19,代碼來源:ConfigurationTest.java

示例6: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(MapDBStoreConfigurationBuilder.class)
         .location(tmpDirectory)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof MapDBStoreConfiguration);
   MapDBStoreConfiguration config = (MapDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:saturnism,項目名稱:infinispan-cachestore-mapdb,代碼行數:25,代碼來源:ConfigurationTest.java

示例7: addListener

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public void addListener(String containerName, String cacheName,
        IGetUpdates<?, ?> u) throws CacheListenerAddException {
    EmbeddedCacheManager manager = this.cm;
    Cache<Object,Object> c;
    String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
    if (manager == null) {
        return;
    }

    if (!manager.cacheExists(realCacheName)) {
        throw new CacheListenerAddException();
    }
    c = manager.getCache(realCacheName);
    CacheListenerContainer cl = new CacheListenerContainer(u,
            containerName, cacheName);
    c.addListener(cl);
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:19,代碼來源:ClusterManager.java

示例8: getListeners

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public Set<IGetUpdates<?, ?>> getListeners(String containerName,
        String cacheName) {
    EmbeddedCacheManager manager = this.cm;
    Cache<Object,Object> c;
    String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
    if (manager == null) {
        return null;
    }

    if (!manager.cacheExists(realCacheName)) {
        return null;
    }
    c = manager.getCache(realCacheName);

    Set<IGetUpdates<?, ?>> res = new HashSet<IGetUpdates<?, ?>>();
    Set<Object> listeners = c.getListeners();
    for (Object listener : listeners) {
        if (listener instanceof CacheListenerContainer) {
            CacheListenerContainer cl = (CacheListenerContainer) listener;
            res.add(cl.whichListener());
        }
    }

    return res;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:27,代碼來源:ClusterManager.java

示例9: removeListener

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Override
public void removeListener(String containerName, String cacheName,
        IGetUpdates<?, ?> u) {
    EmbeddedCacheManager manager = this.cm;
    Cache<Object,Object> c;
    String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
    if (manager == null) {
        return;
    }

    if (!manager.cacheExists(realCacheName)) {
        return;
    }
    c = manager.getCache(realCacheName);

    Set<Object> listeners = c.getListeners();
    for (Object listener : listeners) {
        if (listener instanceof CacheListenerContainer) {
            CacheListenerContainer cl = (CacheListenerContainer) listener;
            if (cl.whichListener() == u) {
                c.removeListener(listener);
                return;
            }
        }
    }
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:27,代碼來源:ClusterManager.java

示例10: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(OffheapStoreConfigurationBuilder.class)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof OffheapStoreConfiguration);
   OffheapStoreConfiguration config = (OffheapStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
開發者ID:saturnism,項目名稱:infinispan-cachestore-offheap,代碼行數:24,代碼來源:ConfigurationTest.java

示例11: createDefaultEntityToCacheMapper

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@Bean
@ConditionalOnMissingBean(EntityToCacheMapper.class)
@ConditionalOnBean(EmbeddedCacheManager.class)
public EntityToCacheMapper createDefaultEntityToCacheMapper(final EmbeddedCacheManager cacheManager) {
    return new EntityToCacheMapper() {
        public <ID, T> Cache<ID, T> getCache(Class<T> entityClass) {
            return cacheManager.getCache(); // always return default cache
        }
    };
}
 
開發者ID:snowdrop,項目名稱:spring-data-snowdrop,代碼行數:11,代碼來源:SnowdropDataInfinispanEmbeddedAutoConfiguration.java

示例12: getCache

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public static synchronized Cache<String, String> getCache() {
	if (INSTANCE == null) {
		GlobalConfiguration gc = GlobalConfigurationBuilder.defaultClusteredBuilder()
				// Use this line for testing in Kubernetes. But it requires
				// additional configuration:
				// oc policy add-role-to-user view
				// system:serviceaccount:$(oc
				// project -q):default -n $(oc project -q)
				// And setting OPENSHIFT_KUBE_PING_NAMESPACE env variable to
				// your namespace
				.transport().defaultTransport()
				.addProperty("configurationFile", "default-configs/default-jgroups-kubernetes.xml")

				// Or use, multicast stack to simplify local testing:
				// .transport().defaultTransport().addProperty("configurationFile",
				// "default-configs/default-jgroups-udp.xml")
				.build();

		EmbeddedCacheManager manager = new DefaultCacheManager(gc);

		// And here are per-cache configuration, e.g. eviction, replication
		// scheme etc.
		ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
		configurationBuilder.clustering().cacheMode(CacheMode.REPL_ASYNC);
		manager.defineConfiguration("default", configurationBuilder.build());
		INSTANCE = manager.getCache("default");
	}
	return INSTANCE;
}
 
開發者ID:redhat-developer-demos,項目名稱:the-deploy-master,代碼行數:30,代碼來源:CacheInstance.java

示例13: get

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
@GET
@Produces("text/plain")
public String get() throws Exception {
    EmbeddedCacheManager cacheContainer
            = (EmbeddedCacheManager) new InitialContext().lookup("java:jboss/infinispan/container/server");
    Cache<String,String> cache = cacheContainer.getCache("server");
    if (cache.keySet().contains(key)) {
        return (String) cache.get(key);
    }

    String result = UUID.randomUUID().toString();
    cache.put(key, result);
    return result;
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:15,代碼來源:MyResource.java

示例14: main

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(SpringBootApp.class, args);

    EmbeddedCacheManager cacheManager = ctx.getBean(EmbeddedCacheManager.class);
    Cache<Long, String> cache = cacheManager.getCache(CACHE_NAME);
    cache.put(System.currentTimeMillis(), "Infinispan");

    logger.info("Values from Cache: {}", cache.entrySet());
}
 
開發者ID:infinispan,項目名稱:infinispan-simple-tutorials,代碼行數:10,代碼來源:SpringBootApp.java

示例15: build

import org.infinispan.manager.EmbeddedCacheManager; //導入方法依賴的package包/類
public EmbeddedCacheManager build() {
	PROCESS_ID = ManagementFactory.getRuntimeMXBean().getName().replaceAll("@.*", "");
	MDC.put("PID", PROCESS_ID);
	
	// udp + multicast is difficult to obtain in test environment
	Properties properties = new Properties();
	properties.put("configurationFile", "test-jgroups-tcp.xml");
	
	GlobalConfiguration globalConfiguration =
			new GlobalDefaultReplicatedTransientConfigurationBuilder(properties).nodeName(name).build();
	Configuration configuration =
			new DefaultReplicatedTransientConfigurationBuilder().build();
	EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfiguration, configuration, false);
	cacheManager.getCache(TestConstants.CACHE_DEFAULT);
	
	if (taskName != null) {
		try {
			Class<?> clazz = Class.forName(taskName);
			Constructor<?> constructor = clazz.getConstructor(EmbeddedCacheManager.class);
			Runnable r = (Runnable) constructor.newInstance(cacheManager);
			
			Thread t = new Thread((Runnable) r);
			t.start();
		} catch (Exception e) {
			throw new IllegalStateException(e);
		}
	}
	
	return cacheManager;
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:31,代碼來源:TestCacheManagerBuilder.java


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