KickJava   Java API By Example, From Geeks To Geeks.

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


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: LogicalDatabase.java,v 1.1 2004/09/03 13:42:37 sinisa Exp $
22  */

23 package com.lutris.appserver.server.sql;
24
25 import java.sql.SQLException JavaDoc;
26 import java.util.Date JavaDoc;
27 import com.lutris.util.Config;
28 import com.lutris.util.ConfigException;
29
30 /**
31  * Interface for a logical database. Each logical database must
32  * provide services for connection and object id allocation.
33  *
34  * @author Paul Morgan
35  * @since LBS1.8
36  * @version $Revision: 1.1 $
37  */

38 public interface LogicalDatabase {
39
40     /**
41      * Initialize the logical database.
42      *
43      * @exception ConfigException
44      * if there is an error in the configuration.
45      * @exception SQLException
46      * if a SQL error occurs.
47      */

48     public void init(String JavaDoc dbName, Config dbConfig)
49         throws ConfigException, SQLException JavaDoc;
50
51     /**
52      * Return a connection to this logical database.
53      *
54      * @return The connection.
55      * @exception SQLException
56      * if a SQL error occurs.
57      */

58     public DBConnection allocateConnection()
59         throws SQLException JavaDoc;
60
61     /**
62      * Return an object id for this logical database.
63      *
64      * @return The object id.
65      * @exception ObjectIdException
66      * if an object id cannot be allocated.
67      */

68     public ObjectId allocateObjectId()
69         throws ObjectIdException;
70
71     /**
72      * Check does oid belong to Object id's range [minOId, currentOId]
73      *
74      * @param oid
75      * oid which will be checked.
76      * @exception ObjectIdException
77      * If a oid does't belong to range.
78      */

79     public void checkOId(ObjectId oid) throws ObjectIdException;
80
81     /**
82      * Return a transaction for use on this logical database.
83      *
84      * @return The transaction object.
85      * @exception SQLException
86      * if a SQL error occurs.
87      */

88     public DBTransaction createTransaction()
89         throws SQLException JavaDoc;
90
91     /**
92      * Return a query for use on this logical database.
93      *
94      * @return The query object.
95      * @exception SQLException
96      * if a SQL error occurs.
97      */

98     public DBQuery createQuery()
99         throws SQLException JavaDoc;
100
101     /**
102      * Immediately shutdown the logical database. All connections
103      * should be closed and any other cleanup performed.
104      */

105     public void shutdown();
106     
107     // ===================================================================
108
// The following are primaryily for management purposes...
109
// ===================================================================
110
/**
111      * Return the symbolic name of this logical database.
112      *
113      * @return The symbolic name.
114      */

115     public String JavaDoc getName();
116
117     /**
118      * Return a description of the logical database type.
119      *
120      * @return The type.
121      */

122     public String JavaDoc getType();
123
124     /**
125      * Return the number of currently active connections.
126      *
127      * @return The number of connections.
128      */

129     public int getActiveConnectionCount();
130
131     /**
132      * Return the maximum number of connections active at one time.
133      *
134      * @return The number of connections.
135      */

136     public int getMaxConnectionCount();
137
138     /**
139      * Return the time when the maximum connection count occured.
140      *
141      * @return The <CODE>Date</CODE> when the maximum connection
142      * count occured.
143      */

144     public Date JavaDoc getMaxConnectionCountDate();
145
146     /**
147      * Reset the maximum connection count and date.
148      */

149     public void resetMaxConnectionCount();
150
151     /**
152      * Return the number of database requests.
153      *
154      * @return The number of database requests (queries or transactions).
155      */

156     public long getRequestCount();
157 }
158
Popular Tags