KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > SocketFactory


1 /*
2    Copyright (C) 2002 MySQL AB
3
4       This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6       the Free Software Foundation; either version 2 of the License, or
7       (at your option) any later version.
8
9       This program is distributed in the hope that it will be useful,
10       but WITHOUT ANY WARRANTY; without even the implied warranty of
11       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12       GNU General Public License for more details.
13
14       You should have received a copy of the GNU General Public License
15       along with this program; if not, write to the Free Software
16       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18  */

19 package com.mysql.jdbc;
20
21 import java.io.IOException JavaDoc;
22
23 import java.net.Socket JavaDoc;
24 import java.net.SocketException JavaDoc;
25
26 import java.util.Properties JavaDoc;
27
28
29 /**
30  * Interface to allow pluggable socket creation in the driver
31  *
32  * @author Mark Matthews
33  */

34 public interface SocketFactory {
35     /**
36      * Called by the driver after issuing the MySQL protocol handshake and
37      * reading the results of the handshake.
38      *
39      * @throws SocketException if a socket error occurs
40      * @throws IOException if an I/O error occurs
41      *
42      * @return the socket to use after the handshake
43      */

44     Socket JavaDoc afterHandshake() throws SocketException JavaDoc, IOException JavaDoc;
45
46     /**
47      * Called by the driver before issuing the MySQL protocol handshake.
48      * Should return the socket instance that should be used during
49      * the handshake.
50      *
51      * @throws SocketException if a socket error occurs
52      * @throws IOException if an I/O error occurs
53      *
54      * @return the socket to use before the handshake
55      */

56     Socket JavaDoc beforeHandshake() throws SocketException JavaDoc, IOException JavaDoc;
57
58     /**
59      * Creates a new socket using the given properties. Properties are parsed
60      * by the driver from the URL. All properties other than sensitive ones
61      * (user and password) are passed to this method. The driver will
62      * instantiate the socket factory with the class name given in the
63      * property "socketFactory", where the standard is
64      * <code>com.mysql.jdbc.StandardSocketFactory</code> Implementing classes
65      * are responsible for handling synchronization of this method (if
66      * needed).
67      *
68      * @param host the hostname passed in the JDBC URL. It will be a single
69      * hostname, as the driver parses multi-hosts (for failover) and calls this
70      * method for each host connection attempt.
71      *
72      * @param props properties passed to the driver via the URL and/or properties
73      * instance.
74      *
75      * @return a socket connected to the given host
76      * @throws SocketException if a socket error occurs
77      * @throws IOException if an I/O error occurs
78      */

79     Socket JavaDoc connect(String JavaDoc host, Properties JavaDoc props)
80         throws SocketException JavaDoc, IOException JavaDoc;
81 }
82
Popular Tags