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