001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: LogicalDatabase.java,v 1.1 2007-01-24 16:59:09 sinisa Exp $
022: */
023: package com.lutris.appserver.server.sql;
024:
025: import java.sql.SQLException;
026: import java.util.Date;
027: import com.lutris.util.Config;
028: import com.lutris.util.ConfigException;
029:
030: /**
031: * Interface for a logical database. Each logical database must
032: * provide services for connection and object id allocation.
033: *
034: * @author Paul Morgan
035: * @since LBS1.8
036: * @version $Revision: 1.1 $
037: */
038: public interface LogicalDatabase {
039:
040: /**
041: * Initialize the logical database.
042: *
043: * @exception ConfigException
044: * if there is an error in the configuration.
045: * @exception SQLException
046: * if a SQL error occurs.
047: */
048: public void init(String dbName, Config dbConfig)
049: throws ConfigException, SQLException;
050:
051: /**
052: * Return a connection to this logical database.
053: *
054: * @return The connection.
055: * @exception SQLException
056: * if a SQL error occurs.
057: */
058: public DBConnection allocateConnection() throws SQLException;
059:
060: /**
061: * Return an object id for this logical database.
062: *
063: * @return The object id.
064: * @exception ObjectIdException
065: * if an object id cannot be allocated.
066: */
067: public ObjectId allocateObjectId() throws ObjectIdException;
068:
069: /**
070: * Check does oid belong to Object id's range [minOId, currentOId]
071: *
072: * @param oid
073: * oid which will be checked.
074: * @exception ObjectIdException
075: * If a oid does't belong to range.
076: */
077: public void checkOId(ObjectId oid) throws ObjectIdException;
078:
079: /**
080: * Return a transaction for use on this logical database.
081: *
082: * @return The transaction object.
083: * @exception SQLException
084: * if a SQL error occurs.
085: */
086: public DBTransaction createTransaction() throws SQLException;
087:
088: /**
089: * Return a query for use on this logical database.
090: *
091: * @return The query object.
092: * @exception SQLException
093: * if a SQL error occurs.
094: */
095: public DBQuery createQuery() throws SQLException;
096:
097: /**
098: * Immediately shutdown the logical database. All connections
099: * should be closed and any other cleanup performed.
100: */
101: public void shutdown();
102:
103: // ===================================================================
104: // The following are primaryily for management purposes...
105: // ===================================================================
106: /**
107: * Return the symbolic name of this logical database.
108: *
109: * @return The symbolic name.
110: */
111: public String getName();
112:
113: /**
114: * Return a description of the logical database type.
115: *
116: * @return The type.
117: */
118: public String getType();
119:
120: /**
121: * Return the number of currently active connections.
122: *
123: * @return The number of connections.
124: */
125: public int getActiveConnectionCount();
126:
127: /**
128: * Return the maximum number of connections active at one time.
129: *
130: * @return The number of connections.
131: */
132: public int getMaxConnectionCount();
133:
134: /**
135: * Return the time when the maximum connection count occured.
136: *
137: * @return The <CODE>Date</CODE> when the maximum connection
138: * count occured.
139: */
140: public Date getMaxConnectionCountDate();
141:
142: /**
143: * Reset the maximum connection count and date.
144: */
145: public void resetMaxConnectionCount();
146:
147: /**
148: * Return the number of database requests.
149: *
150: * @return The number of database requests (queries or transactions).
151: */
152: public long getRequestCount();
153: }
|