01: /*
02: Copyright (C) 2002-2004 MySQL AB
03:
04: This program is free software; you can redistribute it and/or modify
05: it under the terms of version 2 of the GNU General Public License as
06: published by the Free Software Foundation.
07:
08: There are special exceptions to the terms and conditions of the GPL
09: as it is applied to this software. View the full text of the
10: exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
11: software distribution.
12:
13: This program is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: GNU General Public License for more details.
17:
18: You should have received a copy of the GNU General Public License
19: along with this program; if not, write to the Free Software
20: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21:
22:
23:
24: */
25: package com.mysql.jdbc;
26:
27: import java.io.IOException;
28:
29: import java.net.Socket;
30: import java.net.SocketException;
31:
32: import java.util.Properties;
33:
34: /**
35: * Interface to allow pluggable socket creation in the driver
36: *
37: * @author Mark Matthews
38: */
39: public interface SocketFactory {
40: // ~ Methods
41: // ----------------------------------------------------------------
42:
43: /**
44: * Called by the driver after issuing the MySQL protocol handshake and
45: * reading the results of the handshake.
46: *
47: * @throws SocketException
48: * if a socket error occurs
49: * @throws IOException
50: * if an I/O error occurs
51: *
52: * @return the socket to use after the handshake
53: */
54: Socket afterHandshake() throws SocketException, IOException;
55:
56: /**
57: * Called by the driver before issuing the MySQL protocol handshake. Should
58: * return the socket instance that should be used during the handshake.
59: *
60: * @throws SocketException
61: * if a socket error occurs
62: * @throws IOException
63: * if an I/O error occurs
64: *
65: * @return the socket to use before the handshake
66: */
67: Socket beforeHandshake() throws SocketException, IOException;
68:
69: /**
70: * Creates a new socket using the given properties. Properties are parsed by
71: * the driver from the URL. All properties other than sensitive ones (user
72: * and password) are passed to this method. The driver will instantiate the
73: * socket factory with the class name given in the property
74: * "socketFactory", where the standard is
75: * <code>com.mysql.jdbc.StandardSocketFactory</code> Implementing classes
76: * are responsible for handling synchronization of this method (if needed).
77: *
78: * @param host
79: * the hostname passed in the JDBC URL. It will be a single
80: * hostname, as the driver parses multi-hosts (for failover) and
81: * calls this method for each host connection attempt.
82: *
83: * @param portNumber
84: * the port number to connect to (if required).
85: *
86: * @param props
87: * properties passed to the driver via the URL and/or properties
88: * instance.
89: *
90: * @return a socket connected to the given host
91: * @throws SocketException
92: * if a socket error occurs
93: * @throws IOException
94: * if an I/O error occurs
95: */
96: Socket connect(String host, int portNumber, Properties props)
97: throws SocketException, IOException;
98: }
|