01: /*
02: * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.jndi.ldap;
27:
28: import java.io.OutputStream;
29: import javax.naming.InterruptedNamingException;
30: import javax.naming.CommunicationException;
31: import javax.naming.NamingException;
32:
33: import com.sun.jndi.ldap.pool.PoolCallback;
34: import com.sun.jndi.ldap.pool.PooledConnection;
35: import 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: */
44: final 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, connTimeout,
65: readTimeout, trace, pcb);
66: }
67:
68: public String toString() {
69: return host + ":" + port;
70: }
71: }
|