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


Java CacheEntryRemovedListener类代码示例

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


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

示例1: determineEventListener

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
private void determineEventListener(ArrayList arrayList, javax.cache.event.EventType eventType) {
    
    if(eventType == javax.cache.event.EventType.CREATED) {
        if(_isOnCreatedListener)
            ((CacheEntryCreatedListener<K, V>)_cacheEntryListener).onCreated(arrayList);
    }
    else if(eventType == javax.cache.event.EventType.EXPIRED) {
        if(_isOnExpiredListener)
                ((CacheEntryExpiredListener<K,V>) _cacheEntryListener).onExpired(arrayList);
    }
    else if(eventType == javax.cache.event.EventType.REMOVED) {
        if(_isOnRemovedListener)
            ((CacheEntryRemovedListener<? super K, ? super V>) _cacheEntryListener).onRemoved(arrayList);
    }
     else if(eventType == javax.cache.event.EventType.UPDATED) {
         if(_isOnUpdatedListener) 
                ((CacheEntryUpdatedListener<K, V>)_cacheEntryListener).onUpdated(arrayList);
     }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:20,代码来源:CacheEventListener.java

示例2: isListeningFor

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
/**
 * Returns whether this {@link ListenerEntry} is listening to the given eventType
 * @param eventType The event Type
 * @return true, if the listener is listening to the given eventType
 */
boolean isListeningFor(EventType eventType)
{
	switch (eventType)
	{
		case CREATED:
			return listener instanceof CacheEntryCreatedListener;
		case EXPIRED:
			return listener instanceof CacheEntryExpiredListener;
		case REMOVED:
			return listener instanceof CacheEntryRemovedListener;
		case UPDATED:
			return listener instanceof CacheEntryUpdatedListener;
	}

	return false;
}
 
开发者ID:trivago,项目名称:triava,代码行数:22,代码来源:ListenerEntry.java

示例3: ehListenersFor

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static <K, V> List<EventListenerAdaptor<K, V>> ehListenersFor(CacheEntryListener<? super K, ? super V> listener,
    CacheEntryEventFilter<? super K, ? super V> filter, Cache<K, V> source, boolean requestsOld) {
  List<EventListenerAdaptor<K, V>> rv = new ArrayList<>();

  if (listener instanceof CacheEntryUpdatedListener) {
    rv.add(new UpdatedAdaptor<>(source, (CacheEntryUpdatedListener<K, V>) listener,
      (CacheEntryEventFilter<K, V>) filter, requestsOld));
  }
  if (listener instanceof CacheEntryCreatedListener) {
    rv.add(new CreatedAdaptor<>(source, (CacheEntryCreatedListener<K, V>) listener,
      (CacheEntryEventFilter<K, V>) filter, requestsOld));
  }
  if (listener instanceof CacheEntryRemovedListener) {
    rv.add(new RemovedAdaptor<>(source, (CacheEntryRemovedListener<K, V>) listener,
      (CacheEntryEventFilter<K, V>) filter, requestsOld));
  }
  if (listener instanceof CacheEntryExpiredListener) {
    rv.add(new ExpiredAdaptor<>(source, (CacheEntryExpiredListener<K, V>) listener,
      (CacheEntryEventFilter<K, V>) filter, requestsOld));
  }

  return rv;
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:25,代码来源:EventListenerAdaptors.java

示例4: CacheEventListener

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
public CacheEventListener(CacheEntryListener<K,V> cacheEntryListener, final TayzGridCache<K,V> jCache, final CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) {
    _cacheEntryListener = cacheEntryListener;
    _jCache = jCache;
    
    if(cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory() != null) 
        _cacheEntryEventFilter = cacheEntryListenerConfiguration.getCacheEntryEventFilterFactory().create();
    else
        _cacheEntryEventFilter = null;
    
    _isOnCreatedListener = implementsMethod(CacheEntryCreatedListener.class);
    _isOnExpiredListener = implementsMethod(CacheEntryExpiredListener.class);
    _isOnRemovedListener = implementsMethod(CacheEntryRemovedListener.class);
    _isOnUpdatedListener = implementsMethod(CacheEntryUpdatedListener.class);
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:15,代码来源:CacheEventListener.java

示例5: sendEvents

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
private void sendEvents(TCacheEntryEventCollection<K, V> eventColl, CacheEntryListener<K, V> listener)
	{
		EventType eventType = eventColl.eventType();
//		System.out.println("sendEvents to listener " + listener + ", eventType=" + eventColl.eventType());
		switch (eventType)
        {
            case CREATED:
                if (listener instanceof CacheEntryCreatedListener)
                    eventManager.created((CacheEntryCreatedListener<K, V>)listener, eventColl);
                break;

            case EXPIRED:
                if (listener instanceof CacheEntryExpiredListener)
                    eventManager.expired((CacheEntryExpiredListener<K, V>)listener,  eventColl);
                break;

            case UPDATED:
                if (listener instanceof CacheEntryUpdatedListener)
                    eventManager.updated((CacheEntryUpdatedListener<K,V>)listener,  eventColl);
                break;

            case REMOVED:
                if (listener instanceof CacheEntryRemovedListener)
                    eventManager.removed((CacheEntryRemovedListener<K,V>)listener,  eventColl);
                break;

            default:
                // By default do nothing. If new event types are added to the Spec, they will be ignored.
        }
	}
 
开发者ID:trivago,项目名称:triava,代码行数:31,代码来源:ListenerEntry.java

示例6: BlazingCacheCacheEntryListenerWrapper

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
BlazingCacheCacheEntryListenerWrapper(boolean synchronous, boolean oldValueRequired, CacheEntryListener<K, V> listener, CacheEntryEventFilter<K, V> filter, CacheEntryListenerConfiguration<K, V> configuration, BlazingCacheCache<K, V> parent) {
    this.synchronous = synchronous;
    this.parent = parent;
    this.oldValueRequired = oldValueRequired;
    this.listener = listener;
    this.filter = filter;
    this.configuration = configuration;
    this.onCreate = listener instanceof CacheEntryCreatedListener;
    this.onUpdate = listener instanceof CacheEntryUpdatedListener;
    this.onRemove = listener instanceof CacheEntryRemovedListener;
    this.needPreviousValue = oldValueRequired || onRemove || onUpdate;
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:13,代码来源:BlazingCacheCacheEntryListenerWrapper.java

示例7: onEntryRemoved

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
void onEntryRemoved(K key, V oldValue) {
    if (onRemove) {
        BlazingCacheCacheEntryEvent event = new BlazingCacheCacheEntryEvent(key, oldValue, oldValue, parent, EventType.REMOVED, true);
        if (filter != null && !filter.evaluate(event)) {
            return;
        }
        ((CacheEntryRemovedListener) listener).onRemoved(Arrays.asList(event));
    }
}
 
开发者ID:diennea,项目名称:blazingcache,代码行数:10,代码来源:BlazingCacheCacheEntryListenerWrapper.java

示例8: queueEvent

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
/**
 * Requests that the specified event be prepared for dispatching to their specific type of listeners.
 *
 * @param event         the event to be dispatched
 */
public void queueEvent(CacheEntryEvent<K, V> event) {
    if (event == null) {
        throw new NullPointerException("event can't be null");
    }

    Class<? extends CacheEntryListener> listenerClass;
    switch (event.getEventType()) {
        case CREATED:
            listenerClass = CacheEntryCreatedListener.class;
            break;
        case UPDATED:
            listenerClass = CacheEntryUpdatedListener.class;
            break;
        case REMOVED:
            listenerClass = CacheEntryRemovedListener.class;
            break;
        case EXPIRED:
            listenerClass = CacheEntryExpiredListener.class;
            break;
        default:
            throw new IllegalArgumentException("Unknown event type " + event.getEventType());
    }

    List<CacheEntryEvent<K, V>> queue;
    synchronized (this) {
        queue = eventQueues.get(listenerClass);
        if (queue == null) {
            queue = new ArrayList<CacheEntryEvent<K, V>>();
            eventQueues.put(listenerClass, queue);
        }
    }

    queue.add(event);
}
 
开发者ID:couchbaselabs,项目名称:couchbase-java-cache,代码行数:40,代码来源:CacheEventManager.java

示例9: dispatchForRemove

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
protected void dispatchForRemove() {
    List<CacheEntryEvent<K, V>> events = eventQueues.get(CacheEntryRemovedListener.class);
    if (events == null) {
        return;
    }

    for (ListenerEntry entry: entries) {
        if (entry.getListener() instanceof CacheEntryRemovedListener) {
            ((CacheEntryRemovedListener) entry.getListener()).onRemoved(filterEvents(entry, events));
        }
    }
}
 
开发者ID:couchbaselabs,项目名称:couchbase-java-cache,代码行数:13,代码来源:CacheEventManager.java

示例10: onRemoved

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
@Override
public void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends V>> cacheEntryEvents) throws CacheEntryListenerException {
  if (isDirectCallable()) {
    for (CacheEntryListener<K,V> l : listenerServer.getListeners()) {
      if (l instanceof CacheEntryRemovedListener) {
        ((CacheEntryRemovedListener<K,V>) l).onRemoved(cacheEntryEvents);
      }
    }
    return;
  }
  for (CacheEntryEvent<? extends K, ? extends V> event : cacheEntryEvents) {
    getClient().invoke(new OnCacheEntryEventHandler<K, V>(event));
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:15,代码来源:CacheEntryListenerClient.java

示例11: runHandlers

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
private void runHandlers(EventType eventType, TestCacheEntryEvent event) {
  ArrayList events = new ArrayList(1);
  events.add(event);

  for (CacheEntryListener listener : listeners) {
    switch (eventType) {
      case CREATED :
        if (listener instanceof CacheEntryCreatedListener) {
          ((CacheEntryCreatedListener) listener).onCreated(events);
        }
        break;

      case UPDATED:
        if (listener instanceof CacheEntryUpdatedListener) {
          ((CacheEntryUpdatedListener) listener).onUpdated(events);
        }
        break;

      case REMOVED:
        if (listener instanceof CacheEntryRemovedListener) {
          ((CacheEntryRemovedListener) listener).onRemoved(events);
        }
        break;

      case EXPIRED:
        if (listener instanceof CacheEntryExpiredListener) {
          ((CacheEntryExpiredListener) listener).onExpired(events);
        }
        break;

      default:
        break;
    }
  }
}
 
开发者ID:cache2k,项目名称:cache2k,代码行数:36,代码来源:CacheEntryListenerServer.java

示例12: notifyListeners

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
private void notifyListeners(CacheEntryEvent<K, V> event)
{
    for (CacheEntryListenerConfiguration<K, V> listenerConfiguration : cacheEntryListenerConfigurations)
    {
        boolean invokeListener = true;

        if (listenerConfiguration.getCacheEntryEventFilterFactory() != null)
        {
            invokeListener = listenerConfiguration.getCacheEntryEventFilterFactory().create().evaluate(event);
        }

        if (invokeListener)
        {
            CacheEntryListener<?, ?> cel = listenerConfiguration.getCacheEntryListenerFactory().create();

            switch (event.getEventType())
            {
                case CREATED:
                    if (cel instanceof CacheEntryCreatedListener)
                    {
                        throw new CacheEntryListenerException("Not supported!");
                    }
                    break;

                case EXPIRED:
                    if (cel instanceof CacheEntryExpiredListener)
                    {
                        ((CacheEntryExpiredListener) cel).onExpired(Sets.newHashSet(event));
                    }
                    break;

                case REMOVED:
                    if (cel instanceof CacheEntryRemovedListener)
                    {
                        ((CacheEntryRemovedListener) cel).onRemoved(Sets.newHashSet(event));
                    }
                    break;

                case UPDATED:
                    if (cel instanceof CacheEntryUpdatedListener)
                    {
                        ((CacheEntryUpdatedListener) cel).onUpdated(Sets.newHashSet(event));
                    }
                    break;
            }
        }
    }
}
 
开发者ID:ocafebabe,项目名称:guava-jcache,代码行数:49,代码来源:GuavaCache.java

示例13: removed

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
@Override
public void removed(CacheEntryRemovedListener<K, V> listener, TCacheEntryEventCollection<K, V> eventColl)
{
	listener.onRemoved(eventColl.events());
}
 
开发者ID:trivago,项目名称:triava,代码行数:6,代码来源:ListenerCacheEventManager.java

示例14: AbstractJCacheTest

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
protected AbstractJCacheTest(String cacheName, EventType... eventTypesToListenFor) {
	cacheEvents = new EnumMap<>(EventType.class);
	cache = cacheManager.getCache(cacheName);
	activeCacheEntryListenerConfigurations = new ArrayList<>();

	final Consumer<Iterable<CacheEntryEvent<? extends K, ? extends V>>> listener = iterable -> iterable.forEach(
			event -> {
				if (LOG.isTraceEnabled()) {
					LOG.trace("{}: an entry has been {}.", event.getSource().getName(), event.getEventType());
				}
				cacheEvents.get(event.getEventType()).add(event);
			});

	Factory<? extends CacheEntryListener<? super K, ? super V>> listenerFactory;
	for (final EventType eventTypeToListenFor : eventTypesToListenFor) {

		// create the specific listenerFactory for the eventType
		switch (eventTypeToListenFor) {
		case CREATED:
			listenerFactory = (Factory<CacheEntryCreatedListener<K, V>>) (() -> listener::accept);
			break;

		case EXPIRED:
			listenerFactory = (Factory<CacheEntryExpiredListener<K, V>>) (() -> listener::accept);
			break;

		case REMOVED:
			listenerFactory = (Factory<CacheEntryRemovedListener<K, V>>) (() -> listener::accept);
			break;

		case UPDATED:
			listenerFactory = (Factory<CacheEntryUpdatedListener<K, V>>) (() -> listener::accept);
			break;

		default:
			throw new IllegalArgumentException(String.format("Unknown EventType: %s!", eventTypeToListenFor));
		}
		// initialize the backing collection for the specific eventType
		cacheEvents.put(eventTypeToListenFor, new ArrayList<>());

		// add the listenerConfiguration to the list which will be used to register/deregister them
		activeCacheEntryListenerConfigurations.add(
				new MutableCacheEntryListenerConfiguration<>(listenerFactory, null, true, false));
	}
}
 
开发者ID:pnemes,项目名称:jcache-cdi-example,代码行数:46,代码来源:AbstractJCacheTest.java

示例15: RemovedAdaptor

import javax.cache.event.CacheEntryRemovedListener; //导入依赖的package包/类
RemovedAdaptor(Cache<K, V> source, CacheEntryRemovedListener<K, V> listener, CacheEntryEventFilter<K, V> filter,
    boolean requestsOld) {
  super(source, filter, requestsOld);
  this.listener = listener;
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:6,代码来源:EventListenerAdaptors.java


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