|
From: <mwl...@us...> - 2009-01-22 16:57:02
|
Revision: 849
http://cishell.svn.sourceforge.net/cishell/?rev=849&view=rev
Author: mwlinnem
Date: 2009-01-22 16:56:57 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
Made DataSourceWithID into an interface, and moved the implementation to the reference plugin.
Modified Paths:
--------------
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java
trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java
Added Paths:
-----------
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DataSourceWithIDImpl.java
Copied: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DataSourceWithIDImpl.java (from rev 848, trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java)
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DataSourceWithIDImpl.java (rev 0)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DataSourceWithIDImpl.java 2009-01-22 16:56:57 UTC (rev 849)
@@ -0,0 +1,79 @@
+package org.cishell.reference.service.database;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.cishell.service.database.DataSourceWithID;
+
+public class DataSourceWithIDImpl implements DataSource, DataSourceWithID {
+ private static int idCounter = 0;
+
+ private DataSource wrappedDataSource;
+ private int id;
+
+ private static int generateNewID() {
+ int newID = idCounter;
+
+ idCounter++;
+
+ return newID;
+ }
+
+ public DataSourceWithIDImpl(DataSource wrappedDataSource) {
+ this.wrappedDataSource = wrappedDataSource;
+ this.id = generateNewID();
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#getID()
+ */
+ public int getID() {
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#getConnection()
+ */
+ public Connection getConnection() throws SQLException {
+ return this.wrappedDataSource.getConnection();
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#getConnection(java.lang.String, java.lang.String)
+ */
+ public Connection getConnection(String username, String password)
+ throws SQLException {
+ return this.wrappedDataSource.getConnection(username, password);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#getLogWriter()
+ */
+ public PrintWriter getLogWriter() throws SQLException {
+ return this.wrappedDataSource.getLogWriter();
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#setLogWriter(java.io.PrintWriter)
+ */
+ public void setLogWriter(PrintWriter out) throws SQLException {
+ this.wrappedDataSource.setLogWriter(out);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#getLoginTimeout()
+ */
+ public int getLoginTimeout() throws SQLException {
+ return this.wrappedDataSource.getLoginTimeout();
+ }
+
+ /* (non-Javadoc)
+ * @see org.cishell.service.database.DataSourceWithIDI#setLoginTimeout(int)
+ */
+ public void setLoginTimeout(int seconds) throws SQLException {
+ this.wrappedDataSource.setLoginTimeout(seconds);
+ }
+}
\ No newline at end of file
Property changes on: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DataSourceWithIDImpl.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java 2009-01-21 21:57:08 UTC (rev 848)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DatabaseServiceImpl.java 2009-01-22 16:56:57 UTC (rev 849)
@@ -33,6 +33,7 @@
/* TODO: Using a rolling counter like this may have bad implications later on,
but it's decent for now.
*/
+ //Not used for now
private static int dbNameCounter = 0;
private ServiceRegistration databaseServiceRegistration;
@@ -82,7 +83,7 @@
// Driver jdbcDriver = (Driver) Class.forName(driver).newInstance();
String newDatabaseName =
- DEFAULT_DB_NAME + Integer.toString(dbNameCounter);
+ DEFAULT_DB_NAME;
String newDatabaseConnectionURL = DEFAULT_PROTOCOL +
newDatabaseName +
DEFAULT_CREATE_CONNECTION_STRING;
@@ -131,6 +132,6 @@
}
public DataSourceWithID createDatabase() throws DatabaseCreationException {
- return new DataSourceWithID(getConnectionPool());
+ return new DataSourceWithIDImpl(getConnectionPool());
}
}
Modified: trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java
===================================================================
--- trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java 2009-01-21 21:57:08 UTC (rev 848)
+++ trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java 2009-01-22 16:56:57 UTC (rev 849)
@@ -1,56 +1,23 @@
-package org.cishell.service.database;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-public class DataSourceWithID implements DataSource {
- private static int idCounter = 0;
-
- private DataSource wrappedDataSource;
- private int id;
-
- private static int generateNewID() {
- int newID = idCounter;
-
- idCounter++;
-
- return newID;
- }
-
- public DataSourceWithID(DataSource wrappedDataSource) {
- this.wrappedDataSource = wrappedDataSource;
- this.id = generateNewID();
- }
-
- public int getID() {
- return id;
- }
-
- public Connection getConnection() throws SQLException {
- return this.wrappedDataSource.getConnection();
- }
-
- public Connection getConnection(String username, String password)
- throws SQLException {
- return this.wrappedDataSource.getConnection(username, password);
- }
-
- public PrintWriter getLogWriter() throws SQLException {
- return this.wrappedDataSource.getLogWriter();
- }
-
- public void setLogWriter(PrintWriter out) throws SQLException {
- this.wrappedDataSource.setLogWriter(out);
- }
-
- public int getLoginTimeout() throws SQLException {
- return this.wrappedDataSource.getLoginTimeout();
- }
-
- public void setLoginTimeout(int seconds) throws SQLException {
- this.wrappedDataSource.setLoginTimeout(seconds);
- }
+package org.cishell.service.database;
+
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface DataSourceWithID {
+
+ public abstract int getID();
+
+ public abstract Connection getConnection() throws SQLException;
+
+ public abstract Connection getConnection(String username, String password) throws SQLException;
+
+ public abstract PrintWriter getLogWriter() throws SQLException;
+
+ public abstract void setLogWriter(PrintWriter out) throws SQLException;
+
+ public abstract int getLoginTimeout() throws SQLException;
+
+ public abstract void setLoginTimeout(int seconds) throws SQLException;
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|