001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.event;
020
021/**
022 * Post-commit listener that can decide synchronously whether it's worth calling.
023 * <p>
024 * This is useful if there are quick decisions that can be made synchronously, and to avoid creating useless thread
025 * work.
026 *
027 * @since 5.6
028 */
029public interface PostCommitFilteringEventListener extends PostCommitEventListener {
030
031    /**
032     * Checks if this event is worth passing to the asynchronous {@link #handleEvent}.
033     * <p>
034     * Note that the event's documents are usually <strong>disconnected</strong> into
035     * {@link org.nuxeo.ecm.core.event.impl.ShallowDocumentModel ShallowDocumentModel} instances, which means that this
036     * method may not be able to get to all the information it would get from a standard DocumentModel implementation.
037     * If there is not enough information in the ShallowDocumentModel to decide whether this event is of interest, then
038     * this method should accept it an let the actual logic done in {@link #handleEvent} do the final filtering.
039     *
040     * @param event the event
041     * @return {@code true} to accept it, or {@code false} to ignore it
042     * @since 5.6
043     */
044    boolean acceptEvent(Event event);
045
046}