summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-10 07:51:52 (EDT)
committerEike Stepper2007-07-10 07:51:52 (EDT)
commit2e4ea5399a6f7762e181863d60d7db2d5ce1be0c (patch)
tree8bcc1f44c1310b93828472b2c372233ad16f67b1
parentbab1629367ab2431add6d9f185c2733709eaccec (diff)
downloadcdo-2e4ea5399a6f7762e181863d60d7db2d5ce1be0c.zip
cdo-2e4ea5399a6f7762e181863d60d7db2d5ce1be0c.tar.gz
cdo-2e4ea5399a6f7762e181863d60d7db2d5ce1be0c.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/.classpath2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java135
-rw-r--r--plugins/org.eclipse.emf.cdo.server/.classpath2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManager.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AbstractQueryOperation.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddRevisionOperation.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadHistoricalRevisionOperation.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourceIDOperation.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourcePathOperation.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadRevisionOperation.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/NOOPStore.java119
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java51
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/Store.java95
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositoryManager.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/StoreUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/config/org.eclipse.emf.cdo.server.properties26
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java4
-rw-r--r--plugins/org.eclipse.net4j.db/.classpath2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java26
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreManager.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreTransaction.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java23
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreManager.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreTransaction.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java75
-rw-r--r--plugins/org.eclipse.net4j.util/.classpath2
-rw-r--r--plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreManager.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreManager.java)8
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreTransaction.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreTransaction.java)6
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java97
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreManager.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreManager.java)2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreTransaction.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreTransaction.java)2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java25
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java23
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/StoreException.java (renamed from plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/StoreException.java)2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TX.java90
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java38
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java28
50 files changed, 1199 insertions, 118 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/.classpath b/plugins/org.eclipse.emf.cdo.server.db/.classpath
index 751c8f2..9124412 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/.classpath
+++ b/plugins/org.eclipse.emf.cdo.server.db/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/emf/cdo/server/internal/db/CDODBStoreManager.java|org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
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 439d10f..ac31a72 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
@@ -10,15 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.db;
-import org.eclipse.emf.cdo.internal.server.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.db.CDODBStoreManager;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-
-import javax.sql.DataSource;
-
-import java.util.Properties;
/**
* @author Eike Stepper
@@ -29,19 +20,21 @@ public final class CDODBUtil
{
}
- public static CDODBStoreManager getStoreManager(IDBAdapter dbAdapter, DataSource dataSource)
- {
- CDODBStoreManager storeManager = new CDODBStoreManager(dbAdapter, dataSource);
- storeManager.initDatabase();
- return storeManager;
- }
-
- public static CDODBStoreManager getStoreManager()
- {
- Properties properties = OM.BUNDLE.getConfigProperties();
- String adapterName = properties.getProperty("store.adapterName", "derby");
- IDBAdapter dbAdapter = DBUtil.getDBAdapter(adapterName);
- DataSource dataSource = DBUtil.createDataSource(properties, "datasource");
- return getStoreManager(dbAdapter, dataSource);
- }
+ // public static CDODBStoreManager getStoreManager(IDBAdapter dbAdapter,
+ // DataSource dataSource)
+ // {
+ // CDODBStoreManager storeManager = new CDODBStoreManager(dbAdapter,
+ // dataSource);
+ // storeManager.initDatabase();
+ // return storeManager;
+ // }
+ //
+ // public static CDODBStoreManager getStoreManager()
+ // {
+ // Properties properties = OM.BUNDLE.getConfigProperties();
+ // String adapterName = properties.getProperty("store.adapterName", "derby");
+ // IDBAdapter dbAdapter = DBUtil.getDBAdapter(adapterName);
+ // DataSource dataSource = DBUtil.createDataSource(properties, "datasource");
+ // return getStoreManager(dbAdapter, dataSource);
+ // }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java
index f299881..dc7e5e1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBTransaction.java
@@ -15,8 +15,8 @@ import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.net4j.internal.db.DBStoreTransaction;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.IStoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreManager;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
import java.sql.Connection;
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
new file mode 100644
index 0000000..7d8de06
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -0,0 +1,135 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.internal.server.store.AddRevisionOperation;
+import org.eclipse.emf.cdo.internal.server.store.LoadHistoricalRevisionOperation;
+import org.eclipse.emf.cdo.internal.server.store.LoadResourceIDOperation;
+import org.eclipse.emf.cdo.internal.server.store.LoadResourcePathOperation;
+import org.eclipse.emf.cdo.internal.server.store.LoadRevisionOperation;
+import org.eclipse.emf.cdo.internal.server.store.RegisterResourceOperation;
+import org.eclipse.emf.cdo.internal.server.store.Store;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.util.transaction.ITransaction;
+
+import javax.sql.DataSource;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStore extends Store
+{
+ private static final String TYPE = "db";
+
+ private DataSource dataSource;
+
+ public DBStore(DataSource dataSource)
+ {
+ super(TYPE);
+ this.dataSource = dataSource;
+ }
+
+ public ITransaction createTransaction()
+ {
+ return DBUtil.createTransaction(dataSource);
+ }
+
+ @Override
+ protected AddRevisionOperation createAddRevisionOperation(RevisionManager revisionManager, CDORevisionImpl revision)
+ {
+ return new AddRevisionOperation(revisionManager, revision)
+ {
+ @Override
+ protected void update(ITransaction transaction, CDORevisionImpl revision)
+ {
+ // TODO Implement method .update()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadRevisionOperation createLoadRevisionOperation(CDOID id)
+ {
+ return new LoadRevisionOperation(id)
+ {
+ @Override
+ protected CDORevisionImpl query(ITransaction transaction, CDOID id) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadHistoricalRevisionOperation createLoadHistoricalRevisionOperation(CDOID id, long timeStamp)
+ {
+ return new LoadHistoricalRevisionOperation(id, timeStamp)
+ {
+ @Override
+ protected CDORevisionImpl query(ITransaction transaction, CDOID id, long timeStamp) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected RegisterResourceOperation createRegisterResourceOperation(CDOID id, String path,
+ Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap)
+ {
+ return new RegisterResourceOperation(id, path, idToPathMap, pathToIDMap)
+ {
+ @Override
+ protected void update(ITransaction transaction, CDOID id, String path)
+ {
+ // TODO Implement method .update()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadResourceIDOperation createLoadResourceIDOperation(String path)
+ {
+ return new LoadResourceIDOperation(path)
+ {
+ @Override
+ protected CDOID query(ITransaction transaction, String path) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadResourcePathOperation createLoadResourcePathOperation(CDOID id)
+ {
+ return new LoadResourcePathOperation(id)
+ {
+ @Override
+ protected String query(ITransaction transaction, CDOID id) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/.classpath b/plugins/org.eclipse.emf.cdo.server/.classpath
index 30a021e..0ffb2ff 100644
--- a/plugins/org.eclipse.emf.cdo.server/.classpath
+++ b/plugins/org.eclipse.emf.cdo.server/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="org/eclipse/emf/cdo/server/ModelManager.java|org/eclipse/emf/cdo/server/Model.java|org/eclipse/emf/cdo/internal/server/ModelManagerImpl.java|org/eclipse/emf/cdo/internal/server/protocol/LoadResourcePathIndication.java|org/eclipse/emf/cdo/internal/server/protocol/AddModelsIndication.java" kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/emf/cdo/server/ModelManager.java|org/eclipse/emf/cdo/server/Model.java|org/eclipse/emf/cdo/internal/server/ModelManagerImpl.java|org/eclipse/emf/cdo/internal/server/protocol/LoadResourcePathIndication.java|org/eclipse/emf/cdo/internal/server/protocol/AddModelsIndication.java|org/eclipse/emf/cdo/server/ITransaction.java|org/eclipse/emf/cdo/server/StoreUtil.java|org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java|org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
index 71667f9..8a76a89 100644
--- a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
@@ -11,6 +11,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.emf.cdo.internal.server;version="0.8.0",
org.eclipse.emf.cdo.internal.server.bundle;version="0.8.0",
org.eclipse.emf.cdo.internal.server.protocol;version="0.8.0",
+ org.eclipse.emf.cdo.internal.server.store;version="0.8.0",
org.eclipse.emf.cdo.server;version="0.8.0"
Require-Bundle: org.eclipse.core.runtime;resolution:=optional,
org.eclipse.emf.ecore;visibility:=reexport,
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java
index da036e6..d83e2d5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreManager.java
@@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.net4j.internal.util.store.StoreManager;
+import org.eclipse.net4j.internal.util.transaction.StoreManager;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java
index a3e2ebe..4cfc295 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/EmptyStoreTransaction.java
@@ -14,8 +14,8 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.net4j.internal.util.store.StoreTransaction;
-import org.eclipse.net4j.util.store.IStoreManager;
+import org.eclipse.net4j.internal.util.transaction.StoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreManager;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index b4c71c4..6d1f4f2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -13,10 +13,9 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.store.IStoreManager;
import java.util.UUID;
@@ -29,6 +28,8 @@ public class Repository extends Lifecycle implements IRepository
private String name;
+ private IStore store;
+
private String uuid;
private SessionManager sessionManager;
@@ -37,18 +38,16 @@ public class Repository extends Lifecycle implements IRepository
private RevisionManager revisionManager;
- private IStoreManager<ITransaction> storeManager;
-
private long nextOIDValue = INITIAL_OID_VALUE;
- public Repository(String name, IStoreManager<ITransaction> storeManager)
+ public Repository(String name, IStore store)
{
this.name = name;
+ this.store = store;
this.uuid = UUID.randomUUID().toString();
sessionManager = new SessionManager(this);
resourceManager = new ResourceManager(this);
revisionManager = new RevisionManager(this);
- this.storeManager = storeManager;
}
public String getName()
@@ -56,6 +55,11 @@ public class Repository extends Lifecycle implements IRepository
return name;
}
+ public IStore getStore()
+ {
+ return store;
+ }
+
public String getUUID()
{
return uuid;
@@ -76,11 +80,6 @@ public class Repository extends Lifecycle implements IRepository
return revisionManager;
}
- public IStoreManager<ITransaction> getStoreManager()
- {
- return storeManager;
- }
-
public CDOID getNextCDOID()
{
return CDOIDImpl.create(nextOIDValue++);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManager.java
index 0e6f837..64b6984 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryManager.java
@@ -12,11 +12,10 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IRepositoryManager;
-import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.store.IStoreManager;
import java.util.HashMap;
import java.util.Map;
@@ -64,7 +63,7 @@ public final class RepositoryManager extends Lifecycle implements IRepositoryMan
}
}
- public Repository addRepository(String name, IStoreManager<ITransaction> storeManager)
+ public Repository addRepository(String name, IStore store)
{
synchronized (repositories)
{
@@ -73,7 +72,7 @@ public final class RepositoryManager extends Lifecycle implements IRepositoryMan
{
throw new RuntimeException("Repository already exists: " + name);
}
- repository = new Repository(name, storeManager);
+ repository = new Repository(name, store);
LifecycleUtil.activate(repository);
repositories.put(name, repository);
return repository;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
index 07c7bbd..696ae3b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.IResourceManager;
-import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -69,26 +68,21 @@ public class ResourceManager implements IResourceManager
public void registerResource(CDOID id, String path)
{
- final String oldPath = idToPathMap.put(id, path);
- if (oldPath != path)
+ if (TRACER.isEnabled())
{
- if (TRACER.isEnabled())
- {
- TRACER.format("Registering resource: {0} --> {1}", id, path);
- }
-
- StoreUtil.getTransaction().registerResource(id, path);
- pathToIDMap.put(path, id);
+ TRACER.format("Registering resource: {0} --> {1}", id, path);
}
+
+ repository.getStore().registerResource(id, path, idToPathMap, pathToIDMap);
}
private CDOID loadID(String path)
{
- return StoreUtil.getTransaction().getResourceID(path);
+ return repository.getStore().loadResourceID(path);
}
private String loadPath(CDOID id)
{
- return StoreUtil.getTransaction().getResourcePath(id);
+ return repository.getStore().loadResourcePath(id);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
index a8ffc9a..d07af92 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.server.IRevisionManager;
-import org.eclipse.emf.cdo.server.StoreUtil;
/**
* @author Eike Stepper
@@ -37,8 +36,7 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
@Override
public void addRevision(CDORevisionImpl revision)
{
- StoreUtil.getTransaction().addRevision(revision);
- super.addRevision(revision);
+ repository.getStore().addRevision(this, revision);
if (revision.isResource())
{
String path = (String)revision.getData().get(CDOPathFeatureImpl.INSTANCE, -1);
@@ -46,15 +44,20 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
}
}
+ public void addRevisionToCache(CDORevisionImpl revision)
+ {
+ super.addRevision(revision);
+ }
+
@Override
protected CDORevisionImpl loadRevision(CDOID id)
{
- return StoreUtil.getTransaction().getRevision(id);
+ return repository.getStore().loadRevision(id);
}
@Override
protected CDORevisionImpl loadRevision(CDOID id, long timeStamp)
{
- return StoreUtil.getTransaction().getRevision(id, timeStamp);
+ return repository.getStore().loadHistoricalRevision(id, timeStamp);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
index 0f597f2..9fa4701 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java
@@ -15,12 +15,11 @@ import org.eclipse.emf.cdo.internal.server.ResourceManager;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
import org.eclipse.emf.cdo.internal.server.Session;
import org.eclipse.emf.cdo.internal.server.SessionManager;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.server.StoreUtil;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.StoreException;
+import org.eclipse.net4j.util.transaction.TX;
+import org.eclipse.net4j.util.transaction.TransactionException;
/**
* @author Eike Stepper
@@ -55,9 +54,9 @@ public abstract class CDOServerIndication extends IndicationWithResponse
return getRepository().getResourceManager();
}
- protected IStoreManager<ITransaction> getStoreManager()
+ protected IStore getStore()
{
- return getRepository().getStoreManager();
+ return getRepository().getStore();
}
protected Repository getRepository()
@@ -76,8 +75,19 @@ public abstract class CDOServerIndication extends IndicationWithResponse
return (CDOServerProtocol)super.getProtocol();
}
- protected void transact(Runnable runnable) throws StoreException
+ protected void transact(Runnable runnable) throws TransactionException
{
- StoreUtil.transact(getStoreManager(), runnable);
+ TX.begin(getStore().createTransaction());
+
+ try
+ {
+ runnable.run();
+ TX.commit();
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ TX.rollback();
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AbstractQueryOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AbstractQueryOperation.java
new file mode 100644
index 0000000..b18936b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AbstractQueryOperation.java
@@ -0,0 +1,33 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractQueryOperation<T extends ITransaction, RESULT, PARAMETER> implements
+ ITransactionalOperation<T, RESULT>
+{
+ private PARAMETER parameter;
+
+ public AbstractQueryOperation(PARAMETER parameter)
+ {
+ this.parameter = parameter;
+ }
+
+ public RESULT prepare(T transaction) throws Exception
+ {
+ return query(transaction, parameter);
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ }
+
+ protected abstract RESULT query(T transaction, PARAMETER parameter);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddRevisionOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddRevisionOperation.java
new file mode 100644
index 0000000..43f1d06
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddRevisionOperation.java
@@ -0,0 +1,41 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AddRevisionOperation<T extends ITransaction> implements ITransactionalOperation<T, Object>
+{
+ private RevisionManager revisionManager;
+
+ private CDORevisionImpl revision;
+
+ public AddRevisionOperation(RevisionManager revisionManager, CDORevisionImpl revision)
+ {
+ this.revisionManager = revisionManager;
+ this.revision = revision;
+ }
+
+ public Object prepare(T transaction) throws Exception
+ {
+ update(transaction, revision);
+ revisionManager.addRevisionToCache(revision);
+ return null;
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ revisionManager.removeRevision(revision);
+ }
+
+ protected abstract void update(T transaction, CDORevisionImpl revision);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadHistoricalRevisionOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadHistoricalRevisionOperation.java
new file mode 100644
index 0000000..8ee97f7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadHistoricalRevisionOperation.java
@@ -0,0 +1,39 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class LoadHistoricalRevisionOperation<T extends ITransaction> implements
+ ITransactionalOperation<T, CDORevisionImpl>
+{
+ private CDOID id;
+
+ private long timeStamp;
+
+ public LoadHistoricalRevisionOperation(CDOID id, long timeStamp)
+ {
+ this.id = id;
+ this.timeStamp = timeStamp;
+ }
+
+ public CDORevisionImpl prepare(T transaction) throws Exception
+ {
+ return query(transaction, id, timeStamp);
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ }
+
+ protected abstract CDORevisionImpl query(T transaction, CDOID id, long timeStamp) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourceIDOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourceIDOperation.java
new file mode 100644
index 0000000..5c83381
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourceIDOperation.java
@@ -0,0 +1,34 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class LoadResourceIDOperation<T extends ITransaction> implements ITransactionalOperation<T, CDOID>
+{
+ private String path;
+
+ public LoadResourceIDOperation(String path)
+ {
+ this.path = path;
+ }
+
+ public CDOID prepare(T transaction) throws Exception
+ {
+ return query(transaction, path);
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ }
+
+ protected abstract CDOID query(T transaction, String path) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourcePathOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourcePathOperation.java
new file mode 100644
index 0000000..1e81dab
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourcePathOperation.java
@@ -0,0 +1,34 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class LoadResourcePathOperation<T extends ITransaction> implements ITransactionalOperation<T, String>
+{
+ private CDOID id;
+
+ public LoadResourcePathOperation(CDOID id)
+ {
+ this.id = id;
+ }
+
+ public String prepare(T transaction) throws Exception
+ {
+ return query(transaction, id);
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ }
+
+ protected abstract String query(T transaction, CDOID id) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadRevisionOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadRevisionOperation.java
new file mode 100644
index 0000000..0256f47
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadRevisionOperation.java
@@ -0,0 +1,36 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class LoadRevisionOperation<T extends ITransaction> implements
+ ITransactionalOperation<T, CDORevisionImpl>
+{
+ private CDOID id;
+
+ public LoadRevisionOperation(CDOID id)
+ {
+ this.id = id;
+ }
+
+ public CDORevisionImpl prepare(T transaction) throws Exception
+ {
+ return query(transaction, id);
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ }
+
+ protected abstract CDORevisionImpl query(T transaction, CDOID id) throws Exception;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/NOOPStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/NOOPStore.java
new file mode 100644
index 0000000..21fdc2a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/NOOPStore.java
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.TransactionUtil;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPStore extends Store
+{
+ private static final String TYPE = "noop";
+
+ public NOOPStore()
+ {
+ super(TYPE);
+ }
+
+ public ITransaction createTransaction()
+ {
+ return TransactionUtil.createTransaction();
+ }
+
+ @Override
+ protected AddRevisionOperation createAddRevisionOperation(RevisionManager revisionManager, CDORevisionImpl revision)
+ {
+ return new AddRevisionOperation(revisionManager, revision)
+ {
+ @Override
+ protected void update(ITransaction transaction, CDORevisionImpl revision)
+ {
+ }
+ };
+ }
+
+ @Override
+ protected LoadRevisionOperation createLoadRevisionOperation(CDOID id)
+ {
+ return new LoadRevisionOperation(id)
+ {
+ @Override
+ protected CDORevisionImpl query(ITransaction transaction, CDOID id) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadHistoricalRevisionOperation createLoadHistoricalRevisionOperation(CDOID id, long timeStamp)
+ {
+ return new LoadHistoricalRevisionOperation(id, timeStamp)
+ {
+ @Override
+ protected CDORevisionImpl query(ITransaction transaction, CDOID id, long timeStamp) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected RegisterResourceOperation createRegisterResourceOperation(CDOID id, String path,
+ Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap)
+ {
+ return new RegisterResourceOperation(id, path, idToPathMap, pathToIDMap)
+ {
+ @Override
+ protected void update(ITransaction transaction, CDOID id, String path)
+ {
+ }
+ };
+ }
+
+ @Override
+ protected LoadResourceIDOperation createLoadResourceIDOperation(String path)
+ {
+ return new LoadResourceIDOperation(path)
+ {
+ @Override
+ protected CDOID query(ITransaction transaction, String path) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+
+ @Override
+ protected LoadResourcePathOperation createLoadResourcePathOperation(CDOID id)
+ {
+ return new LoadResourcePathOperation(id)
+ {
+ @Override
+ protected String query(ITransaction transaction, CDOID id) throws Exception
+ {
+ // TODO Implement method .query()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java
new file mode 100644
index 0000000..16f1087
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java
@@ -0,0 +1,51 @@
+package org.eclipse.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class RegisterResourceOperation<T extends ITransaction> implements ITransactionalOperation<T, Object>
+{
+ private CDOID id;
+
+ private String path;
+
+ private Map<CDOID, String> idToPathMap = new HashMap();
+
+ private Map<String, CDOID> pathToIDMap = new HashMap();
+
+ public RegisterResourceOperation(CDOID id, String path, Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap)
+ {
+ this.id = id;
+ this.path = path;
+ this.idToPathMap = idToPathMap;
+ this.pathToIDMap = pathToIDMap;
+ }
+
+public Object prepare(T transaction) throws Exception
+ {
+ update(transaction, id, path);
+ idToPathMap.put(id, path);
+ pathToIDMap.put(path, id);
+ return null;
+ }
+
+ public void onCommit(T transaction)
+ {
+ }
+
+ public void onRollback(T transaction)
+ {
+ idToPathMap.remove(id);
+ pathToIDMap.remove(path);
+ }
+
+ protected abstract void update(T transaction, CDOID id, String path);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/Store.java
new file mode 100644
index 0000000..97ca6e4
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/Store.java
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.emf.cdo.internal.server.store;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.server.IStore;
+
+import org.eclipse.net4j.util.transaction.TX;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Store implements IStore
+{
+ private String type;
+
+ private Repository repository;
+
+ public Store(String type)
+ {
+ this.type = type;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public Repository getRepository()
+ {
+ return repository;
+ }
+
+ public void setRepository(Repository repository)
+ {
+ this.repository = repository;
+ }
+
+ public void registerResource(CDOID id, String path, Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap)
+ {
+ TX.execute(createRegisterResourceOperation(id, path, idToPathMap, pathToIDMap));
+ }
+
+ public CDOID loadResourceID(String path)
+ {
+ return (CDOID)TX.execute(createLoadResourceIDOperation(path));
+ }
+
+ public String loadResourcePath(CDOID id)
+ {
+ return (String)TX.execute(createLoadResourcePathOperation(id));
+ }
+
+ public void addRevision(RevisionManager revisionManager, CDORevisionImpl revision)
+ {
+ TX.execute(createAddRevisionOperation(revisionManager, revision));
+ }
+
+ public CDORevisionImpl loadRevision(CDOID id)
+ {
+ return (CDORevisionImpl)TX.execute(createLoadRevisionOperation(id));
+ }
+
+ public CDORevisionImpl loadHistoricalRevision(CDOID id, long timeStamp)
+ {
+ return (CDORevisionImpl)TX.execute(createLoadHistoricalRevisionOperation(id, timeStamp));
+ }
+
+ protected abstract RegisterResourceOperation createRegisterResourceOperation(CDOID id, String path,
+ Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap);
+
+ protected abstract LoadResourceIDOperation createLoadResourceIDOperation(String path);
+
+ protected abstract LoadResourcePathOperation createLoadResourcePathOperation(CDOID id);
+
+ protected abstract AddRevisionOperation createAddRevisionOperation(RevisionManager revisionManager,
+ CDORevisionImpl revision);
+
+ protected abstract LoadRevisionOperation createLoadRevisionOperation(CDOID id);
+
+ protected abstract LoadHistoricalRevisionOperation createLoadHistoricalRevisionOperation(CDOID id, long timeStamp);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
index fcce731..b2d59ea 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
-import org.eclipse.net4j.util.store.IStoreManager;
/**
* @author Eike Stepper
@@ -19,6 +18,8 @@ public interface IRepository
{
public String getName();
+ public IStore getStore();
+
public String getUUID();
public ISessionManager getSessionManager();
@@ -26,6 +27,4 @@ public interface IRepository
public IResourceManager getResourceManager();
public IRevisionManager getRevisionManager();
-
- public IStoreManager<ITransaction> getStoreManager();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositoryManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositoryManager.java
index 350b813..da4ee8b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositoryManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepositoryManager.java
@@ -12,8 +12,6 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.internal.server.RepositoryManager;
-import org.eclipse.net4j.util.store.IStoreManager;
-
/**
* @author Eike Stepper
*/
@@ -27,7 +25,7 @@ public interface IRepositoryManager
public IRepository getRepository(String name);
- public IRepository addRepository(String name, IStoreManager<ITransaction> storeManager);
+ public IRepository addRepository(String name, IStore store);
public void clear();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
new file mode 100644
index 0000000..f042165
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.emf.cdo.server;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IStore
+{
+ public String getType();
+
+ public IRepository getRepository();
+
+ public ITransaction createTransaction();
+
+ public void registerResource(CDOID id, String path, Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap);
+
+ public CDOID loadResourceID(String path);
+
+ public String loadResourcePath(CDOID id);
+
+ public void addRevision(RevisionManager revisionManager, CDORevisionImpl revision);
+
+ public CDORevisionImpl loadRevision(CDOID id);
+
+ public CDORevisionImpl loadHistoricalRevision(CDOID id, long timeStamp);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java
index c0f6bad..926aa0b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.net4j.util.store.IStoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/StoreUtil.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/StoreUtil.java
index 25c4f2e..ec4f693 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/StoreUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/StoreUtil.java
@@ -10,9 +10,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.StoreException;
-import org.eclipse.net4j.util.store.IStoreManager.TransactedOperation;
+import org.eclipse.net4j.util.transaction.IStoreManager;
+import org.eclipse.net4j.util.transaction.StoreException;
+import org.eclipse.net4j.util.transaction.IStoreManager.TransactedOperation;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.ui/config/org.eclipse.emf.cdo.server.properties b/plugins/org.eclipse.emf.cdo.ui/config/org.eclipse.emf.cdo.server.properties
index 31c3dbf..a69d3b6 100644
--- a/plugins/org.eclipse.emf.cdo.ui/config/org.eclipse.emf.cdo.server.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/config/org.eclipse.emf.cdo.server.properties
@@ -1,15 +1,15 @@
-repositories = repo1, repo2
+repositories = repo1, repo2
-repo1.type = db
-repo1.instanceID = TEST0001
-repo1.dbAdapter = derby
-repo1.dataSource.driverClass = org.apache.derby.jdbc.EmbeddedDataSource
-repo1.dataSource.databaseName = C:/temp/cdodb1
-repo1.dataSource.createDatabase = create
+repo1.store.type = db
+repo1.store.instanceID = TEST0001
+repo1.store.dbAdapter = derby
+repo1.store.dataSource.driverClass = org.apache.derby.jdbc.EmbeddedDataSource
+repo1.store.dataSource.databaseName = C:/temp/cdodb1
+repo1.store.dataSource.createDatabase = create
-repo2.type = db
-repo2.instanceID = TEST0002
-repo2.dbAdapter = derby
-repo2.dataSource.driverClass = org.apache.derby.jdbc.EmbeddedDataSource
-repo2.dataSource.databaseName = C:/temp/cdodb2
-repo2.dataSource.createDatabase = create
+repo2.store.type = db
+repo2.store.instanceID = TEST0002
+repo2.store.dbAdapter = derby
+repo2.store.dataSource.driverClass = org.apache.derby.jdbc.EmbeddedDataSource
+repo2.store.dataSource.databaseName = C:/temp/cdodb2
+repo2.store.dataSource.createDatabase = create
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index a549327..59117c3 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.bundle;
-import org.eclipse.emf.cdo.internal.server.EmptyStoreManager;
+import org.eclipse.emf.cdo.internal.server.store.NOOPStore;
import org.eclipse.emf.cdo.server.IRepositoryManager;
import org.eclipse.net4j.internal.util.om.OSGiActivator;
@@ -50,7 +50,7 @@ public final class OM
@Override
protected void start() throws Exception
{
- IRepositoryManager.INSTANCE.addRepository("repo1", new EmptyStoreManager());
+ IRepositoryManager.INSTANCE.addRepository("repo1", new NOOPStore());
// Properties properties = BUNDLE.getConfigProperties();
// String repositories = properties.getProperty("repositories");
// if (repositories != null)
diff --git a/plugins/org.eclipse.net4j.db/.classpath b/plugins/org.eclipse.net4j.db/.classpath
index 751c8f2..a44345a 100644
--- a/plugins/org.eclipse.net4j.db/.classpath
+++ b/plugins/org.eclipse.net4j.db/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/net4j/db/IDBStoreManager.java|org/eclipse/net4j/db/IDBStoreTransaction.java|org/eclipse/net4j/internal/db/DBStoreManager.java|org/eclipse/net4j/internal/db/DBStoreTransaction.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
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 f799a4a..9e3f5bb 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,11 +11,13 @@
package org.eclipse.net4j.db;
import org.eclipse.net4j.internal.db.DBSchema;
+import org.eclipse.net4j.internal.db.DBTransaction;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.util.ReflectUtil;
import javax.sql.DataSource;
+import java.sql.Connection;
import java.util.Map;
/**
@@ -58,4 +60,28 @@ public final class DBUtil
{
return IDBAdapter.REGISTRY.get(adapterName);
}
+
+ public static IDBTransaction createTransaction(DataSource dataSource)
+ {
+ try
+ {
+ return createTransaction(dataSource.getConnection());
+ }
+ catch (Exception ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ public static IDBTransaction createTransaction(Connection connection)
+ {
+ try
+ {
+ return new DBTransaction(connection);
+ }
+ catch (Exception ex)
+ {
+ throw new DBException(ex);
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreManager.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreManager.java
index 57cc73e..3e6b86a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreManager.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreManager.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.db;
-import org.eclipse.net4j.util.store.IStoreManager;
+import org.eclipse.net4j.util.transaction.IStoreManager;
import javax.sql.DataSource;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreTransaction.java
index f3b36d8..45abc25 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBStoreTransaction.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.db;
-import org.eclipse.net4j.util.store.IStoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
import java.sql.Connection;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java
new file mode 100644
index 0000000..9dc9d5e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java
@@ -0,0 +1,23 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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 org.eclipse.net4j.util.transaction.ITransaction;
+
+import java.sql.Connection;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDBTransaction extends ITransaction
+{
+ public Connection getConnection();
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreManager.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreManager.java
index 92c2f99..1b397e2 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreManager.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreManager.java
@@ -13,8 +13,8 @@ package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBStoreManager;
import org.eclipse.net4j.db.IDBSchema;
-import org.eclipse.net4j.internal.util.store.StoreManager;
-import org.eclipse.net4j.util.store.StoreException;
+import org.eclipse.net4j.internal.util.transaction.StoreManager;
+import org.eclipse.net4j.util.transaction.StoreException;
import javax.sql.DataSource;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreTransaction.java
index 5109625..3f8a4e2 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBStoreTransaction.java
@@ -11,9 +11,9 @@
package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.IDBStoreTransaction;
-import org.eclipse.net4j.internal.util.store.StoreTransaction;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.IStoreTransaction;
+import org.eclipse.net4j.internal.util.transaction.StoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreManager;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
import java.sql.Connection;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
new file mode 100644
index 0000000..05a8795
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.DBException;
+import org.eclipse.net4j.db.IDBTransaction;
+import org.eclipse.net4j.internal.util.transaction.Transaction;
+import org.eclipse.net4j.util.transaction.TransactionException;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBTransaction extends Transaction implements IDBTransaction
+{
+ private Connection connection;
+
+ public DBTransaction(Connection connection) throws DBException
+ {
+ try
+ {
+ this.connection = connection;
+ connection.setAutoCommit(false);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ public Connection getConnection()
+ {
+ return connection;
+ }
+
+ @Override
+ public void commit() throws TransactionException
+ {
+ try
+ {
+ connection.commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new TransactionException(ex);
+ }
+
+ super.commit();
+ }
+
+ @Override
+ public void rollback() throws TransactionException
+ {
+ try
+ {
+ connection.rollback();
+ }
+ catch (SQLException ex)
+ {
+ throw new TransactionException(ex);
+ }
+
+ super.rollback();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/.classpath b/plugins/org.eclipse.net4j.util/.classpath
index 304e861..6a78c74 100644
--- a/plugins/org.eclipse.net4j.util/.classpath
+++ b/plugins/org.eclipse.net4j.util/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
+ <classpathentry excluding="org/eclipse/net4j/internal/util/transaction/StoreManager.java|org/eclipse/net4j/internal/util/transaction/StoreTransaction.java|org/eclipse/net4j/util/transaction/IStoreManager.java|org/eclipse/net4j/util/transaction/IStoreTransaction.java|org/eclipse/net4j/util/transaction/StoreException.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
index 179d434..83a4374 100644
--- a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
@@ -21,7 +21,7 @@ Export-Package: org.eclipse.net4j.internal.util;version="0.8.0",
org.eclipse.net4j.internal.util.lifecycle;version="0.8.0",
org.eclipse.net4j.internal.util.om;version="0.8.0",
org.eclipse.net4j.internal.util.registry;version="0.8.0",
- org.eclipse.net4j.internal.util.store;version="0.8.0",
+ org.eclipse.net4j.internal.util.transaction;version="0.8.0",
org.eclipse.net4j.util;version="0.8.0",
org.eclipse.net4j.util.concurrent;version="0.8.0",
org.eclipse.net4j.util.container;version="0.8.0",
@@ -33,6 +33,6 @@ Export-Package: org.eclipse.net4j.internal.util;version="0.8.0",
org.eclipse.net4j.util.om.log;version="0.8.0",
org.eclipse.net4j.util.om.trace;version="0.8.0",
org.eclipse.net4j.util.registry;version="0.8.0",
- org.eclipse.net4j.util.store;version="0.8.0",
- org.eclipse.net4j.util.stream;version="0.8.0"
+ org.eclipse.net4j.util.stream;version="0.8.0",
+ org.eclipse.net4j.util.transaction;version="0.8.0"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreManager.java
index f86effb..414c011 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreManager.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreManager.java
@@ -8,12 +8,12 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.internal.util.store;
+package org.eclipse.net4j.internal.util.transaction;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.IStoreTransaction;
-import org.eclipse.net4j.util.store.StoreException;
+import org.eclipse.net4j.util.transaction.IStoreManager;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
+import org.eclipse.net4j.util.transaction.StoreException;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreTransaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreTransaction.java
index b5c9150..6c9af2c 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/store/StoreTransaction.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/StoreTransaction.java
@@ -8,10 +8,10 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.internal.util.store;
+package org.eclipse.net4j.internal.util.transaction;
-import org.eclipse.net4j.util.store.IStoreManager;
-import org.eclipse.net4j.util.store.IStoreTransaction;
+import org.eclipse.net4j.util.transaction.IStoreManager;
+import org.eclipse.net4j.util.transaction.IStoreTransaction;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java
new file mode 100644
index 0000000..8b2382d
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.util.transaction;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+import org.eclipse.net4j.util.transaction.TransactionException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class Transaction implements ITransaction
+{
+ private List<ITransactionalOperation> operations = new ArrayList();
+
+ public boolean isActive()
+ {
+ return operations != null;
+ }
+
+ public <R> R execute(ITransactionalOperation<ITransaction, R> operation) throws TransactionException
+ {
+ if (!isActive())
+ {
+ throw new TransactionException("Transaction inactive");
+ }
+
+ try
+ {
+ operations.add(operation);
+ return operation.prepare(this);
+ }
+ catch (TransactionException ex)
+ {
+ rollback();
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ rollback();
+ throw new TransactionException(ex);
+ }
+ }
+
+ public void commit() throws TransactionException
+ {
+ for (ITransactionalOperation operation : end())
+ {
+ try
+ {
+ operation.onCommit(this);
+ }
+ catch (RuntimeException ex)
+ {
+ throw new TransactionException("Unexpected problem during commit", ex);
+ }
+ }
+ }
+
+ public void rollback() throws TransactionException
+ {
+ for (ITransactionalOperation operation : end())
+ {
+ try
+ {
+ operation.onRollback(this);
+ }
+ catch (RuntimeException ex)
+ {
+ throw new TransactionException("Unexpected problem during rollback", ex);
+ }
+ }
+ }
+
+ private List<ITransactionalOperation> end()
+ {
+ try
+ {
+ return operations;
+ }
+ finally
+ {
+ operations = null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreManager.java
index a72bfe2..69c9142 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreManager.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreManager.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.store;
+package org.eclipse.net4j.util.transaction;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreTransaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreTransaction.java
index 5298b3f..1d52187 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/IStoreTransaction.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/IStoreTransaction.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.store;
+package org.eclipse.net4j.util.transaction;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java
new file mode 100644
index 0000000..f3f8786
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.util.transaction;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ITransaction
+{
+ public boolean isActive();
+
+ public <R> R execute(ITransactionalOperation<ITransaction, R> operation) throws TransactionException;
+
+ public void commit() throws TransactionException;
+
+ public void rollback() throws TransactionException;
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java
new file mode 100644
index 0000000..8edff47
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java
@@ -0,0 +1,23 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.util.transaction;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ITransactionalOperation<T extends ITransaction, R>
+{
+ public R prepare(T transaction) throws Exception;
+
+ public void onCommit(T transaction);
+
+ public void onRollback(T transaction);
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/StoreException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/StoreException.java
index 7640617..130b50d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/store/StoreException.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/StoreException.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.util.store;
+package org.eclipse.net4j.util.transaction;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TX.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TX.java
new file mode 100644
index 0000000..a3bb8ec
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TX.java
@@ -0,0 +1,90 @@
+/***************************************************************************
+ * 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.util.transaction;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TX
+{
+ private static ThreadLocal<ITransaction> tx = new InheritableThreadLocal();
+
+ private TX()
+ {
+ }
+
+ public static <R> R execute(ITransactionalOperation<ITransaction, R> operation)
+ {
+ ITransaction transaction = get();
+
+ try
+ {
+ return transaction.execute(operation);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ }
+
+ public static void begin(ITransaction transaction)
+ {
+ ITransaction existingTransaction = tx.get();
+ if (existingTransaction != null)
+ {
+ throw new IllegalStateException("Transaction already ongoing");
+ }
+
+ tx.set(transaction);
+ }
+
+ public static void begin()
+ {
+ begin(TransactionUtil.createTransaction());
+ }
+
+ public static void commit()
+ {
+ ITransaction transaction = get();
+ try
+ {
+ transaction.commit();
+ }
+ finally
+ {
+ tx.set(null);
+ }
+ }
+
+ public static void rollback()
+ {
+ ITransaction transaction = get();
+ try
+ {
+ transaction.rollback();
+ }
+ finally
+ {
+ tx.set(null);
+ }
+ }
+
+ private static ITransaction get()
+ {
+ ITransaction transaction = tx.get();
+ if (transaction == null)
+ {
+ throw new IllegalStateException("No transaction ongoing");
+ }
+
+ return transaction;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java
new file mode 100644
index 0000000..8a8edcf
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionException.java
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (c) 2004, 2005, 2006 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.util.transaction;
+
+/**
+ * @author Eike Stepper
+ */
+public class TransactionException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public TransactionException()
+ {
+ }
+
+ public TransactionException(String message)
+ {
+ super(message);
+ }
+
+ public TransactionException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public TransactionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java
new file mode 100644
index 0000000..fa101c2
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * 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.util.transaction;
+
+import org.eclipse.net4j.internal.util.transaction.Transaction;
+
+/**
+ * @author Eike Stepper
+ */
+public final class TransactionUtil
+{
+ private TransactionUtil()
+ {
+ }
+
+ public static ITransaction createTransaction()
+ {
+ return new Transaction();
+ }
+}