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.IOException;
029import java.net.InetSocketAddress;
030
031import org.forgerock.opendj.ldap.LDAPClientContext;
032import org.forgerock.opendj.ldap.ServerConnectionFactory;
033import org.forgerock.util.Options;
034
035/**
036 * Interface for transport providers, which provide implementation
037 * for {@code LDAPConnectionFactory} and {@code LDAPListener} classes,
038 * using a specific transport.
039 * <p>
040 * A transport provider must be declared in the provider-configuration file
041 * {@code META-INF/services/org.forgerock.opendj.ldap.spi.TransportProvider}
042 * in order to allow automatic loading of the implementation classes using the
043 * {@code java.util.ServiceLoader} facility.
044 */
045public interface TransportProvider extends Provider {
046
047    /**
048     * Returns an implementation of {@code LDAPConnectionFactory}. The address
049     * will be resolved each time a new connection is returned.
050     *
051     * @param host
052     *            The hostname of the Directory Server to connect to.
053     * @param port
054     *            The port number of the Directory Server to connect to.
055     * @param options
056     *            The LDAP options to use when creating connections.
057     * @return an implementation of {@code LDAPConnectionFactory}
058     */
059    LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, Options options);
060
061  /**
062     * Returns an implementation of {@code LDAPListener}.
063     *
064     * @param address
065     *            The address to listen on.
066     * @param factory
067     *            The server connection factory which will be used to create
068     *            server connections.
069     * @param options
070     *            The LDAP listener options.
071     * @return an implementation of {@code LDAPListener}
072     * @throws IOException
073     *             If an error occurred while trying to listen on the provided
074     *             address.
075     */
076    LDAPListenerImpl getLDAPListener(InetSocketAddress address,
077            ServerConnectionFactory<LDAPClientContext, Integer> factory, Options options)
078            throws IOException;
079
080}