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 2013-2015 ForgeRock AS. 025 */ 026package org.forgerock.opendj.ldap.spi; 027 028import java.io.Closeable; 029import java.net.InetSocketAddress; 030 031import org.forgerock.opendj.ldap.LdapException; 032import org.forgerock.util.promise.Promise; 033 034/** 035 * Interface for all classes that implement {@code LDAPConnectionFactory}. 036 * <p> 037 * An implementation class is provided by a {@code TransportProvider}. 038 * <p> 039 * The implementation can be automatically loaded using the 040 * {@code java.util.ServiceLoader} facility if its provider extending 041 * {@code TransportProvider} is declared in the provider-configuration file 042 * {@code META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider}. 043 */ 044public interface LDAPConnectionFactoryImpl extends Closeable { 045 046 /** 047 * Returns the address used by the connections created by this factory. 048 * 049 * @return The address used by the connections. 050 */ 051 InetSocketAddress getSocketAddress(); 052 053 /** 054 * Returns the hostname used by the connections created by this factory. 055 * 056 * @return The hostname used by the connections. 057 */ 058 String getHostName(); 059 060 /** 061 * Returns the remote port number used by the connections created by this factory. 062 * 063 * @return The remote port number used by the connections. 064 */ 065 int getPort(); 066 067 /** 068 * Releases any resources associated with this connection factory implementation. 069 */ 070 @Override 071 void close(); 072 073 /** 074 * Asynchronously obtains a connection to the Directory Server associated 075 * with this connection factory. The returned {@code Promise} can be used to 076 * retrieve the completed connection. 077 * 078 * @return A promise which can be used to retrieve the connection. 079 */ 080 Promise<LDAPConnectionImpl, LdapException> getConnectionAsync(); 081}