public class FilteringObserver extends java.lang.Object implements Observer, java.io.Closeable
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 and Description |
---|
FilteringObserver(@NotNull BackgroundObserver backgroundObserver,
@NotNull Filter filter)
Alternative constructor where the BackgroundObserver is created elsewhere
|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
contentChanged(@NotNull NodeState root,
@NotNull CommitInfo info)
Observes a content change.
|
BackgroundObserver |
getBackgroundObserver() |
public FilteringObserver(@NotNull @NotNull java.util.concurrent.Executor executor, int queueLength, @NotNull @NotNull Filter filter, @NotNull @NotNull FilteringAwareObserver observer)
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.public FilteringObserver(@NotNull @NotNull BackgroundObserver backgroundObserver, @NotNull @NotNull Filter filter)
backgroundObserver
- the BackgroundObserver to be used by this FilteringObserverfilter
- the Filter to be used for filteringpublic BackgroundObserver getBackgroundObserver()
public final void contentChanged(@NotNull @NotNull NodeState root, @NotNull @NotNull CommitInfo info)
Observer
Observer
class javadocs
and relevant repository and observer registration details for more
information on when and how this method gets called.contentChanged
in interface Observer
root
- root state of the repositoryinfo
- commit informationpublic void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
Copyright © 2010 - 2020 Adobe. All Rights Reserved