本文整理汇总了Java中javax.cache.event.EventType.CREATED属性的典型用法代码示例。如果您正苦于以下问题:Java EventType.CREATED属性的具体用法?Java EventType.CREATED怎么用?Java EventType.CREATED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.cache.event.EventType
的用法示例。
在下文中一共展示了EventType.CREATED属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put0
void put0(K key, V value, boolean writeThrough)
{
throwISEwhenClosed();
kvUtil.verifyKeyAndValueNotNull(key, value);
Action<K,V,Object> action = new PutAction<>(key, value, EventType.CREATED, false, writeThrough);
if (actionRunner.preMutate(action))
{
Holders<V> holders = tcache.putToMapI(key, value, tcache.cacheTimeSpread(), false);
final EventType eventType;
if (holders == null)
eventType = null;
else
{
if (holders.newHolder == null || holders.newHolder.isInvalid())
eventType = null; // new is invalid
else
eventType = holders.oldHolder == null ? EventType.CREATED : EventType.UPDATED;
}
action.setEventType(eventType);
actionRunner.postMutate(action);
}
action.close();
}
示例2: putIfAbsent
@Override
public boolean putIfAbsent(K key, V value)
{
throwISEwhenClosed();
PutAction<K,V,Object> action = new PutAction<>(key, value, EventType.CREATED, false);
boolean added = false;
if (actionRunnerWriteBehind.preMutate(action))
{
Holders<V> holders = tcache.putIfAbsentH(key, value);
// For JSR107 putIfAbsent() should return whether a value was set.
// It is set when the old holder was null AND the new holder is not null.
// The latter case (new holder == null) can happen if it immediately expires.
added = holders.oldHolder == null && holders.newHolder != null;
if (added)
actionRunnerWriteBehind.postMutate(action);
}
return added;
}
示例3: onEntryCreated
void onEntryCreated(K key, V value) {
if (onCreate) {
BlazingCacheCacheEntryEvent event = new BlazingCacheCacheEntryEvent(key, null, value, parent, EventType.CREATED, false);
if (filter != null && !filter.evaluate(event)) {
return;
}
((CacheEntryCreatedListener) listener).onCreated(Arrays.asList(event));
}
}
示例4: testCacheEntryEventUnwrap
@Test
public void testCacheEntryEventUnwrap() {
MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
configuration.setTypes(String.class, String.class);
Cache<String, String> cache = cacheManager.createCache("cache", configuration);
org.ehcache.event.CacheEvent<String, String> ehEvent = new EhEvent();
Eh107CacheEntryEvent<String, String> cacheEntryEvent = new Eh107CacheEntryEvent.NormalEvent<>(cache, EventType.CREATED, ehEvent, false);
assertThat(cacheEntryEvent.unwrap(org.ehcache.event.CacheEvent.class), is(instanceOf(CacheEvent.class)));
assertThat(cacheEntryEvent.unwrap(cacheEntryEvent.getClass()), is(instanceOf(Eh107CacheEntryEvent.NormalEvent.class)));
}
示例5: fireCreated
private void fireCreated(final javax.cache.Cache<K, V> _jCache, final CacheEntry<K, V> e) {
EntryEvent<K, V> cee =
new EntryEvent<K, V>(_jCache, EventType.CREATED, e.getKey(), extractValue(e.getValue()));
asyncDispatcher.deliverAsyncEvent(cee);
for (Listener<K,V> t : createdListener) {
t.fire(cee);
}
}
示例6: evaluate
@Override
public boolean evaluate(CacheEntryEvent<? extends K, ? extends V> event) throws CacheEntryListenerException {
return event.getEventType() == EventType.CREATED;
}
示例7: AbstractJCacheTest
protected AbstractJCacheTest(String cacheName) {
this(cacheName, EventType.CREATED, EventType.UPDATED, EventType.REMOVED, EventType.EXPIRED);
}
示例8: shouldHandleCacheEntryEventFromServerWithClient
/**
* Ensure that values can be loaded from the {@link org.jsr107.tck.event.CacheEntryListenerClient} via
* the {@link org.jsr107.tck.event.CacheEntryListenerServer}.
*/
@Test
public void shouldHandleCacheEntryEventFromServerWithClient() {
CacheTestSupport.MyCacheEntryListener<String, String> listener = new CacheTestSupport.MyCacheEntryListener<>();
CacheEntryListenerServer<String, String> serverListener =
new CacheEntryListenerServer<>(10011, String.class, String.class);
serverListener.addCacheEventListener(listener);
try {
serverListener.open();
CacheEntryListenerClient<String, String> clientListener =
new CacheEntryListenerClient<>(serverListener.getInetAddress(), serverListener.getPort());
TestCacheEntryEvent<String, String> event = new TestCacheEntryEvent(null, EventType.CREATED);
event.setKey("key");
event.setValue("value");
event.setOldValueAvailable(false);
ArrayList events = new ArrayList();
events.add(event);
clientListener.onCreated(events);
Assert.assertThat(listener.getCreated(), is(1));
clientListener.onRemoved(events);
Assert.assertThat(listener.getRemoved(), is(0));
event = new TestCacheEntryEvent(null, EventType.UPDATED);
event.setKey("key");
event.setValue("value");
event.setOldValue("oldValue");
event.setOldValueAvailable(true);
events.clear();
events.add(event);
clientListener.onUpdated(events);
Assert.assertThat(listener.getUpdated(), is(1));
Assert.assertThat(listener.getCreated(), is(1));
} catch (Exception e) {
} finally {
serverListener.close();
}
}
示例9: getEventType
@Override
public EventType getEventType() {
return EventType.CREATED;
}