1/* 2 * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.jndi.ldap; 27 28import java.io.OutputStream; 29import javax.naming.InterruptedNamingException; 30import javax.naming.CommunicationException; 31import javax.naming.NamingException; 32 33import com.sun.jndi.ldap.pool.PoolCallback; 34import com.sun.jndi.ldap.pool.PooledConnection; 35import com.sun.jndi.ldap.pool.PooledConnectionFactory; 36 37/** 38 * Creates an LdapClient. Encapsulates the parameters required to create 39 * an LdapClient and provides methods for returning appropriate exceptions 40 * to throw when acquiring a pooled LdapClient fails. 41 * 42 * @author Rosanna Lee 43 */ 44final class LdapClientFactory implements PooledConnectionFactory { 45 final private String host; 46 final private int port; 47 final private String socketFactory; 48 final private int connTimeout; 49 final private int readTimeout; 50 final private OutputStream trace; 51 52 LdapClientFactory(String host, int port, String socketFactory, 53 int connTimeout, int readTimeout, OutputStream trace) { 54 this.host = host; 55 this.port = port; 56 this.socketFactory = socketFactory; 57 this.connTimeout = connTimeout; 58 this.readTimeout = readTimeout; 59 this.trace = trace; 60 } 61 62 public PooledConnection createPooledConnection(PoolCallback pcb) 63 throws NamingException { 64 return new LdapClient(host, port, socketFactory, 65 connTimeout, readTimeout, trace, pcb); 66 } 67 68 public String toString() { 69 return host + ":" + port; 70 } 71} 72