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


Java EventType.CREATED属性代码示例

本文整理汇总了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();
}
 
开发者ID:trivago,项目名称:triava,代码行数:25,代码来源:TCacheJSR107.java

示例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;
}
 
开发者ID:trivago,项目名称:triava,代码行数:20,代码来源:TCacheJSR107.java

示例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));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:9,代码来源:BlazingCacheCacheEntryListenerWrapper.java

示例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)));
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:UnwrapTest.java

示例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);
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:8,代码来源:EventHandling.java

示例6: evaluate

@Override
public boolean evaluate(CacheEntryEvent<? extends K, ? extends V> event) throws CacheEntryListenerException {
    return event.getEventType() == EventType.CREATED;
}
 
开发者ID:sdl,项目名称:dxa-modules,代码行数:4,代码来源:OnlyCreatedFilter.java

示例7: AbstractJCacheTest

protected AbstractJCacheTest(String cacheName) {
	this(cacheName, EventType.CREATED, EventType.UPDATED, EventType.REMOVED, EventType.EXPIRED);
}
 
开发者ID:pnemes,项目名称:jcache-cdi-example,代码行数:3,代码来源:AbstractJCacheTest.java

示例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();
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:51,代码来源:CacheEntryListenerClientServerTest.java

示例9: getEventType

@Override
public EventType getEventType() {
  return EventType.CREATED;
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:4,代码来源:Listener.java


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