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 024import org.apache.commons.pool.impl.GenericObjectPool; 025 026 027/** 028 * A pool implementation for LdapConnection objects. 029 * 030 * This class is just a wrapper around the commons GenericObjectPool, and has 031 * a more meaningful name to represent the pool type. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class LdapConnectionPool extends GenericObjectPool 036{ 037 038 /** 039 * Instantiates a new LDAP connection pool. 040 * 041 * @param factory the LDAP connection factory 042 */ 043 public LdapConnectionPool( PoolableLdapConnectionFactory factory ) 044 { 045 super( factory ); 046 } 047 048 049 /** 050 * Gives a LdapConnection fetched from the pool. 051 * 052 * @return an LdapConnection object from pool 053 * @throws Exception if an error occurs while obtaining a connection from the factory 054 */ 055 public LdapNetworkConnection getConnection() throws Exception 056 { 057 return ( LdapNetworkConnection ) super.borrowObject(); 058 } 059 060 061 /** 062 * Places the given LdapConnection back in the pool. 063 * 064 * @param connection the LdapConnection to be released 065 * @throws Exception if an error occurs while releasing the connection 066 */ 067 public void releaseConnection( LdapNetworkConnection connection ) throws Exception 068 { 069 super.returnObject( connection ); 070 } 071 072}