001/*
002 *   Licensed to the Apache Software Foundation (ASF) under one
003 *   or more contributor license agreements.  See the NOTICE file
004 *   distributed with this work for additional information
005 *   regarding copyright ownership.  The ASF licenses this file
006 *   to you under the Apache License, Version 2.0 (the
007 *   "License"); you may not use this file except in compliance
008 *   with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *   Unless required by applicable law or agreed to in writing,
013 *   software distributed under the License is distributed on an
014 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *   KIND, either express or implied.  See the License for the
016 *   specific language governing permissions and limitations
017 *   under the License.
018 *
019 */
020
021package org.apache.directory.ldap.client.api;
022
023
024
025
026/**
027 * A factory for creating LdapConnection objects managed by LdapConnectionPool. The connections are
028 * not validated when they are pulled from the pool : we just check if they are still connected, using
029 * their internal flag. We don't either re-bind when we push back the connection into the pool.
030 * <br>
031 * It's up to the users to be careful with the way they deal with connections -especially when using
032 * the StartTLS extended operation -.
033 * 
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 */
036public class DefaultPoolableLdapConnectionFactory extends AbstractPoolableLdapConnectionFactory
037{
038    /**
039     * Creates a new instance of PoolableLdapConnectionFactory.
040     *
041     * @param config the configuration for creating LdapConnections
042     */
043    public DefaultPoolableLdapConnectionFactory( LdapConnectionConfig config )
044    {
045        this( new DefaultLdapConnectionFactory( config ) );
046    }
047    
048    
049    /**
050     * Creates a new instance of PoolableLdapConnectionFactory using an instance
051     * of the supplied class as its LdapConnection factory.
052     *
053     * @param config the configuration for creating LdapConnections
054     * @param connectionFactoryClass the class used as a factory for connections
055     */
056    public DefaultPoolableLdapConnectionFactory( LdapConnectionConfig config,
057        Class<? extends LdapConnectionFactory> connectionFactoryClass )
058    {
059        this( newLdapConnectionFactory( config, connectionFactoryClass ) );
060    }
061
062
063    /**
064     * Creates a new instance of PoolableLdapConnectionFactory.
065     *
066     * @param connectionFactory the connection factory for creating LdapConnections
067     */
068    public DefaultPoolableLdapConnectionFactory( LdapConnectionFactory connectionFactory )
069    {
070        this.connectionFactory = connectionFactory;
071    }
072}