本文整理了Java中javax.cache.configuration.Factory
类的一些代码示例,展示了Factory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory
类的具体详情如下:
包路径:javax.cache.configuration.Factory
类名称:Factory
[英]Constructs and returns a fully configured instance of a specific factory type.
Implementations may choose not to construct a new instance, but instead return a previously created instance.
Implementations must correctly implement Object#equals(Object) and Object#hashCode() as Factorys are often compared with each other for equivalence.
[中]构造并返回特定工厂类型的完全配置实例。
实现可以选择不构造新实例,而是返回以前创建的实例。
实现必须正确地实现Object#equals(Object)和Object#hashCode(),因为工厂经常相互比较以获得等价性。
代码示例来源:origin: apache/ignite
@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);
}
}
});
代码示例来源:origin: ben-manes/caffeine
static void checkListener(CaffeineConfiguration<?, ?> config) {
CacheEntryListenerConfiguration<?, ?> listener = Iterables.getOnlyElement(
config.getCacheEntryListenerConfigurations());
assertThat(listener.getCacheEntryListenerFactory().create(),
instanceOf(TestCacheEntryListener.class));
assertThat(listener.getCacheEntryEventFilterFactory().create(),
instanceOf(TestCacheEntryEventFilter.class));
assertThat(listener.isSynchronous(), is(true));
assertThat(listener.isOldValueRequired(), is(true));
}
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
IgniteRunnable job = (IgniteRunnable)factory.create();
ignite.compute().broadcast(job);
// All checks are inside the run() method of the job.
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected IgniteClosure<CacheEntryEvent<? extends K, ? extends V>, ?> getTransformer() {
if (rmtTrans == null && rmtTransFactory != null)
rmtTrans = rmtTransFactory.create();
return rmtTrans;
}
代码示例来源:origin: ben-manes/caffeine
/**
* Registers a cache entry listener based on the supplied configuration.
*
* @param configuration the listener's configuration.
*/
public void register(CacheEntryListenerConfiguration<K, V> configuration) {
if (configuration.getCacheEntryListenerFactory() == null) {
return;
}
EventTypeAwareListener<K, V> listener = new EventTypeAwareListener<>(
configuration.getCacheEntryListenerFactory().create());
CacheEntryEventFilter<K, V> filter = event -> true;
if (configuration.getCacheEntryEventFilterFactory() != null) {
filter = new EventTypeFilter<>(listener,
configuration.getCacheEntryEventFilterFactory().create());
}
Registration<K, V> registration = new Registration<>(configuration, filter, listener);
dispatchQueues.putIfAbsent(registration, CompletableFuture.completedFuture(null));
}
代码示例来源:origin: apache/ignite
final IgniteCache cache = client.createCache(cacheConfiguration(atomicityMode, heapCache, cfgExpiryPlc));
assertEquals(data, client.compute().affinityCall(cache.getName(), 1,
new GetAllClosure(data.keySet(), cache.getName(), withExpiryPlc)));
assertEquals(1, client.compute().affinityCall(cache.getName(), 1,
new GetClosure(1, cache.getName(), withExpiryPlc)));
srvCache = srvCache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create());
代码示例来源:origin: apache/ignite
cctx.config().addCacheEntryListenerConfiguration(cfg);
CacheEntryListener locLsnrImpl = (CacheEntryListener)cfg.getCacheEntryListenerFactory().create();
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Object call() throws Exception {
IgniteCache cache = ignite.cache(cacheName);
if (withExpiryPlc)
cache = cache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create());
Map vals = cache.getAll(keys);
Collection<CacheEntry> entries = cache.getEntries(keys);
assertEquals(vals.size(), entries.size());
for (CacheEntry entry : entries) {
Object val = vals.get(entry.getKey());
assertEquals(val, entry.getValue());
}
return vals;
}
}
代码示例来源:origin: apache/ignite
if (!forceSrvMode && (Boolean.TRUE.equals(ignite.configuration().isClientMode()))) {
if (ackTimeout == 0)
ackTimeout = DFLT_ACK_TIMEOUT_CLIENT;
metricsUpdateFreq = ignite.configuration().getMetricsUpdateFrequency();
SSLContext sslCtx = ignite().configuration().getSslContextFactory().create();
代码示例来源:origin: redisson/redisson
private void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean addToConfig) {
Factory<CacheEntryListener<? super K, ? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
final CacheEntryListener<? super K, ? super V> listener = factory.create();
Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory();
final CacheEntryEventFilter<? super K, ? super V> filter;
if (filterFactory != null) {
filter = filterFactory.create();
} else {
filter = null;
final boolean sync = cacheEntryListenerConfiguration.isSynchronous();
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
IgniteRunnable job = (IgniteRunnable)factory.create();
ignite.compute().run(job);
// All checks are inside the run() method of the job.
Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT);
for (int i = 0; i < MAX_JOB_COUNT; ++i)
jobs.add((IgniteRunnable)factory.create());
ignite.compute().run(jobs);
// All checks are inside the run() method of the job.
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public CacheStore<K, V> create() {
CacheLoader<K, V> ldr = ldrFactory == null ? null : ldrFactory.create();
CacheWriter<K, V> writer = writerFactory == null ? null : writerFactory.create();
return new GridCacheLoaderWriterStore<>(ldr, writer);
}
代码示例来源:origin: ehcache/ehcache3
@SuppressWarnings("unchecked")
static <K, V> ListenerResources<K, V> createListenerResources(CacheEntryListenerConfiguration<K, V> listenerConfig) {
CacheEntryListener<? super K, ? super V> listener = listenerConfig.getCacheEntryListenerFactory().create();
// create the filter, closing the listener above upon exception
CacheEntryEventFilter<? super K, ? super V> filter;
try {
Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = listenerConfig
.getCacheEntryEventFilterFactory();
if (filterFactory != null) {
filter = listenerConfig.getCacheEntryEventFilterFactory().create();
} else {
filter = event -> true;
}
} catch (Throwable t) {
throw closeAllAfter(new CacheException(t), listener);
}
try {
return new ListenerResources<>(listener, filter);
} catch (Throwable t) {
throw closeAllAfter(new CacheException(t), filter, listener);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private CacheEntryListener<K, V> createCacheEntryListener(
CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
Factory<CacheEntryListener<? super K, ? super V>> cacheEntryListenerFactory =
cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
injectDependencies(cacheEntryListenerFactory);
return (CacheEntryListener<K, V>) cacheEntryListenerFactory.create();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Object call() throws Exception {
IgniteCache cache = ignite.cache(cacheName);
if (withExpiryPlc)
cache = cache.withExpiryPolicy(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES).create());
Object val = cache.get(key);
CacheEntry e = cache.getEntry(key);
assertEquals(val, e.getValue());
return val;
}
}
代码示例来源:origin: apache/ignite
boolean clientMode = Boolean.TRUE.equals(ignite.configuration().isClientMode());
new GridNioSslFilter(ignite.configuration().getSslContextFactory().create(),
true, ByteOrder.nativeOrder(), log);
代码示例来源:origin: apache/ignite
@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();
}
}
});
代码示例来源:origin: redisson/redisson
private void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration, boolean addToConfig) {
Factory<CacheEntryListener<? super K, ? super V>> factory = cacheEntryListenerConfiguration.getCacheEntryListenerFactory();
final CacheEntryListener<? super K, ? super V> listener = factory.create();
Factory<CacheEntryEventFilter<? super K, ? super V>> filterFactory = cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory();
final CacheEntryEventFilter<? super K, ? super V> filter;
if (filterFactory != null) {
filter = filterFactory.create();
} else {
filter = null;
final boolean sync = cacheEntryListenerConfiguration.isSynchronous();
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
final Collection<Object> resultsAllNull = ignite.compute()
.broadcast((IgniteClosure<Object, Object>)factory.create(), null);
assertEquals("Result's size mismatch: job must be run on all server nodes",
gridCount() - clientsCount(), resultsAllNull.size());
for (Object o : resultsAllNull)
assertNull("All results must be null", o);
Collection<Object> resultsNotNull = ignite.compute()
.broadcast((IgniteClosure<Object, Object>)factory.create(), value(0));
checkResultsClassCount(gridCount() - clientsCount(), resultsNotNull, value(0).getClass());
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public CacheEntryEventFilter getEventFilter() {
if (filter == null) {
assert rmtFilterFactory != null;
Factory<? extends CacheEntryEventFilter> factory = rmtFilterFactory;
filter = factory.create();
if (types != 0)
filter = new JCacheQueryRemoteFilter(filter, types);
}
return filter;
}
内容来源于网络,如有侵权,请联系作者删除!