Java Code Examples for javax.cache.event.EventType#values()

The following examples show how to use javax.cache.event.EventType#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListenerCollection.java    From triava with Apache License 2.0 6 votes vote down vote up
/**
 * Rebuild the listenerPresent lookup array 
 */
private void rebuildListenerPresent()
{
	short listenerPresentXnew = 0;
	for (ListenerEntry<K, V> listener : listeners)
	{
		for (EventType eventType : EventType.values())
		{
			if (listener.isListeningFor(eventType))
			{
				listenerPresentXnew |= (1 << eventType.ordinal());
			}
		}
	}

	listenerPresentMask = listenerPresentXnew;
}
 
Example 2
Source File: ListenerCollection.java    From triava with Apache License 2.0 6 votes vote down vote up
/**
 * Enables a listener, without adding it to the Configuration. An  enabled listener can send events after this method returns.  
 * The caller must make sure that the
 * corresponding Configuration object reflects the change.
 * 
 * @param listenerConfiguration
 * @return
 */
private synchronized boolean enableCacheEntryListener(CacheEntryListenerConfiguration<K, V> listenerConfiguration)
{
	DispatchMode dispatchMode = listenerConfiguration.isSynchronous() ? DispatchMode.SYNC : DispatchMode.ASYNC_TIMED;
	ListenerEntry<K, V> newListener = new ListenerEntry<K, V>(listenerConfiguration, tcache, dispatchMode);
	boolean added = listeners.add(newListener);
	for (EventType eventType : EventType.values())
	{
		if (newListener.isListeningFor(eventType))
		{
			listenerPresentMask |= (1 << eventType.ordinal());
		}
	}

	return added;
}
 
Example 3
Source File: CacheEntryListenerServer.java    From cache2k with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an CacheLoaderServer.
 *
 * @param port        the port on which to accept {@link org.jsr107.tck.integration.CacheLoaderClient} request.
 * @param keyClass    the class for entry key
 * @param valueClass  the class for entry value
 */
public CacheEntryListenerServer(int port, Class keyClass, Class valueClass) {
  super(port);
  this.listeners = new HashSet<CacheEntryListener<K, V>>();

  // establish the client-server operation handlers
  for (EventType eventType : EventType.values()) {
    addOperationHandler(new CacheEntryEventOperationHandler(eventType, keyClass, valueClass));
  }
}
 
Example 4
Source File: AsyncDispatcher.java    From cache2k with Apache License 2.0 5 votes vote down vote up
boolean removeAsyncListener(CacheEntryListenerConfiguration<K,V> cfg) {
  boolean _found = false;
  for (EventType t : EventType.values()) {
    _found |= EventHandlingImpl.removeCfgMatch(cfg, asyncListenerByType.get(t));
  }
  return _found;
}
 
Example 5
Source File: AsyncDispatcher.java    From cache2k with Apache License 2.0 4 votes vote down vote up
void collectListeners(Collection<Listener<K, V>> l) {
  for (EventType t : EventType.values()) {
    l.addAll(asyncListenerByType.get(t));
  }
}