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 2011-2014 ForgeRock AS
025 */
026
027package org.forgerock.opendj.ldap;
028
029/**
030 * A handler interface for accepting new connections from clients.
031 *
032 * @param <C>
033 *            The type of client context.
034 * @param <R>
035 *            The type of request context.
036 */
037public interface RequestHandlerFactory<C, R extends RequestContext> {
038    /**
039     * Invoked when a new client connection is accepted by the associated
040     * listener. Implementations should return a {@code RequestHandler} which
041     * will be used to handle requests from the client connection.
042     *
043     * @param clientContext
044     *            The protocol dependent context information associated with the
045     *            client connection. Depending on the protocol this may contain
046     *            information about the client such as their address and level
047     *            connection security. It may also be used to manage the state
048     *            of the client's connection.
049     * @return A {@code RequestHandler} which will be used to handle requests
050     *         from a client connection.
051     * @throws LdapException
052     *             If this request handler factory cannot accept the client
053     *             connection.
054     */
055    RequestHandler<R> handleAccept(C clientContext) throws LdapException;
056}