本文整理匯總了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);
}
示例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");
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}