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


Java FactoryBuilder.SingletonFactory方法代码示例

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


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

示例1: createCacheConfiguration

import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
 * @param atomicityMode Atomicity mode.
 * @return Cache configuration.
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private CacheConfiguration<String, List<Double>> createCacheConfiguration(CacheAtomicityMode atomicityMode) {
    CacheConfiguration<String, List<Double>> cc = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cc.setCacheMode(PARTITIONED);
    cc.setAtomicityMode(atomicityMode);
    cc.setWriteSynchronizationMode(FULL_SYNC);

    cc.setReadThrough(true);
    cc.setWriteThrough(true);

    Factory cacheStoreFactory = new FactoryBuilder.SingletonFactory(new DummyCacheStore());

    cc.setCacheStoreFactory(cacheStoreFactory);

    cc.setBackups(2);

    return cc;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:EntryVersionConsistencyReadThroughTest.java

示例2: setMaxIdleTime

import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
@Override
public Builder<K,V> setMaxIdleTime(int maxIdleTime, TimeUnit timeUnit)
{
	if (maxIdleTime <= 0)
		throw new IllegalArgumentException("Invalid maxIdleTime: " + maxIdleTime);
	
	TouchedExpiryPolicy ep = new TouchedExpiryPolicy(new Duration(timeUnit, maxIdleTime));
	SingletonFactory<ExpiryPolicy> singletonFactory = new FactoryBuilder.SingletonFactory<ExpiryPolicy>(ep);
	this.expiryPolicyFactory = (Factory<ExpiryPolicy>)singletonFactory;
	
	return this;
}
 
开发者ID:trivago,项目名称:triava,代码行数:13,代码来源:Builder.java

示例3: testZeroOnUpdate

import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testZeroOnUpdate() throws Exception {
    factory = new FactoryBuilder.SingletonFactory<>(new TestPolicy(null, 0L, null));

    startGrids();

    for (final Integer key : keys()) {
        log.info("Test zero duration on update, key: " + key);

        zeroOnUpdate(key);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:IgniteCacheExpiryPolicyAbstractTest.java

示例4: factory

import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
public static Factory<CacheLoader<Object, Object>> factory() {
    return new FactoryBuilder.SingletonFactory(new MyCacheLoader());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:JCacheConfigurationTest.java

示例5: testContinuousQuery

import javax.cache.configuration.FactoryBuilder; //导入方法依赖的package包/类
/**
 * @param ccfg Cache configuration.
 * @param isClient Client.
 * @throws Exception If failed.
 */
protected void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, boolean isClient)
    throws Exception {
    ignite(0).createCache(ccfg);

    ThreadLocalRandom rnd = ThreadLocalRandom.current();

    QueryCursor<?> cur = null;

    final Class<Factory<CacheEntryEventFilter>> evtFilterFactory =
        (Class<Factory<CacheEntryEventFilter>>)getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilterFactory");

    final CountDownLatch latch = new CountDownLatch(10);

    ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();

    TestLocalListener localLsnr = new TestLocalListener() {
        @Override public void onEvent(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
            throws CacheEntryListenerException {
            for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
                latch.countDown();

                log.info("Received event: " + evt);
            }
        }
    };

    MutableCacheEntryListenerConfiguration<Integer, Integer> lsnrCfg =
        new MutableCacheEntryListenerConfiguration<>(
            new FactoryBuilder.SingletonFactory<>(localLsnr),
            (Factory<? extends CacheEntryEventFilter<? super Integer, ? super Integer>>)
                (Object)evtFilterFactory.newInstance(),
            true,
            true
        );

    qry.setLocalListener(localLsnr);

    qry.setRemoteFilterFactory(
        (Factory<? extends CacheEntryEventFilter<Integer, Integer>>)(Object)evtFilterFactory.newInstance());

    IgniteCache<Integer, Integer> cache = null;

    try {
        if (isClient)
            cache = grid(NODES - 1).cache(ccfg.getName());
        else
            cache = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName());

        cur = cache.query(qry);

        cache.registerCacheEntryListener(lsnrCfg);

        for (int i = 0; i < 10; i++)
            cache.put(i, i);

        assertTrue(latch.await(3, TimeUnit.SECONDS));
    }
    finally {
        if (cur != null)
            cur.close();

        if (cache != null)
            cache.deregisterCacheEntryListener(lsnrCfg);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:72,代码来源:CacheContinuousQueryOperationP2PTest.java


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