Class FilteringObserver
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.observation.FilteringObserver
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Observer
public class FilteringObserver extends java.lang.Object implements Observer, java.io.Closeable
An observer that implements filtering of content changes while at the same time supporting (wrapping) a BackgroundObserver underneath.The FilteringObserver uses an explicit Filter to decide whether or not to forward a content change to the BackgroundObserver. If the Filter decides to include the change things happen as usual. If the Filter decides to exclude the change, this FilteringObserver does not forward the change, but remembers the fact that the last change was filtered. The first included change after excluded ones will cause a NOOP_CHANGE commitInfo to be passed along to the BackgroundObserver. That NOOP_CHANGE is then used by the FilteringDispatcher: if a CommitInfo is a NOOP_CHANGE then the FilteringDispatcher will not forward anything to the FilteringAwareObserver and only adjust the 'before' state accordingly (which it does also for a NOOP_CHANGE, to exactly achieve the skipping effect).
-
-
Constructor Summary
Constructors Constructor Description FilteringObserver(@NotNull java.util.concurrent.Executor executor, int queueLength, @NotNull Filter filter, @NotNull FilteringAwareObserver observer)
Default constructor which creates a BackgroundObserver automatically, including creating a FilteringDispatcher.FilteringObserver(@NotNull BackgroundObserver backgroundObserver, @NotNull Filter filter)
Alternative constructor where the BackgroundObserver is created elsewhere
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
contentChanged(@NotNull NodeState root, @NotNull CommitInfo info)
Observes a content change.BackgroundObserver
getBackgroundObserver()
-
-
-
Constructor Detail
-
FilteringObserver
public FilteringObserver(@NotNull @NotNull java.util.concurrent.Executor executor, int queueLength, @NotNull @NotNull Filter filter, @NotNull @NotNull FilteringAwareObserver observer)
Default constructor which creates a BackgroundObserver automatically, including creating a FilteringDispatcher.- Parameters:
executor
- the executor that should be used for the BackgroundObserverqueueLength
- the queue length of the BackgroundObserverfilter
- the Filter to be used for filteringobserver
- the FilteringAwareObserver to which content changes ultimately are delivered after going through a chain of FilteringObserver->BackgroundObserver->FilteringDispatcher.
-
FilteringObserver
public FilteringObserver(@NotNull @NotNull BackgroundObserver backgroundObserver, @NotNull @NotNull Filter filter)
Alternative constructor where the BackgroundObserver is created elsewhere- Parameters:
backgroundObserver
- the BackgroundObserver to be used by this FilteringObserverfilter
- the Filter to be used for filtering
-
-
Method Detail
-
getBackgroundObserver
public BackgroundObserver getBackgroundObserver()
-
contentChanged
public final void contentChanged(@NotNull @NotNull NodeState root, @NotNull @NotNull CommitInfo info)
Description copied from interface:Observer
Observes a content change. See theObserver
class javadocs and relevant repository and observer registration details for more information on when and how this method gets called.- Specified by:
contentChanged
in interfaceObserver
- Parameters:
root
- root state of the repositoryinfo
- commit information
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-