001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2010 Sun Microsystems, Inc.
025 *      Portions copyright 2011 ForgeRock AS.
026 */
027
028package org.forgerock.opendj.ldap;
029
030import org.forgerock.opendj.ldap.responses.IntermediateResponse;
031
032/**
033 * A completion handler for consuming intermediate responses returned from
034 * extended operations, or other operations for which an appropriate control was
035 * sent.
036 * <p>
037 * Intermediate responses are rarely used in practice and are therefore only
038 * supported in a few specialized cases where they are most likely to be
039 * encountered:
040 * <ul>
041 * <li>when performing extended requests using the
042 * {@link Connection#extendedRequest} methods
043 * <li>when using the asynchronous operation methods, such as
044 * {@link Connection#addAsync}
045 * </ul>
046 * When no handler is provided any intermediate responses will be discarded.
047 * <p>
048 * The {@link #handleIntermediateResponse} method is invoked each time a
049 * Intermediate Response is returned from the Directory Server.
050 * <p>
051 * Implementations of these methods should complete in a timely manner so as to
052 * avoid keeping the invoking thread from dispatching to other completion
053 * handlers.
054 */
055public interface IntermediateResponseHandler {
056    /**
057     * Invoked each time an intermediate response is returned from the Directory
058     * Server.
059     *
060     * @param response
061     *            The intermediate response.
062     * @return {@code true} if this handler should continue to be notified of
063     *         any remaining intermediate responses, or {@code false} if the
064     *         remaining responses should be skipped for some reason (e.g. a
065     *         client side size limit has been reached).
066     */
067    boolean handleIntermediateResponse(IntermediateResponse response);
068}