summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-21 11:40:47 (EDT)
committerEike Stepper2007-08-21 11:40:47 (EDT)
commit0d0a4c5209df8b49af87ca19152af28665e7d3bf (patch)
treea1ccd352814c6213e441b41d334cc0b3868f0155
parent1e53502d2911a1e74ded37ddf6c37e87d16046bc (diff)
downloadcdo-0d0a4c5209df8b49af87ca19152af28665e7d3bf.zip
cdo-0d0a4c5209df8b49af87ca19152af28665e7d3bf.tar.gz
cdo-0d0a4c5209df8b49af87ca19152af28665e7d3bf.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ConnectionProvider.java21
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java19
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DataSourceConnectionProvider.java49
6 files changed, 92 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index dc15fff..f444277 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -25,6 +25,8 @@ import java.util.Collection;
*/
public interface IStoreReader extends IStoreAccessor
{
+ public ISession getSession();
+
public Collection<CDOPackageInfo> readPackageInfos();
/**
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ConnectionProvider.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ConnectionProvider.java
new file mode 100644
index 0000000..bf711e5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ConnectionProvider.java
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.db;
+
+import java.sql.Connection;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ConnectionProvider
+{
+ public Connection getConnection() throws DBException;
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index bae9e34..81cb83a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -11,6 +11,7 @@
package org.eclipse.net4j.db;
import org.eclipse.net4j.internal.db.DBSchema;
+import org.eclipse.net4j.internal.db.DataSourceConnectionProvider;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ReflectUtil;
@@ -63,6 +64,11 @@ public final class DBUtil
}
}
+ public static ConnectionProvider createConnectionProvider(DataSource dataSource)
+ {
+ return new DataSourceConnectionProvider(dataSource);
+ }
+
public static IDBAdapter getDBAdapter(String adapterName)
{
return IDBAdapter.REGISTRY.get(adapterName);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
index 0dc8227..bfd606f 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
@@ -25,7 +25,9 @@ public interface IDBSchema extends IDBElement
public IDBTable[] getTables();
- public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException;
-
public void create(IDBAdapter dbAdapter, Connection connection) throws DBException;
+
+ public void create(IDBAdapter dbAdapter, ConnectionProvider connectionProvider) throws DBException;
+
+ public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException;
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
index cb2e9a8..f0f9d8b 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.db;
+import org.eclipse.net4j.db.ConnectionProvider;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
@@ -18,7 +19,6 @@ import org.eclipse.net4j.db.IDBSchema;
import javax.sql.DataSource;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
@@ -86,28 +86,29 @@ public class DBSchema extends DBElement implements IDBSchema
return locked = true;
}
- public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
+ public void create(IDBAdapter dbAdapter, Connection connection) throws DBException
+ {
+ dbAdapter.createTables(tables.values(), connection);
+ }
+
+ public void create(IDBAdapter dbAdapter, ConnectionProvider connectionProvider) throws DBException
{
Connection connection = null;
try
{
- connection = dataSource.getConnection();
+ connection = connectionProvider.getConnection();
create(dbAdapter, connection);
}
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
finally
{
DBUtil.close(connection);
}
}
- public void create(IDBAdapter dbAdapter, Connection connection) throws DBException
+ public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
{
- dbAdapter.createTables(tables.values(), connection);
+ create(dbAdapter, DBUtil.createConnectionProvider(dataSource));
}
void assertUnlocked() throws DBException
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DataSourceConnectionProvider.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DataSourceConnectionProvider.java
new file mode 100644
index 0000000..428f486
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DataSourceConnectionProvider.java
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.internal.db;
+
+import org.eclipse.net4j.db.ConnectionProvider;
+import org.eclipse.net4j.db.DBException;
+
+import javax.sql.DataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DataSourceConnectionProvider implements ConnectionProvider
+{
+ private DataSource dataSource;
+
+ public DataSourceConnectionProvider(DataSource dataSource)
+ {
+ this.dataSource = dataSource;
+ }
+
+ public DataSource getDataSource()
+ {
+ return dataSource;
+ }
+
+ public Connection getConnection()
+ {
+ try
+ {
+ return dataSource.getConnection();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+}