001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2010 Sun Microsystems, Inc.
015 * Portions copyright 2012-2016 ForgeRock AS.
016 */
017
018package org.forgerock.opendj.ldap;
019
020import org.forgerock.opendj.ldap.requests.AbandonRequest;
021import org.forgerock.opendj.ldap.requests.UnbindRequest;
022
023/**
024 * A handler interface for interacting with client connections. A
025 * {@code ServerConnection} is associated with a client connection when the
026 * {@link ServerConnectionFactory#handleAccept(Object) handleAccept} method is
027 * invoked against a {@code ServerConnectionFactory}.
028 * <p>
029 * Implementations are responsible for handling connection life-cycle as well as
030 * request life-cycle. In particular, a {@code ServerConnection} is responsible
031 * for processing abandon and unbind requests, as well as extended operations
032 * such as {@code StartTLS} and {@code Cancel} operations.
033 *
034 * @param <C>
035 *            The type of request context.
036 * @see ServerConnectionFactory
037 * @deprecated will be removed as part of OPENDJ-3467.
038 *             It has been replaced by {@code ReactiveHandler<>}
039 */
040@Deprecated
041public interface ServerConnection<C> extends RequestHandler<C> {
042
043    /**
044     * Invoked when an abandon request is received from a client.
045     *
046     * @param requestContext
047     *            The request context.
048     * @param request
049     *            The abandon request.
050     * @throws UnsupportedOperationException
051     *             If this server connection does not handle abandon requests.
052     */
053    void handleAbandon(C requestContext, AbandonRequest request);
054
055    /**
056     * Invoked when the client closes the connection, possibly using an unbind
057     * request.
058     *
059     * @param requestContext
060     *            The request context which should be ignored if there was no
061     *            associated unbind request.
062     * @param request
063     *            The unbind request, which may be {@code null} if one was not
064     *            sent before the connection was closed.
065     */
066    void handleConnectionClosed(C requestContext, UnbindRequest request);
067
068    /**
069     * Invoked when the server disconnects the client connection, possibly using
070     * a disconnect notification.
071     *
072     * @param resultCode
073     *            The result code which was included with the disconnect
074     *            notification, or {@code null} if no disconnect notification
075     *            was sent.
076     * @param message
077     *            The diagnostic message, which may be empty or {@code null}
078     *            indicating that none was provided.
079     */
080    void handleConnectionDisconnected(ResultCode resultCode, String message);
081
082    /**
083     * Invoked when an error occurs on the connection and it is no longer
084     * usable.
085     *
086     * @param error
087     *            The exception describing the problem that occurred.
088     */
089    void handleConnectionError(Throwable error);
090
091}