Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-05-30 04:37:11 +0000
committerEike Stepper2020-05-30 04:37:11 +0000
commite0549007f07737b8955eb68766f4882f4c6ed100 (patch)
tree09fbbc2046927c5790f8e230fd4487a681eff468
parentb312ebf9f3c0dec37e246d77c80e6a7807490ede (diff)
downloadcdo-e0549007f07737b8955eb68766f4882f4c6ed100.tar.gz
cdo-e0549007f07737b8955eb68766f4882f4c6ed100.tar.xz
cdo-e0549007f07737b8955eb68766f4882f4c6ed100.zip
[563744] Provide an EmbeddedH2Repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=563744 Change-Id: I08bba185906e3f256ed3de8b3472b63b6ccc43b0
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/CDOFacade.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/EmbeddedH2Repository.java111
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java8
7 files changed, 133 insertions, 60 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
index 52727e26c6..d98d4e3c39 100644
--- a/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.examples/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.examples;singleton:=true
-Bundle-Version: 4.1.0.qualifier
+Bundle-Version: 4.1.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.emf.cdo.internal.examples.bundle.OM$Activator
@@ -23,9 +23,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resoluti
org.eclipse.emf.cdo.security;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.cdo.server.security;bundle-version="[4.0.0,5.0.0)"
Import-Package: org.h2.jdbcx;version="[1.0.0,2.0.0)"
-Export-Package: org.eclipse.emf.cdo.examples;version="4.1.0";x-internal:=true,
- org.eclipse.emf.cdo.examples.embedded;version="4.1.0",
- org.eclipse.emf.cdo.examples.server;version="4.1.0";x-internal:=true,
- org.eclipse.emf.cdo.examples.server.offline;version="4.1.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.examples.bundle;version="4.1.0";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.examples;version="4.1.1";x-internal:=true,
+ org.eclipse.emf.cdo.examples.embedded;version="4.1.1",
+ org.eclipse.emf.cdo.examples.server;version="4.1.1";x-internal:=true,
+ org.eclipse.emf.cdo.examples.server.offline;version="4.1.1";x-internal:=true,
+ org.eclipse.emf.cdo.internal.examples.bundle;version="4.1.1";x-internal:=true
Automatic-Module-Name: org.eclipse.emf.cdo.examples
diff --git a/plugins/org.eclipse.emf.cdo.examples/pom.xml b/plugins/org.eclipse.emf.cdo.examples/pom.xml
index ee8ed23bc6..c70f59d60a 100644
--- a/plugins/org.eclipse.emf.cdo.examples/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.examples/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.examples</artifactId>
- <version>4.1.0-SNAPSHOT</version>
+ <version>4.1.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/CDOFacade.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/CDOFacade.java
index 7f5b8d7054..c57e028a2e 100644
--- a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/CDOFacade.java
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/CDOFacade.java
@@ -13,18 +13,8 @@ package org.eclipse.emf.cdo.examples.embedded;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.server.CDOServerBrowser;
import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.db.CDODBUtil;
-import org.eclipse.emf.cdo.server.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.server.embedded.CDOEmbeddedRepositoryConfig;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.db.h2.H2Adapter;
-import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
@@ -32,16 +22,12 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.h2.jdbcx.JdbcDataSource;
-
import java.io.File;
-import java.sql.Connection;
-import java.util.Map;
/**
* @author Eike Stepper
*/
-public final class CDOFacade extends CDOEmbeddedRepositoryConfig
+public final class CDOFacade extends EmbeddedH2Repository
{
public static final CDOFacade INSTANCE = new CDOFacade();
@@ -53,8 +39,6 @@ public final class CDOFacade extends CDOEmbeddedRepositoryConfig
private static final File DB_FOLDER = new File("./database");
- private static final String DS_URL = "jdbc:h2:" + DB_FOLDER + "/" + NAME + ";MVCC=FALSE";
-
private CDOServerBrowser serverBrowser;
private CDONet4jSession session;
@@ -65,13 +49,7 @@ public final class CDOFacade extends CDOEmbeddedRepositoryConfig
private CDOFacade()
{
- super(NAME);
- }
-
- public Connection getJDBCConnection()
- {
- IDBStore store = (IDBStore)getRepository().getStore();
- return store.getConnection();
+ super(NAME, AUDITING, BRANCHING, DB_FOLDER);
}
public synchronized CDONet4jSession getSession(boolean openOnDemand)
@@ -131,30 +109,6 @@ public final class CDOFacade extends CDOEmbeddedRepositoryConfig
}
@Override
- public IStore createStore(IManagedContainer container)
- {
- DB_FOLDER.mkdirs();
-
- IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(AUDITING, BRANCHING);
- mappingStrategy.getProperties().put(IMappingStrategy.Props.FORCE_NAMES_WITH_ID, "true");
-
- JdbcDataSource dataSource = new JdbcDataSource();
- dataSource.setURL(DS_URL);
-
- IDBAdapter dbAdapter = new H2Adapter();
- IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(dataSource);
-
- return CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
- }
-
- @Override
- public void initProperties(IManagedContainer container, Map<String, String> properties)
- {
- properties.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(AUDITING));
- properties.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(BRANCHING));
- }
-
- @Override
public boolean isInitialPackage(IRepository repository, String nsURI)
{
return nsURI.equals("http://www.eclipse.org/emf/CDO/examples/company/1.0.0");
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/EmbeddedH2Repository.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/EmbeddedH2Repository.java
new file mode 100644
index 0000000000..2430958827
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/embedded/EmbeddedH2Repository.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2020 Eike Stepper (Loehne, Germany) and others.
+ * 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.emf.cdo.examples.embedded;
+
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.IDBStore;
+import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.server.embedded.CDOEmbeddedRepositoryConfig;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.db.h2.H2Adapter;
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+import org.h2.jdbcx.JdbcDataSource;
+
+import java.io.File;
+import java.sql.Connection;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class EmbeddedH2Repository extends CDOEmbeddedRepositoryConfig
+{
+ private final boolean auditing;
+
+ private final boolean branching;
+
+ private final File dbFolder;
+
+ public EmbeddedH2Repository(String repositoryName, boolean auditing, boolean branching, File dbFolder)
+ {
+ super(repositoryName);
+ this.auditing = auditing;
+ this.branching = branching;
+ this.dbFolder = dbFolder;
+ }
+
+ public boolean isAuditing()
+ {
+ return auditing;
+ }
+
+ public boolean isBranching()
+ {
+ return branching;
+ }
+
+ public File getDbFolder()
+ {
+ return dbFolder;
+ }
+
+ public Connection getJDBCConnection()
+ {
+ IDBStore store = (IDBStore)getRepository().getStore();
+ return store.getConnection();
+ }
+
+ @Override
+ public IStore createStore(IManagedContainer container)
+ {
+ dbFolder.mkdirs();
+
+ IMappingStrategy mappingStrategy = createMappingStrategy();
+ IDBAdapter dbAdapter = createDBAdapter();
+
+ JdbcDataSource dataSource = createDataSource();
+ IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(dataSource);
+
+ return CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
+ }
+
+ protected IMappingStrategy createMappingStrategy()
+ {
+ IMappingStrategy mappingStrategy = CDODBUtil.createHorizontalMappingStrategy(auditing, branching);
+ mappingStrategy.getProperties().put(IMappingStrategy.Props.FORCE_NAMES_WITH_ID, "true");
+ return mappingStrategy;
+ }
+
+ protected H2Adapter createDBAdapter()
+ {
+ return new H2Adapter();
+ }
+
+ protected JdbcDataSource createDataSource()
+ {
+ JdbcDataSource dataSource = new JdbcDataSource();
+ dataSource.setURL("jdbc:h2:" + dbFolder + "/" + getRepositoryName() + ";MVCC=FALSE");
+ return dataSource;
+ }
+
+ @Override
+ public void initProperties(IManagedContainer container, Map<String, String> properties)
+ {
+ properties.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(auditing));
+ properties.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(branching));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
index 05a6b78c9d..ef3db3200d 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.embedded;singleton:=true
-Bundle-Version: 4.7.0.qualifier
+Bundle-Version: 4.8.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resoluti
org.eclipse.emf.cdo.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j.jvm;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.embedded;version="4.7.0",
- org.eclipse.emf.cdo.server.internal.embedded;version="4.7.0";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.server.internal.embedded.bundle;version="4.7.0";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.server.embedded;version="4.8.0",
+ org.eclipse.emf.cdo.server.internal.embedded;version="4.8.0";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.server.internal.embedded.bundle;version="4.8.0";x-internal:=true
Automatic-Module-Name: org.eclipse.emf.cdo.server.embedded
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/pom.xml b/plugins/org.eclipse.emf.cdo.server.embedded/pom.xml
index 087e8904de..fad9188175 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.server.embedded</artifactId>
- <version>4.7.0-SNAPSHOT</version>
+ <version>4.8.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
index ff7ea1dd19..41532863af 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
@@ -55,6 +55,14 @@ public abstract class CDOEmbeddedRepositoryConfig extends Lifecycle
this.repositoryName = repositoryName;
}
+ /**
+ * @since 4.8
+ */
+ public final String getRepositoryName()
+ {
+ return repositoryName;
+ }
+
public final IRepository getRepository()
{
return repository;

Back to the top