Skip to content

Instantly share code, notes, and snippets.

@galderz
Last active August 29, 2015 14:05
Show Gist options
  • Save galderz/257e1f39f2dce672cca8 to your computer and use it in GitHub Desktop.
Save galderz/257e1f39f2dce672cca8 to your computer and use it in GitHub Desktop.
package sample;
import java.io.Serializable;
import org.infinispan.notifications.cachelistener.filter.*;
import org.infinispan.metadata.*;
@NamedFactory(name = "basic-filter-factory")
public class BasicKeyValueFilterFactory implements CacheEventFilterFactory {
@Override public CacheEventFilter<Integer, String> getFilter(final Object[] params) {
return new BasicKeyValueFilter(params);
}
static class BasicKeyValueFilter implements CacheEventFilter<Integer, String>, Serializable {
private final Object[] params;
public BasicKeyValueFilter(Object[] params) { this.params = params; }
@Override public boolean accept(Integer key, String oldValue, Metadata oldMetadata,
String newValue, Metadata newMetadata, EventType eventType) {
return !params[0].equals(key);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment