|
From: <mwl...@us...> - 2010-01-04 17:29:16
|
Revision: 1003
http://cishell.svn.sourceforge.net/cishell/?rev=1003&view=rev
Author: mwlinnem
Date: 2010-01-04 17:29:08 +0000 (Mon, 04 Jan 2010)
Log Message:
-----------
Modified to incorporate database-related constants into this service (before they were duplicated in various other areas).
Modified Paths:
--------------
trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/ExternalDatabase.java
trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/InternalDerbyDatabase.java
trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF
trunk/core/org.cishell.service.database/src/org/cishell/service/database/Database.java
Added Paths:
-----------
trunk/core/org.cishell.reference.service.database/.checkstyle
trunk/core/org.cishell.service.database/bin/
Removed Paths:
-------------
trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java
Added: trunk/core/org.cishell.reference.service.database/.checkstyle
===================================================================
--- trunk/core/org.cishell.reference.service.database/.checkstyle (rev 0)
+++ trunk/core/org.cishell.reference.service.database/.checkstyle 2010-01-04 17:29:08 UTC (rev 1003)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true">
+ <fileset name="all" enabled="true" check-config-name="CNS Checks (Eclipse)" local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
Modified: trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.reference.service.database/META-INF/MANIFEST.MF 2010-01-04 17:29:08 UTC (rev 1003)
@@ -3,7 +3,6 @@
Bundle-Name: Database Plug-in
Bundle-SymbolicName: org.cishell.reference.service.database
Bundle-Version: 1.0.0
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-Activator: org.cishell.reference.service.database.DerbyDatabaseService
X-AutoStart: true
Import-Package: org.apache.commons.dbcp,
@@ -20,3 +19,4 @@
org.osgi.service.log;version="1.3.0",
org.osgi.util.tracker;version="1.3.3"
Service-Component: OSGI-INF/component.xml
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/DerbyDatabaseService.java 2010-01-04 17:29:08 UTC (rev 1003)
@@ -89,8 +89,10 @@
try {
//connect to and create a 'new' database
String databaseName = INTERNAL_DB_NAME_PREFIX + id;
- InternalDerbyDatabase db = new InternalDerbyDatabase(createNewInternalDataSource(databaseName));
+ InternalDerbyDatabase db =
+ new InternalDerbyDatabase(createNewInternalDataSource(databaseName));
+
//if this database existed on disk from a previous session, clean it to be like new
removeAllNonSystemDatabaseTables(db.getConnection());
@@ -115,7 +117,8 @@
throws DatabaseCreationException {
DataSource dataSource =
createNewDataSource(driver, url, username, password);
- Database db = new ExternalDatabase(dataSource);
+ //TODO: See if we can get the default schema as a property somehow.
+ Database db = new ExternalDatabase(dataSource, "APP");
return db;
}
Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/ExternalDatabase.java
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/ExternalDatabase.java 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/ExternalDatabase.java 2010-01-04 17:29:08 UTC (rev 1003)
@@ -10,9 +10,11 @@
public class ExternalDatabase implements Database {
private DataSource dataSource;
+ private String schemaName;
- public ExternalDatabase(DataSource dataSource) {
+ public ExternalDatabase(DataSource dataSource, String schemaName) {
this.dataSource = dataSource;
+ this.schemaName = schemaName;
}
public Connection getConnection() throws SQLException {
@@ -27,4 +29,8 @@
throws SQLException {
return dataSource.getConnection(username, password);
}
+
+ public String getApplicationSchemaName() {
+ return schemaName;
+ }
}
Modified: trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/InternalDerbyDatabase.java
===================================================================
--- trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/InternalDerbyDatabase.java 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.reference.service.database/src/org/cishell/reference/service/database/InternalDerbyDatabase.java 2010-01-04 17:29:08 UTC (rev 1003)
@@ -27,4 +27,10 @@
+ DerbyDatabaseService.DEFAULT_SHUTDOWN_CONNECTION_STRING;
DriverManager.getConnection(shutdownDatabaseCommand);
}
+
+
+ //TODO: We might want to expose our different 'databases' as different schemas at some point instead.
+ public String getApplicationSchemaName() {
+ return "APP";
+ }
}
Modified: trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF
===================================================================
--- trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.service.database/META-INF/MANIFEST.MF 2010-01-04 17:29:08 UTC (rev 1003)
@@ -3,6 +3,6 @@
Bundle-Name: Database Plug-in
Bundle-SymbolicName: org.cishell.service.database
Bundle-Version: 1.0.0
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.cishell.service.database
Import-Package: org.apache.commons.dbcp
Deleted: 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-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.service.database/src/org/cishell/service/database/DataSourceWithID.java 2010-01-04 17:29:08 UTC (rev 1003)
@@ -1,25 +0,0 @@
-package org.cishell.service.database;
-
-import java.io.PrintWriter;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.sql.DataSource;
-
-public interface DataSourceWithID extends DataSource {
-
- 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
Modified: trunk/core/org.cishell.service.database/src/org/cishell/service/database/Database.java
===================================================================
--- trunk/core/org.cishell.service.database/src/org/cishell/service/database/Database.java 2009-12-30 20:55:04 UTC (rev 1002)
+++ trunk/core/org.cishell.service.database/src/org/cishell/service/database/Database.java 2010-01-04 17:29:08 UTC (rev 1003)
@@ -3,8 +3,18 @@
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.commons.dbcp.ConnectionFactory;
+
public interface Database {
+ public static final String DB_MIME_TYPE_PREFIX = "db:";
+ public static final String GENERIC_DB_MIME_TYPE = "db:any";
+
public Connection getConnection() throws SQLException;
+
+ /**
+ *
+ * @return the name of the schema where the non-system tables we are interested in reside.
+ */
+ public String getApplicationSchemaName();
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|