KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sql > ConnectionAllocator


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: ConnectionAllocator.java,v 1.1 2004/09/03 13:42:35 sinisa Exp $
22  */

23 package com.lutris.appserver.server.sql;
24
25 import java.util.Date JavaDoc;
26
27 /**
28  * Defines the connection allocator. A connection allocator is an integral
29  * part of a logical database implementation. It manages a pool of database
30  * connections.
31  *
32  * @author Paul Morgan
33  * @since LBS1.8
34  * @version $Revision: 1.1 $
35  */

36 public interface ConnectionAllocator {
37
38     /**
39      * Allocate a connection either from the managed pool or create a new.
40      *
41      * @exception java.sql.SQLException
42      * if a SQL error occures.
43      */

44     DBConnection allocate() throws java.sql.SQLException JavaDoc;
45
46     /**
47      * Return a connection to the pool. If it is of an old generation,
48      * close and drop.
49      *
50      * @param dbConnection The connection object to return.
51      */

52     void release(DBConnection dbConnection);
53
54     /**
55      * Used to drop a connection from the pool. The connection
56      * should not be re-allocated
57      *
58      * @param dbConnection
59      * The connection object to drop.
60      */

61     void drop(DBConnection dbConnection);
62     
63     /**
64      * Drop all the connection in the pool immediately.
65      */

66     void dropAllNow();
67
68     /**
69      * Return the number of currently active (allocated) connections.
70      *
71      * @return The number of connections.
72      */

73     public int getActiveCount();
74
75     /**
76      * Return the maximum number of connections active at one time.
77      *
78      * @return The number of connections.
79      */

80     public int getMaxCount();
81
82     /**
83      * Return the time when the maximum connection count occured.
84      *
85      * @return The <CODE>Date</CODE> when the maximum connection
86      * count occured.
87      */

88     public Date JavaDoc getMaxCountDate();
89
90     /**
91      * Reset the maximum connection count and date.
92      */

93     public void resetMaxCount();
94
95     /**
96      * Return the number of database requests made on any of the
97      * connection allocated from this managed pool. Implementations
98      * of the connection allocator must provide a mechanism for
99      * <CODE>DBQuery</CODE> and <CODE>DBTransaction</CODE> objects
100      * to count requests.
101      *
102      * @return The number of database requests (queries or transactions).
103      */

104     public long getRequestCount();
105     
106     /**
107      * @return database name of current connection
108      *
109      */

110     public String JavaDoc getDatabaseName();
111     
112 }
113
Popular Tags