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 2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2011-2015 ForgeRock AS.
026 */
027
028package org.forgerock.opendj.ldap;
029
030import org.forgerock.util.promise.ExceptionHandler;
031import org.forgerock.util.promise.ResultHandler;
032
033/**
034 * A completion handler for consuming the result of an asynchronous operation or
035 * connection attempts.
036 * <p>
037 * A result completion handler may be specified when performing asynchronous
038 * operations using a {@link Connection} object or when connecting
039 * asynchronously to a remote Directory Server using an
040 * {@link ConnectionFactory}. The {@link #handleResult} method is invoked when
041 * the operation or connection attempt completes successfully. The
042 * {@link #handleException(LdapException)} method is invoked if the operation or connection
043 * attempt fails.
044 * <p>
045 * Implementations of these methods should complete in a timely manner so as to
046 * avoid keeping the invoking thread from dispatching to other completion
047 * handlers.
048 *
049 * @param <S>
050 *            The type of result handled by this result handler.
051 */
052public interface LdapResultHandler<S> extends ResultHandler<S>, ExceptionHandler<LdapException> {
053    /**
054     * Invoked when the asynchronous operation has failed.
055     *
056     * @param exception
057     *            The error result exception indicating why the asynchronous
058     *            operation has failed.
059     */
060    @Override
061    void handleException(LdapException exception);
062
063    /**
064     * Invoked when the asynchronous operation has completed successfully.
065     *
066     * @param result
067     *            The result of the asynchronous operation.
068     */
069    @Override
070    void handleResult(S result);
071}