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