01: // JdbcServerState.java
02: // $Id: JdbcServerState.java,v 1.6 2001/01/22 16:34:53 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.jdbc;
07:
08: import java.util.Vector;
09:
10: class JdbcServerState {
11: JdbcServer server = null;
12: Vector conns = null;
13:
14: private static final boolean debug = false;
15:
16: final JdbcServer getServer() {
17: return server;
18: }
19:
20: synchronized void registerConnection(JdbcConnection conn) {
21: if (conns == null) {
22: conns = new Vector(4);
23: }
24: conns.addElement(conn);
25: }
26:
27: synchronized void deleteConnection(JdbcConnection conn) {
28: if (conns != null) {
29: conns.removeElement(conn);
30: }
31: }
32:
33: synchronized void unregisterConnection(JdbcConnection conn) {
34: if (conns != null) {
35: conns.removeElement(conn);
36: }
37: }
38:
39: synchronized JdbcConnection getConnection() {
40: if ((conns != null) && (conns.size() > 0)) {
41: if (debug) {
42: System.out.println("+++ GetConnection out of "
43: + conns.size());
44: }
45: JdbcConnection conn = (JdbcConnection) conns.elementAt(0);
46: conns.removeElementAt(0);
47: return conn;
48: }
49: return null;
50: }
51:
52: JdbcServerState(JdbcServer server) {
53: this.server = server;
54:
55: }
56: }
|