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


Java Factory类代码示例

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


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

示例1: JCache

import javax.cache.configuration.Factory; //导入依赖的package包/类
public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) {
    super(redisson.getConfig().getCodec(), redisson.getCommandExecutor(), name);
    
    this.hasOwnRedisson = hasOwnRedisson;
    this.redisson = redisson;
    
    Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
    if (cacheLoaderFactory != null) {
        cacheLoader = cacheLoaderFactory.create();
    }
    Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = config.getCacheWriterFactory();
    if (config.getCacheWriterFactory() != null) {
        cacheWriter = (CacheWriter<K, V>) cacheWriterFactory.create();
    }
    
    this.cacheManager = cacheManager;
    this.config = config;
    
    redisson.getEvictionScheduler().scheduleJCache(getName(), getTimeoutSetName(), getExpiredChannelName());
    
    for (CacheEntryListenerConfiguration<K, V> listenerConfig : config.getCacheEntryListenerConfigurations()) {
        registerCacheEntryListener(listenerConfig, false);
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:25,代码来源:JCache.java

示例2: testCall

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testCall() throws Exception {
    runTest(callableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                EchoCallable job = (EchoCallable)factory.create();
                job.setArg(value(i - 1));
                results.add(ignite.compute().call(job));
            }

            checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例3: deregisterCacheEntryListener

import javax.cache.configuration.Factory; //导入依赖的package包/类
@Override
public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
    verifyCacheConnectivity();
    final Factory<CacheEntryListener<? super K,? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
    final CacheEntryListener cacheEntryListener = factory.create();
    final CacheEventListener<K,V> cacheEventListener = new CacheEventListener<K, V>(cacheEntryListener, this, cacheEntryListenerConfiguration);
    try {
    if(cacheEventListener.isOnCreatedListenerConfigured() && addEventDescriptor != null) 
        innerCache.removeCacheDataModificationListener(addEventDescriptor);
    if(cacheEventListener.isOnUpdatedListenerConfigured() && updateEventDescriptor != null)
        innerCache.removeCacheDataModificationListener(updateEventDescriptor);
    if(cacheEventListener.isOnRemovedListenerConfigured() && deleteEventDescriptor != null) {
        if(!isExpiryEventConfigured)
            innerCache.removeCacheDataModificationListener(deleteEventDescriptor);
    }
    if(cacheEventListener.isOnExpiredListenerConfigured() && deleteEventDescriptor != null) {
        isExpiryEventConfigured = false;
        innerCache.removeCacheDataModificationListener(deleteEventDescriptor);
    }
    }
    catch (Exception e) {
        
    }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:25,代码来源:TayzGridCache.java

示例4: testMultiCacheByPartIdAffinityRun

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testMultiCacheByPartIdAffinityRun() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                comp.affinityRun(Arrays.asList("test0", "test1"), 0, job);
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例5: testAffinityRunAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testAffinityRunAsync() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache(CACHE_NAME);

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                IgniteFuture<Void> fut = comp.affinityRunAsync("test", key(0), job);

                fut.get();
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例6: testMultiCacheAffinityRunAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testMultiCacheAffinityRunAsync() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), key(0), job);

                fut.get();
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例7: createCacheConfiguration

import javax.cache.configuration.Factory; //导入依赖的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

示例8: testMultiCacheByPartIdAffinityRunAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testMultiCacheByPartIdAffinityRunAsync() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), 0, job);

                fut.get();
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例9: writeExpiryPolicyFactory

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * Writes the policy factory.
 *
 * @param out Writer.
 */
private static void writeExpiryPolicyFactory(BinaryRawWriter out, Factory<? extends ExpiryPolicy> factory) {
    if (!(factory instanceof PlatformExpiryPolicyFactory)) {
        out.writeBoolean(false);

        return;
    }

    out.writeBoolean(true);

    PlatformExpiryPolicyFactory f = (PlatformExpiryPolicyFactory)factory;

    out.writeLong(f.getCreate());
    out.writeLong(f.getUpdate());
    out.writeLong(f.getAccess());
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:PlatformConfigurationUtils.java

示例10: testAffinityCallAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testAffinityCallAsync() throws Exception {
    runTest(callableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache(CACHE_NAME);

            final IgniteCompute comp = ignite.compute();

            Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                EchoCallable job = (EchoCallable)factory.create();

                job.setArg(value(i - 1));

                IgniteFuture<Object> fut = comp.affinityCallAsync("test", key(0), job);

                results.add(fut.get());
            }

            checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例11: testMultiCacheByPartIdAffinityCallAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testMultiCacheByPartIdAffinityCallAsync() throws Exception {
    runTest(callableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                EchoCallable job = (EchoCallable)factory.create();

                job.setArg(value(i - 1));

                IgniteFuture fut = comp.affinityCallAsync(Arrays.asList("test0", "test1"), 0, job);

                results.add(fut.get());
            }

            checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例12: cacheConfiguration

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @param cacheName Cache name.
 * @param factory Factory to use.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(String cacheName, Factory<CacheStore> factory) {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setNearConfiguration(null);
    cfg.setName(cacheName);

    cfg.setBackups(1);

    if (factory != null) {
        cfg.setCacheStoreFactory(factory);

        cfg.setWriteThrough(true);
    }

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteCrossCacheTxStoreSelfTest.java

示例13: testMultiCacheAffinityCall

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testMultiCacheAffinityCall() throws Exception {
    runTest(callableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                EchoCallable job = (EchoCallable)factory.create();

                job.setArg(value(i - 1));

                results.add(comp.affinityCall(Arrays.asList("test0", "test1"), key(0), job));
            }

            checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例14: testCallCollection

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testCallCollection() throws Exception {
    runTest(callableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                EchoCallable job = (EchoCallable)factory.create();
                job.setArg(value(i - 1));
                jobs.add(job);
            }

            Collection<Object> results = ignite.compute().call(jobs);

            checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteComputeConfigVariationsFullApiTest.java

示例15: testExecuteTaskClassAsync

import javax.cache.configuration.Factory; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testExecuteTaskClassAsync() throws Exception {
    runTest(jobFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            // Begin with negative to check 'null' value in the test.
            final int[] i = {-1};

            ComputeTaskFuture<List<Object>> fut = ignite.compute().executeAsync(
                TestTask.class,
                new T2<>((Factory<ComputeJobAdapter>)factory,
                    (Factory<Object>)new Factory<Object>() {
                        @Override public Object create() {
                            return value(i[0]++);
                        }
                    }));

            checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass());
            assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get());
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:IgniteComputeConfigVariationsFullApiTest.java


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