Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-07 05:22:43 -0500
committerEike Stepper2013-03-07 08:45:09 -0500
commitc24c0fbffac8c9c51ff49172b1104fbd8b6b460e (patch)
treecef05b9c760960f2a7069b232356347fdcb6661f
parentfec13815dd6c0d3cb112cf93d06b1734a898f452 (diff)
downloadcdo-c24c0fbffac8c9c51ff49172b1104fbd8b6b460e.tar.gz
cdo-c24c0fbffac8c9c51ff49172b1104fbd8b6b460e.tar.xz
cdo-c24c0fbffac8c9c51ff49172b1104fbd8b6b460e.zip
[401763] Make CDO Server more robust against data dictionary changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java2
4 files changed, 18 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
index 2a6928f2ee..696b72625f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
@@ -99,7 +99,7 @@ public final class CDODBUtil
DBStore store = new DBStore();
store.setMappingStrategy(mappingStrategy);
store.setDBAdapter(dbAdapter);
- store.setDbConnectionProvider(dbConnectionProvider);
+ store.setDBConnectionProvider(dbConnectionProvider);
store.setProperties(properties);
return store;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
index b779c3f49f..6937fe240d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.ddl.IDBSchema;
import java.sql.Connection;
@@ -49,7 +50,7 @@ public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClient
/**
* @since 4.2
*/
- // public IDBDatabase getDatabase();
+ public IDBDatabase getDatabase();
public IDBAdapter getDBAdapter();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 626d4d7cb9..38245e4917 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -42,16 +42,16 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.db.ddl.delta.IDBDelta;
import org.eclipse.net4j.spi.db.DBSchema;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.ProgressDistributor;
-import javax.sql.DataSource;
-
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -115,9 +115,7 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
private IMappingStrategy mappingStrategy;
- // private IDBDatabase database;
-
- private IDBSchema dbSchema;
+ private IDBDatabase database;
private IDBAdapter dbAdapter;
@@ -197,6 +195,11 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
return idHandler;
}
+ public IDBDatabase getDatabase()
+ {
+ return database;
+ }
+
public Connection getConnection()
{
Connection connection = dbConnectionProvider.getConnection();
@@ -217,16 +220,11 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
return connection;
}
- public void setDbConnectionProvider(IDBConnectionProvider dbConnectionProvider)
+ public void setDBConnectionProvider(IDBConnectionProvider dbConnectionProvider)
{
this.dbConnectionProvider = dbConnectionProvider;
}
- public void setDataSource(DataSource dataSource)
- {
- dbConnectionProvider = DBUtil.createConnectionProvider(dataSource);
- }
-
public IMetaDataManager getMetaDataManager()
{
return metaDataManager;
@@ -260,7 +258,7 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
public IDBSchema getDBSchema()
{
- return dbSchema;
+ return database.getSchema();
}
public void visitAllTables(Connection connection, IDBStore.TableVisitor visitor)
@@ -624,7 +622,10 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
DBUtil.close(connection);
}
- dbSchema = createSchema();
+ IDBSchema schema = createSchema();
+
+ database = DBUtil.openDatabase(dbAdapter, dbConnectionProvider, repository.getName());
+ database.ensureSchema(schema, IDBDelta.ChangeKind.ADD);
LifecycleUtil.activate(idHandler);
LifecycleUtil.activate(metaDataManager);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index f4a98ab18c..ecc48f03ee 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -56,7 +56,7 @@ public class DBStoreFactory implements IStoreFactory
DBStore store = new DBStore();
store.setMappingStrategy(mappingStrategy);
store.setDBAdapter(dbAdapter);
- store.setDbConnectionProvider(connectionProvider);
+ store.setDBConnectionProvider(connectionProvider);
Map<String, String> storeProperties = RepositoryConfigurator.getProperties(storeConfig, 1);
store.setProperties(storeProperties);

Back to the top