Search in sources :

Example 1 with FilteringAwareObserver

use of org.apache.jackrabbit.oak.plugins.observation.FilteringAwareObserver in project jackrabbit-oak by apache.

the class PrefilteringBackgroundObserverTest method init.

public void init(int queueLength) throws Exception {
    runnableQ = new LinkedList<Runnable>();
    executor = new EnqueuingExecutorService(runnableQ);
    compositeObserver = new CompositeObserver();
    received = new LinkedList<ContentChanged>();
    filteringObserver = new FilteringObserver(executor, queueLength, new Filter() {

        @Override
        public boolean excludes(NodeState root, CommitInfo info) {
            if (info == includingCommitInfo) {
                return false;
            } else if (info == excludingCommitInfo) {
                return true;
            } else if (info.isExternal()) {
                return false;
            }
            throw new IllegalStateException("only supporting include or exclude");
        }
    }, new FilteringAwareObserver() {

        NodeState previous;

        @Override
        public void contentChanged(NodeState before, NodeState after, CommitInfo info) {
            received.add(new ContentChanged(after, info));
            if (previous != null && previous != before) {
                resetCallCnt++;
            }
            previous = after;
        }
    });
    compositeObserver.addObserver(filteringObserver);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) FilteringAwareObserver(org.apache.jackrabbit.oak.plugins.observation.FilteringAwareObserver) Filter(org.apache.jackrabbit.oak.plugins.observation.Filter) FilteringObserver(org.apache.jackrabbit.oak.plugins.observation.FilteringObserver)

Aggregations

Filter (org.apache.jackrabbit.oak.plugins.observation.Filter)1 FilteringAwareObserver (org.apache.jackrabbit.oak.plugins.observation.FilteringAwareObserver)1 FilteringObserver (org.apache.jackrabbit.oak.plugins.observation.FilteringObserver)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1