KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > jdbcserver > ServerConnection


1 /**
2  * com.mckoi.database.jdbcserver.ServerConnection 21 Jul 2000
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database.jdbcserver;
26
27 import com.mckoi.database.Database;
28 import com.mckoi.database.User;
29 import java.io.IOException JavaDoc;
30
31 /**
32  * A server side connection with a client. Each client that is connected
33  * to the database has a ServerConnection object.
34  *
35  * @author Tobias Downer
36  */

37
38 interface ServerConnection {
39
40   /**
41    * This should return true if it has been determined that there is an
42    * entire command waiting to be serviced on this connection. This method
43    * is always run on the same thread for all connections. It is called
44    * many times a second by the connection pool server so it must execute
45    * extremely fast.
46    * <p>
47    * ISSUE: Method is polled! Unfortunately can't get around this because
48    * of the limitation in Java that TCP connections must block on a thread,
49    * and we can't block if we are to be servicing 100+ connections.
50    */

51   boolean requestPending() throws IOException JavaDoc;
52
53   /**
54    * Processes a pending command on the connection. This method is called
55    * from a database worker thread. The method will block until a request
56    * has been received and processed. Note, it is not desirable is some
57    * cases to allow this method to block. If a call to 'requestPending'
58    * returns true then then method is guarenteed not to block.
59    * <p>
60    * The first call to this method will handle the hand shaking protocol
61    * between the client and server.
62    * <p>
63    * While this method is doing something, it can not be called again even
64    * if another request arrives from the client. All calls to this method
65    * are sequential. This method will only be called if the 'ping' method is
66    * not currently being processed.
67    */

68   void processRequest() throws IOException JavaDoc;
69
70   /**
71    * Blocks until a complete command is available to be processed. This is
72    * used for a blocking implementation. As soon as this method returns then
73    * a call to 'processRequest' will process the incoming command.
74    */

75   void blockForRequest() throws IOException JavaDoc;
76
77   /**
78    * Pings the connection. This is used to determine if the connection is
79    * alive or not. If it's not, we should throw an IOException.
80    * <p>
81    * This method will only be called if the 'processRequest' method is not
82    * being processed.
83    */

84   void ping() throws IOException JavaDoc;
85
86   /**
87    * Closes this connection.
88    */

89   void close() throws IOException JavaDoc;
90
91
92 }
93
Popular Tags