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