summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-13 16:58:13 (EDT)
committerEike Stepper2007-08-13 16:58:13 (EDT)
commite41633eba09459294ec1455cf7faae2af379ecd1 (patch)
tree1c49c55daaee5553cfed09fc416585fcc2c1583d
parent167eedf06e47d5bfa7e4aed9054ede183d86949c (diff)
downloadcdo-e41633eba09459294ec1455cf7faae2af379ecd1.zip
cdo-e41633eba09459294ec1455cf7faae2af379ecd1.tar.gz
cdo-e41633eba09459294ec1455cf7faae2af379ecd1.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java170
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java75
-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/PackageManager.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java (renamed from plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/StoreFactory.java)2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOReadIndication.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerIndication.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java175
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddPackageOperation.java41
-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/LoadPackageOperation.java35
-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.java155
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/QueryObjectTypeOperation.java36
-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.java174
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ISession.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java)12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java34
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java2
-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/internal/db/DBTransaction.java75
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java40
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransaction.java10
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/ITransactionalOperation.java8
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TX.java17
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/transaction/TransactionUtil.java4
47 files changed, 724 insertions, 1178 deletions
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 dc2e1fa..ffd60fd 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
@@ -10,186 +10,42 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
-import org.eclipse.emf.cdo.internal.server.PackageManager;
-import org.eclipse.emf.cdo.internal.server.RevisionManager;
-import org.eclipse.emf.cdo.internal.server.store.AddPackageOperation;
-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.LoadPackageOperation;
-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.QueryObjectTypeOperation;
-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.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.internal.server.Store;
+import org.eclipse.emf.cdo.server.IStoreReader;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBTransaction;
-import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.db.DBException;
import javax.sql.DataSource;
-import java.sql.Connection;
-import java.util.Map;
-
/**
* @author Eike Stepper
*/
-@SuppressWarnings("unused")
public class DBStore extends Store
{
private static final String TYPE = "db";
private DataSource dataSource;
- public DBStore(DataSource dataSource)
+ public DBStore(String storeID, DataSource dataSource)
{
- super(TYPE);
+ super(TYPE, storeID);
this.dataSource = dataSource;
}
- public ITransaction createTransaction()
- {
- return DBUtil.createTransaction(dataSource);
- }
-
- @Override
- protected AddPackageOperation createAddPackageOperation(PackageManager packageManager, CDOPackageImpl cdoPackage)
- {
- return new AddPackageOperation(packageManager, cdoPackage)
- {
- @Override
- protected void update(ITransaction transaction, CDOPackageImpl cdoPackage)
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .createAddPackageOperation()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
- }
-
- @Override
- protected LoadPackageOperation createLoadPackageOperation(CDOPackageImpl cdoPackage)
- {
- return new LoadPackageOperation(cdoPackage)
- {
- @Override
- protected void queryAndFill(ITransaction transaction, CDOPackageImpl cdoPackage)
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .createLoadPackageOperation()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
- }
-
- @Override
- protected AddRevisionOperation createAddRevisionOperation(RevisionManager revisionManager, CDORevisionImpl revision)
- {
- return new AddRevisionOperation(revisionManager, revision)
- {
- @Override
- protected void update(ITransaction transaction, CDORevisionImpl revision)
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // 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
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // 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
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // 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)
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .update()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
- }
-
- @Override
- protected LoadResourceIDOperation createLoadResourceIDOperation(String path)
+ public DataSource getDataSource()
{
- return new LoadResourceIDOperation(path)
- {
- @Override
- protected CDOID query(ITransaction transaction, String path) throws Exception
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .query()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
+ return dataSource;
}
- @Override
- protected LoadResourcePathOperation createLoadResourcePathOperation(CDOID id)
+ public IStoreReader getReader() throws DBException
{
- return new LoadResourcePathOperation(id)
- {
- @Override
- protected String query(ITransaction transaction, CDOID id) throws Exception
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .query()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
+ return new DBStoreReader(this);
}
- @Override
- protected QueryObjectTypeOperation createQueryObjectTypeOperation(CDOID id)
+ public IStoreWriter getWriter(IView view) throws DBException
{
- return new QueryObjectTypeOperation(id)
- {
- @Override
- protected CDOClassRef query(ITransaction transaction, CDOID id) throws Exception
- {
- Connection connection = ((IDBTransaction)transaction).getConnection();
- // TODO Implement method .query()
- throw new UnsupportedOperationException("Not yet implemented");
- }
- };
+ return new DBStoreWriter(this, view);
}
}
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 e2daf67..831f52f 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
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.internal.server.store.StoreFactory;
+import org.eclipse.emf.cdo.internal.server.StoreFactory;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.factory.ProductCreationException;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
new file mode 100644
index 0000000..b2985ee
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * 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.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IStoreReader;
+
+import org.eclipse.net4j.db.DBException;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStoreReader implements IStoreReader
+{
+ protected DBStore store;
+
+ protected Connection connection;
+
+ public DBStoreReader(DBStore store) throws DBException
+ {
+ this.store = store;
+
+ try
+ {
+ connection = store.getDataSource().getConnection();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ public void release() throws DBException
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ public DBStore getStore()
+ {
+ return store;
+ }
+
+ public void readPackage(CDOPackageImpl cdoPackage)
+ {
+ // TODO Implement method DBStoreReader.readPackage()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public CDORevision readRevision(CDOID id, long timeStamp)
+ {
+ // TODO Implement method DBStoreReader.readRevision()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public CDOID readResourceID(String path)
+ {
+ // TODO Implement method DBStoreReader.readResourceID()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public String readResourcePath(CDOID id)
+ {
+ // TODO Implement method DBStoreReader.readResourcePath()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public CDORevision readRevision(CDOID id)
+ {
+ // TODO Implement method DBStoreReader.readRevision()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public CDOClassRef readObjectType(CDOID id)
+ {
+ // TODO Implement method DBStoreReader.readObjectType()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
new file mode 100644
index 0000000..03b535e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * 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.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
+
+import org.eclipse.net4j.db.DBException;
+
+import java.sql.SQLException;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStoreWriter extends DBStoreReader implements IStoreWriter
+{
+ private IView view;
+
+ public DBStoreWriter(DBStore store, IView view) throws DBException
+ {
+ super(store);
+ this.view = view;
+
+ try
+ {
+ connection.setAutoCommit(false);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ @Override
+ public void release() throws DBException
+ {
+ try
+ {
+ connection.commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+
+ super.release();
+ }
+
+ public IView getView()
+ {
+ return view;
+ }
+
+ public void writePackage(CDOPackageImpl cdoPackage)
+ {
+ // TODO Implement method DBStoreWriter.writePackage()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void writeRevision(CDORevisionImpl revision)
+ {
+ // TODO Implement method DBStoreWriter.writeRevision()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+}
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 00e8d6d..92e5522 100644
--- a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
@@ -10,7 +10,6 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.emf.cdo.internal.server;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/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
index 9c0b9b0..287bba0 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -12,10 +12,13 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
-import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.server.IPackageManager;
+import org.eclipse.emf.cdo.server.IStoreReader;
+import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
/**
* @author Eike Stepper
@@ -34,37 +37,21 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
return repository;
}
- @Override
- public void addPackage(CDOPackageImpl cdoPackage)
+ public void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackageImpl[] cdoPackages)
{
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
- if (metaIDRange != null && metaIDRange.isTemporary())
- {
- CDOIDRange newRange = repository.getMetaIDRange(metaIDRange.getCount());
- cdoPackage.setMetaIDRange(newRange);
- }
-
- if (cdoPackage.isSystem())
- {
- addPackageToCache(cdoPackage);
- }
- else
+ for (CDOPackageImpl cdoPackage : cdoPackages)
{
- repository.getStore().addPackage(this, cdoPackage);
+ storeTransaction.execute(new AddPackageOperation(cdoPackage));
}
}
- public void addPackageToCache(CDOPackageImpl cdoPackage)
- {
- super.addPackage(cdoPackage);
- }
-
@Override
protected void resolve(CDOPackageImpl cdoPackage)
{
if (!cdoPackage.isSystem())
{
- repository.getStore().loadPackage(cdoPackage);
+ IStoreReader storeReader = StoreUtil.getReader();
+ storeReader.readPackage(cdoPackage);
}
}
@@ -73,4 +60,31 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
{
throw new ImplementationError("No generated model on server side");
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class AddPackageOperation implements ITransactionalOperation<IStoreWriter>
+ {
+ private CDOPackageImpl cdoPackage;
+
+ private AddPackageOperation(CDOPackageImpl cdoPackage)
+ {
+ this.cdoPackage = cdoPackage;
+ }
+
+ public void phase1(IStoreWriter storeWriter) throws Exception
+ {
+ storeWriter.writePackage(cdoPackage);
+ }
+
+ public void phase2(IStoreWriter storeWriter)
+ {
+ addPackage(cdoPackage);
+ }
+
+ public void undoPhase1(IStoreWriter storeWriter)
+ {
+ }
+ }
}
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 c0de8d5..b4c272c 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,13 +13,16 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.server.store.Store;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import java.text.MessageFormat;
import java.util.UUID;
@@ -37,7 +40,7 @@ public class Repository extends Container implements IRepository
private String name;
- private Store store;
+ private IStore store;
private String uuid;
@@ -55,7 +58,7 @@ public class Repository extends Container implements IRepository
private long nextMetaIDValue = INITIAL_META_ID_VALUE;
- private ConcurrentMap<CDOID, CDOClassRefImpl> types = new ConcurrentHashMap();
+ private ConcurrentMap<CDOID, CDOClassRef> objectTypes = new ConcurrentHashMap();
public Repository(String name)
{
@@ -73,12 +76,12 @@ public class Repository extends Container implements IRepository
return uuid;
}
- public Store getStore()
+ public IStore getStore()
{
return store;
}
- public void setStore(Store store)
+ public void setStore(IStore store)
{
this.store = store;
}
@@ -130,26 +133,26 @@ public class Repository extends Container implements IRepository
return id;
}
- public CDOClassRefImpl getObjectType(CDOID id)
+ public CDOClassRef getObjectType(IStoreReader storeReader, CDOID id)
{
- CDOClassRefImpl type = types.get(id);
+ CDOClassRef type = objectTypes.get(id);
if (type == null)
{
- type = store.queryObjectType(id);
+ type = storeReader.readObjectType(id);
if (type == null)
{
throw new ImplementationError("type == null");
}
- types.put(id, type);
+ objectTypes.put(id, type);
}
return type;
}
- public void setObjectType(CDOID id, CDOClassRefImpl type)
+ public void registerObjectType(CDOID id, CDOClassRefImpl type)
{
- types.putIfAbsent(id, type);
+ objectTypes.putIfAbsent(id, type);
}
@Override
@@ -157,4 +160,39 @@ public class Repository extends Container implements IRepository
{
return MessageFormat.format("Repository[{0}, {1}]", name, uuid);
}
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ if (store == null)
+ {
+ throw new IllegalStateException("No store for repository " + name);
+ }
+
+ if (!LifecycleUtil.isActive(store))
+ {
+ throw new IllegalStateException("Inactive store for repository " + name);
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ packageManager.activate();
+ sessionManager.activate();
+ resourceManager.activate();
+ revisionManager.activate();
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ revisionManager.deactivate();
+ resourceManager.deactivate();
+ sessionManager.deactivate();
+ packageManager.deactivate();
+ super.doDeactivate();
+ }
}
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 20d491b..3a5af88 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,6 +13,7 @@ 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.IStoreReader;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -71,19 +72,22 @@ public class ResourceManager extends Lifecycle implements IResourceManager
{
if (TRACER.isEnabled())
{
- TRACER.format("Registering resource: {0} --> {1}", id, path);
+ TRACER.format("Registering resource: {0} <--> {1}", id, path);
}
- repository.getStore().registerResource(id, path, idToPathMap, pathToIDMap);
+ idToPathMap.put(id, path);
+ pathToIDMap.put(path, id);
}
private CDOID loadID(String path)
{
- return repository.getStore().loadResourceID(path);
+ IStoreReader storeReader = StoreUtil.getReader();
+ return storeReader.readResourceID(path);
}
private String loadPath(CDOID id)
{
- return repository.getStore().loadResourcePath(id);
+ IStoreReader storeReader = StoreUtil.getReader();
+ return storeReader.readResourcePath(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 8186944..e5f1013 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,6 +15,11 @@ 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.IStoreReader;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+
+import org.eclipse.net4j.util.transaction.ITransaction;
+import org.eclipse.net4j.util.transaction.ITransactionalOperation;
/**
* @author Eike Stepper
@@ -36,36 +41,59 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
return repository;
}
- @Override
- public void addRevision(CDORevisionImpl revision)
+ public void addRevision(ITransaction<IStoreWriter> storeTransaction, CDORevisionImpl revision)
{
- repository.setObjectType(revision.getID(), revision.getCDOClass().createClassRef());
- repository.getStore().addRevision(this, revision);
- if (revision.isResource())
- {
- String path = (String)revision.getData().get(cdoPathFeature, -1);
- repository.getResourceManager().registerResource(revision.getID(), path);
- }
- }
-
- public void addRevisionToCache(CDORevisionImpl revision)
- {
- super.addRevision(revision);
+ storeTransaction.execute(new AddRevisionOperation(revision));
}
@Override
protected CDORevisionImpl loadRevision(CDOID id)
{
- CDORevisionImpl revision = repository.getStore().loadRevision(id);
- repository.setObjectType(revision.getID(), revision.getCDOClass().createClassRef());
+ IStoreReader storeReader = StoreUtil.getReader();
+ CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevision(id);
+ repository.registerObjectType(revision.getID(), revision.getCDOClass().createClassRef());
return revision;
}
@Override
protected CDORevisionImpl loadRevision(CDOID id, long timeStamp)
{
- CDORevisionImpl revision = repository.getStore().loadHistoricalRevision(id, timeStamp);
- repository.setObjectType(revision.getID(), revision.getCDOClass().createClassRef());
+ IStoreReader storeReader = StoreUtil.getReader();
+ CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevision(id, timeStamp);
+ repository.registerObjectType(revision.getID(), revision.getCDOClass().createClassRef());
return revision;
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class AddRevisionOperation implements ITransactionalOperation<IStoreWriter>
+ {
+ private CDORevisionImpl revision;
+
+ private AddRevisionOperation(CDORevisionImpl revision)
+ {
+ this.revision = revision;
+ }
+
+ public void phase1(IStoreWriter storeWriter) throws Exception
+ {
+ storeWriter.writeRevision(revision);
+ }
+
+ public void phase2(IStoreWriter storeWriter)
+ {
+ repository.registerObjectType(revision.getID(), revision.getCDOClass().createClassRef());
+ addRevision(revision);
+ if (revision.isResource())
+ {
+ String path = (String)revision.getData().get(cdoPathFeature, -1);
+ repository.getResourceManager().registerResource(revision.getID(), path);
+ }
+ }
+
+ public void undoPhase1(IStoreWriter storeWriter)
+ {
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index ffa9fc1..85c70d8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.SessionCreationException;
import org.eclipse.emf.cdo.server.IView.Type;
@@ -109,6 +110,11 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
return views.values().toArray(new View[views.size()]);
}
+ public View getView(int viewID)
+ {
+ return views.get(viewID);
+ }
+
public void notifyViewsChanged(Session session, int viewID, byte kind)
{
if (kind == CDOProtocolConstants.VIEW_CLOSED)
@@ -169,8 +175,10 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
return id;
}
+ IStoreReader storeReader = StoreUtil.getReader();
+ CDOClassRef type = storeReader.readObjectType(id);
+
knownObjects.add(id);
- CDOClassRef type = sessionManager.getRepository().getObjectType(id);
return CDOIDImpl.create(id.getValue(), type);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
new file mode 100644
index 0000000..c2d94f3
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.emf.cdo.server.IStore;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Store implements IStore
+{
+ private String type;
+
+ private String storeID;
+
+ public Store(String type, String storeID)
+ {
+ this.type = type;
+ this.storeID = storeID;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public String getStoreID()
+ {
+ return storeID;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/StoreFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java
index ff9fd21..0bc150c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/StoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreFactory.java
@@ -8,7 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.emf.cdo.internal.server.store;
+package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.server.IStore;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java
new file mode 100644
index 0000000..2069051
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * 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;
+
+import org.eclipse.emf.cdo.server.IStoreReader;
+
+/**
+ * @author Eike Stepper
+ */
+public final class StoreUtil
+{
+ private static final ThreadLocal<IStoreReader> THREAD_LOCAL = new InheritableThreadLocal();
+
+ private StoreUtil()
+ {
+ }
+
+ public static void setReader(IStoreReader reader)
+ {
+ THREAD_LOCAL.set(reader);
+ }
+
+ public static IStoreReader getReader()
+ {
+ IStoreReader reader = THREAD_LOCAL.get();
+ if (reader == null)
+ {
+ throw new IllegalStateException("reader == null");
+ }
+
+ return reader;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOReadIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOReadIndication.java
new file mode 100644
index 0000000..426878a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOReadIndication.java
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * 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.emf.cdo.internal.server.protocol;
+
+import org.eclipse.emf.cdo.internal.server.StoreUtil;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreReader;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+import java.io.IOException;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CDOReadIndication extends CDOServerIndication
+{
+ public CDOReadIndication(short signalID)
+ {
+ super(signalID);
+ }
+
+ @Override
+ protected final void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ IStore store = getStore();
+ IStoreReader storeReader = store.getReader();
+
+ try
+ {
+ StoreUtil.setReader(storeReader);
+ accessStore(in);
+ }
+ finally
+ {
+ storeReader.release();
+ StoreUtil.setReader(null);
+ }
+ }
+
+ protected abstract void accessStore(ExtendedDataInputStream in) throws IOException;
+}
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 da4e7ab..cc3901f 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
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
-import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.PackageManager;
+import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.ResourceManager;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
import org.eclipse.emf.cdo.internal.server.Session;
@@ -19,8 +19,6 @@ import org.eclipse.emf.cdo.internal.server.SessionManager;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.transaction.TX;
-import org.eclipse.net4j.util.transaction.TransactionException;
/**
* @author Eike Stepper
@@ -80,20 +78,4 @@ public abstract class CDOServerIndication extends IndicationWithResponse
{
return (CDOServerProtocol)super.getProtocol();
}
-
- protected void transact(Runnable runnable) throws TransactionException
- {
- TX.begin();
-
- 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/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index bb10975..496ab63 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -13,19 +13,31 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.server.PackageManager;
+import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
+import org.eclipse.emf.cdo.internal.server.StoreUtil;
+import org.eclipse.emf.cdo.internal.server.View;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
+import org.eclipse.emf.cdo.protocol.model.core.CDOCorePackage;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOResourcePackage;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.internal.util.transaction.Transaction;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.IORuntimeException;
+import org.eclipse.net4j.util.transaction.ITransaction;
import java.io.IOException;
import java.util.HashMap;
@@ -54,50 +66,63 @@ public class CommitTransactionIndication extends CDOServerIndication
private long timeStamp;
+ private PackageManager sessionPackageManager;
+
+ private CDOPackageManager transactionPackageManager;
+
+ private View view;
+
public CommitTransactionIndication()
{
super(CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION);
+ sessionPackageManager = getPackageManager();
+ transactionPackageManager = new TransactionPackageManager();
}
@Override
- protected void indicating(final ExtendedDataInputStream in) throws IOException
+ protected void indicating(ExtendedDataInputStream in) throws IOException
{
timeStamp = System.currentTimeMillis();
int viewID = in.readInt();
- transact(new Runnable()
+
+ view = getSession().getView(viewID);
+ if (view == null || view.getViewType() != IView.Type.TRANSACTION)
{
- public void run()
- {
- try
- {
- addNewPackages(in);
- newResources = readNewResources(in);
- newObjects = readNewObjects(in);
- dirtyObjects = readDirtyObjects(in);
- }
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
+ throw new IllegalStateException("Illegal view: " + view);
+ }
- addRevisions(newResources);
- addRevisions(newObjects);
- addRevisions(dirtyObjects);
- }
- });
+ newPackages = readNewPackages(in);
+ newResources = readNewResources(in);
+ newObjects = readNewObjects(in);
+ dirtyObjects = readDirtyObjects(in);
+
+ IStore store = getStore();
+ IStoreWriter storeWriter = store.getWriter(view);
+ try
+ {
+ StoreUtil.setReader(storeWriter);
+ ITransaction<IStoreWriter> storeTransaction = new Transaction(storeWriter);
+ addPackages(storeTransaction, newPackages);
+ addRevisions(storeTransaction, newResources);
+ addRevisions(storeTransaction, newObjects);
+ addRevisions(storeTransaction, dirtyObjects);
+ storeTransaction.commit();
+ }
+ finally
+ {
+ storeWriter.release();
+ StoreUtil.setReader(null);
+ }
}
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
out.writeLong(timeStamp);
- if (newPackages != null)
+ for (CDOPackageImpl newPackage : newPackages)
{
- for (CDOPackageImpl newPackage : newPackages)
- {
- CDOIDRangeImpl.write(out, newPackage.getMetaIDRange());
- }
+ CDOIDRangeImpl.write(out, newPackage.getMetaIDRange());
}
writeIDMappings(out);
@@ -107,7 +132,7 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- private void addNewPackages(ExtendedDataInputStream in) throws IOException
+ private CDOPackageImpl[] readNewPackages(ExtendedDataInputStream in) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -115,17 +140,16 @@ public class CommitTransactionIndication extends CDOServerIndication
PROTOCOL.format("Reading {0} new packages", size);
}
- if (size != 0)
+ Repository repository = getRepository();
+ CDOPackageImpl[] newPackages = new CDOPackageImpl[size];
+ for (int i = 0; i < size; i++)
{
- PackageManager packageManager = getPackageManager();
- newPackages = new CDOPackageImpl[size];
- for (int i = 0; i < size; i++)
+ newPackages[i] = new CDOPackageImpl(sessionPackageManager, in);
+ CDOIDRange oldRange = newPackages[i].getMetaIDRange();
+ if (oldRange != null && oldRange.isTemporary())
{
- newPackages[i] = new CDOPackageImpl(packageManager, in);
- CDOIDRange oldRange = newPackages[i].getMetaIDRange();
-
- packageManager.addPackage(newPackages[i]);
- CDOIDRange newRange = newPackages[i].getMetaIDRange();
+ CDOIDRange newRange = repository.getMetaIDRange(oldRange.getCount());
+ newPackages[i].setMetaIDRange(newRange);
long count = oldRange.getCount();
for (long l = 0; l < count; l++)
@@ -142,6 +166,8 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
}
+
+ return newPackages;
}
private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in) throws IOException
@@ -179,25 +205,29 @@ public class CommitTransactionIndication extends CDOServerIndication
private CDORevisionImpl[] readRevisions(ExtendedDataInputStream in, int size) throws IOException
{
- CDOPackageManagerImpl packageManager = getRepository().getPackageManager();
CDORevisionImpl[] revisions = new CDORevisionImpl[size];
for (int i = 0; i < size; i++)
{
- revisions[i] = new CDORevisionImpl(packageManager, in);
+ revisions[i] = new CDORevisionImpl(in, transactionPackageManager);
mapTemporaryID(revisions[i]);
}
return revisions;
}
- private void addRevisions(CDORevisionImpl[] revisions)
+ private void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackageImpl[] newPackages)
+ {
+ sessionPackageManager.addPackages(storeTransaction, newPackages);
+ }
+
+ private void addRevisions(ITransaction<IStoreWriter> storeTransaction, CDORevisionImpl[] revisions)
{
RevisionManager revisionManager = getRevisionManager();
for (CDORevisionImpl revision : revisions)
{
revision.setCreated(timeStamp);
revision.adjustReferences(idMappings);
- revisionManager.addRevision(revision);
+ revisionManager.addRevision(storeTransaction, revision);
}
}
@@ -232,4 +262,67 @@ public class CommitTransactionIndication extends CDOServerIndication
CDOIDImpl.write(out, CDOID.NULL);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class TransactionPackageManager implements CDOPackageManager
+ {
+ public TransactionPackageManager()
+ {
+ }
+
+ public CDOPackageImpl lookupPackage(String uri)
+ {
+ for (CDOPackageImpl cdoPackage : newPackages)
+ {
+ if (ObjectUtil.equals(cdoPackage.getPackageURI(), uri))
+ {
+ return cdoPackage;
+ }
+ }
+
+ return sessionPackageManager.lookupPackage(uri);
+ }
+
+ public CDOCorePackage getCDOCorePackage()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOResourcePackage getCDOResourcePackage()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getPackageCount()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOPackage[] getPackages()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOPackage[] getElements()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isEmpty()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addListener(IListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeListener(IListener listener)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
index 1c6bd13..f72d6c1 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
@@ -24,7 +24,7 @@ import java.io.IOException;
* @author Eike Stepper
*/
@SuppressWarnings("unused")
-public class LoadPackageIndication extends CDOServerIndication
+public class LoadPackageIndication extends CDOReadIndication
{
private CDOPackageImpl cdoPackage;
@@ -34,7 +34,7 @@ public class LoadPackageIndication extends CDOServerIndication
}
@Override
- protected void indicating(ExtendedDataInputStream in) throws IOException
+ protected void accessStore(ExtendedDataInputStream in) throws IOException
{
String packageURI = in.readString();
PackageManager packageManager = getPackageManager();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
index d6da2a0..5af5def 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
@@ -26,7 +26,7 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class LoadRevisionIndication extends CDOServerIndication
+public class LoadRevisionIndication extends CDOReadIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionIndication.class);
@@ -40,7 +40,7 @@ public class LoadRevisionIndication extends CDOServerIndication
}
@Override
- protected void indicating(ExtendedDataInputStream in) throws IOException
+ protected void accessStore(ExtendedDataInputStream in) throws IOException
{
id = CDOIDImpl.read(in);
if (PROTOCOL.isEnabled())
@@ -62,16 +62,8 @@ public class LoadRevisionIndication extends CDOServerIndication
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- final CDORevisionImpl[] revision = new CDORevisionImpl[1];
- transact(new Runnable()
- {
- public void run()
- {
- RevisionManager rm = getRevisionManager();
- revision[0] = timeStamp != null ? rm.getRevision(id, timeStamp) : rm.getRevision(id);
- }
- });
-
- revision[0].write(out, getSession());
+ RevisionManager rm = getRevisionManager();
+ CDORevisionImpl revision = timeStamp != null ? rm.getRevision(id, timeStamp) : rm.getRevision(id);
+ revision.write(out, getSession());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
index 1fcd39b..cda0b65 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
@@ -24,7 +24,7 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class ResourceIDIndication extends CDOServerIndication
+public class ResourceIDIndication extends CDOReadIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, ResourceIDIndication.class);
@@ -36,7 +36,7 @@ public class ResourceIDIndication extends CDOServerIndication
}
@Override
- protected void indicating(ExtendedDataInputStream in) throws IOException
+ protected void accessStore(ExtendedDataInputStream in) throws IOException
{
// TODO Optimize transfer of URIs/paths
final String path = in.readString();
@@ -45,21 +45,7 @@ public class ResourceIDIndication extends CDOServerIndication
PROTOCOL.format("Read path: {0}", path);
}
- try
- {
- transact(new Runnable()
- {
- public void run()
- {
- id = getResourceManager().getResourceID(path);
- }
- });
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- id = CDOID.NULL;
- }
+ id = getResourceManager().getResourceID(path);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
index b537044..4dfcc37 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
@@ -24,7 +24,7 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class ResourcePathIndication extends CDOServerIndication
+public class ResourcePathIndication extends CDOReadIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, ResourcePathIndication.class);
@@ -36,7 +36,7 @@ public class ResourcePathIndication extends CDOServerIndication
}
@Override
- protected void indicating(ExtendedDataInputStream in) throws IOException
+ protected void accessStore(ExtendedDataInputStream in) throws IOException
{
final CDOID id = CDOIDImpl.read(in);
if (PROTOCOL.isEnabled())
@@ -44,13 +44,7 @@ public class ResourcePathIndication extends CDOServerIndication
PROTOCOL.format("Read ID: {0}", id);
}
- transact(new Runnable()
- {
- public void run()
- {
- path = getResourceManager().getResourcePath(id);
- }
- });
+ path = getResourceManager().getResourcePath(id);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddPackageOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddPackageOperation.java
deleted file mode 100644
index 0b4fffa..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddPackageOperation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.eclipse.emf.cdo.internal.server.store;
-
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.server.PackageManager;
-
-import org.eclipse.net4j.util.transaction.ITransaction;
-import org.eclipse.net4j.util.transaction.ITransactionalOperation;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AddPackageOperation<T extends ITransaction> implements ITransactionalOperation<T, Object>
-{
- private PackageManager packageManager;
-
- private CDOPackageImpl cdoPackage;
-
- public AddPackageOperation(PackageManager packageManager, CDOPackageImpl cdoPackage)
- {
- this.packageManager = packageManager;
- this.cdoPackage = cdoPackage;
- }
-
- public Object prepare(T transaction) throws Exception
- {
- update(transaction, cdoPackage);
- packageManager.addPackageToCache(cdoPackage);
- return null;
- }
-
- public void onCommit(T transaction)
- {
- }
-
- public void onRollback(T transaction)
- {
- packageManager.removePackage(cdoPackage);
- }
-
- protected abstract void update(T transaction, CDOPackageImpl cdoPackage);
-} \ 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
deleted file mode 100644
index 43f1d06..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/AddRevisionOperation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644
index 8ee97f7..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadHistoricalRevisionOperation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-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/LoadPackageOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadPackageOperation.java
deleted file mode 100644
index 18c8b4a..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadPackageOperation.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.eclipse.emf.cdo.internal.server.store;
-
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-
-import org.eclipse.net4j.util.transaction.ITransaction;
-import org.eclipse.net4j.util.transaction.ITransactionalOperation;
-
-/**
- * @author Eike Stepper
- */
-public abstract class LoadPackageOperation<T extends ITransaction> implements ITransactionalOperation<T, Object>
-{
- private CDOPackageImpl cdoPackage;
-
- public LoadPackageOperation(CDOPackageImpl cdoPackage)
- {
- this.cdoPackage = cdoPackage;
- }
-
- public Object prepare(T transaction) throws Exception
- {
- queryAndFill(transaction, cdoPackage);
- return null;
- }
-
- public void onCommit(T transaction)
- {
- }
-
- public void onRollback(T transaction)
- {
- }
-
- protected abstract void queryAndFill(T transaction, CDOPackageImpl cdoPackage);
-} \ 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
deleted file mode 100644
index 5c83381..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourceIDOperation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-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
deleted file mode 100644
index 1e81dab..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadResourcePathOperation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-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
deleted file mode 100644
index 0256f47..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/LoadRevisionOperation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-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
deleted file mode 100644
index ce4a1f6..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/NOOPStore.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/***************************************************************************
- * 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.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
-import org.eclipse.emf.cdo.internal.server.PackageManager;
-import org.eclipse.emf.cdo.internal.server.RevisionManager;
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-
-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 AddPackageOperation createAddPackageOperation(PackageManager packageManager, CDOPackageImpl cdoPackage)
- {
- return new AddPackageOperation(packageManager, cdoPackage)
- {
- @Override
- protected void update(ITransaction transaction, CDOPackageImpl cdoPackage)
- {
- }
- };
- }
-
- @Override
- protected LoadPackageOperation createLoadPackageOperation(CDOPackageImpl cdoPackage)
- {
- return new LoadPackageOperation(cdoPackage)
- {
- @Override
- protected void queryAndFill(ITransaction transaction, CDOPackageImpl cdoPackage)
- {
- }
- };
- }
-
- @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
- {
- return null;
- }
- };
- }
-
- @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
- {
- return null;
- }
- };
- }
-
- @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
- {
- return null;
- }
- };
- }
-
- @Override
- protected LoadResourcePathOperation createLoadResourcePathOperation(CDOID id)
- {
- return new LoadResourcePathOperation(id)
- {
- @Override
- protected String query(ITransaction transaction, CDOID id) throws Exception
- {
- return null;
- }
- };
- }
-
- @Override
- protected QueryObjectTypeOperation createQueryObjectTypeOperation(CDOID id)
- {
- return new QueryObjectTypeOperation(id)
- {
- @Override
- protected CDOClassRef query(ITransaction transaction, CDOID id) throws Exception
- {
- return null;
- }
- };
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/QueryObjectTypeOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/QueryObjectTypeOperation.java
deleted file mode 100644
index 29bbf83..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/QueryObjectTypeOperation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.eclipse.emf.cdo.internal.server.store;
-
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-
-import org.eclipse.net4j.util.transaction.ITransaction;
-import org.eclipse.net4j.util.transaction.ITransactionalOperation;
-
-/**
- * @author Eike Stepper
- */
-public abstract class QueryObjectTypeOperation<T extends ITransaction> implements
- ITransactionalOperation<T, CDOClassRef>
-{
- private CDOID id;
-
- public QueryObjectTypeOperation(CDOID id)
- {
- this.id = id;
- }
-
- public CDOClassRef prepare(T transaction) throws Exception
- {
- return query(transaction, id);
- }
-
- public void onCommit(T transaction)
- {
- }
-
- public void onRollback(T transaction)
- {
- }
-
- protected abstract CDOClassRef 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/RegisterResourceOperation.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java
deleted file mode 100644
index 01be1f7..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/RegisterResourceOperation.java
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index 504e1c2..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/store/Store.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/***************************************************************************
- * 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.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
-import org.eclipse.emf.cdo.internal.server.Repository;
-import org.eclipse.emf.cdo.internal.server.PackageManager;
-import org.eclipse.emf.cdo.internal.server.RevisionManager;
-import org.eclipse.emf.cdo.internal.server.bundle.OM;
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.server.IStore;
-
-import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.transaction.TX;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public abstract class Store implements IStore
-{
- public static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, Store.class);
-
- 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)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting repository: {0} ({1})", repository.getName(), repository.getUUID());
- }
-
- this.repository = repository;
- }
-
- public void registerResource(CDOID id, String path, Map<CDOID, String> idToPathMap, Map<String, CDOID> pathToIDMap)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Registering resource: {0}", id);
- }
-
- TX.execute(createRegisterResourceOperation(id, path, idToPathMap, pathToIDMap));
- }
-
- public CDOID loadResourceID(String path)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading resource ID: {0}", path);
- }
-
- return (CDOID)TX.execute(createLoadResourceIDOperation(path));
- }
-
- public String loadResourcePath(CDOID id)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading resource path: {0}", id);
- }
-
- return (String)TX.execute(createLoadResourcePathOperation(id));
- }
-
- public void addPackage(PackageManager packageManager, CDOPackageImpl cdoPackage)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Adding package: {0}", cdoPackage);
- }
-
- TX.execute(createAddPackageOperation(packageManager, cdoPackage));
- }
-
- public void loadPackage(CDOPackageImpl cdoPackage)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading package: {0}", cdoPackage);
- }
-
- TX.execute(createLoadPackageOperation(cdoPackage));
- }
-
- public void addRevision(RevisionManager revisionManager, CDORevisionImpl revision)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Adding revision: {0}", revision);
- }
-
- TX.execute(createAddRevisionOperation(revisionManager, revision));
- }
-
- public CDORevisionImpl loadRevision(CDOID id)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading revision: {0}", id);
- }
-
- return (CDORevisionImpl)TX.execute(createLoadRevisionOperation(id));
- }
-
- public CDORevisionImpl loadHistoricalRevision(CDOID id, long timeStamp)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading historical revision: {0} ({1,date} {1,time})", id, timeStamp);
- }
-
- return (CDORevisionImpl)TX.execute(createLoadHistoricalRevisionOperation(id, timeStamp));
- }
-
- public CDOClassRefImpl queryObjectType(CDOID id)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Querying object type: {0}", id);
- }
-
- return (CDOClassRefImpl)TX.execute(createQueryObjectTypeOperation(id));
- }
-
- 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 AddPackageOperation createAddPackageOperation(PackageManager packageManager,
- CDOPackageImpl cdoPackage);
-
- protected abstract LoadPackageOperation createLoadPackageOperation(CDOPackageImpl cdoPackage);
-
- protected abstract AddRevisionOperation createAddRevisionOperation(RevisionManager revisionManager,
- CDORevisionImpl revision);
-
- protected abstract LoadRevisionOperation createLoadRevisionOperation(CDOID id);
-
- protected abstract LoadHistoricalRevisionOperation createLoadHistoricalRevisionOperation(CDOID id, long timeStamp);
-
- protected abstract QueryObjectTypeOperation createQueryObjectTypeOperation(CDOID id);
-}
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 784d750..de9d3f1 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
@@ -34,5 +34,5 @@ public interface IRepository extends IContainer
public IRevisionManager getRevisionManager();
- public CDOClassRef getObjectType(CDOID id);
+ public CDOClassRef getObjectType(IStoreReader storeReader, CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ISession.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ISession.java
index 007a196..e66b1a0 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ISession.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ISession.java
@@ -26,4 +26,6 @@ public interface ISession extends IContainer<IView>
public int getSessionID();
public IView[] getViews();
+
+ public IView getView(int viewID);
}
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
index 2cbe4fb..7b3e5c1 100644
--- 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
@@ -10,16 +10,6 @@
**************************************************************************/
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.emf.cdo.protocol.model.CDOClassRef;
-import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-
-import org.eclipse.net4j.util.transaction.ITransaction;
-
-import java.util.Map;
-
/**
* @author Eike Stepper
*/
@@ -27,21 +17,9 @@ 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 CDORevision loadRevision(CDOID id);
+ public String getStoreID();
- public CDORevision loadHistoricalRevision(CDOID id, long timeStamp);
+ public IStoreReader getReader();
- public CDOClassRef queryObjectType(CDOID id);
+ public IStoreWriter getWriter(IView view);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
index 9dc9d5e..631b799 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
@@ -8,16 +8,14 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.net4j.db;
-
-import org.eclipse.net4j.util.transaction.ITransaction;
-
-import java.sql.Connection;
+package org.eclipse.emf.cdo.server;
/**
* @author Eike Stepper
*/
-public interface IDBTransaction extends ITransaction
+public interface IStoreAccessor
{
- public Connection getConnection();
+ public IStore getStore();
+
+ public void release();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
new file mode 100644
index 0000000..2b1d50c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * 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.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IStoreReader extends IStoreAccessor
+{
+ public void readPackage(CDOPackageImpl cdoPackage);
+
+ public CDOID readResourceID(String path);
+
+ public String readResourcePath(CDOID id);
+
+ public CDORevision readRevision(CDOID id);
+
+ public CDORevision readRevision(CDOID id, long timeStamp);
+
+ public CDOClassRef readObjectType(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
new file mode 100644
index 0000000..fd9c75d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IStoreWriter extends IStoreReader
+{
+ public IView getView();
+
+ public void writePackage(CDOPackageImpl cdoPackage);
+
+ public void writeRevision(CDORevisionImpl revision);
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 027f832..59cedd7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -16,11 +16,11 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.ConnectorException;
@@ -377,8 +377,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
public CDOClassImpl requestObjectType(CDOID id)
{
- CDOClassRef typeRef = null; // FIXME
- CDOClassImpl type = packageManager.resolveClass(typeRef);
+ CDOClassRefImpl typeRef = null; // FIXME
+ CDOClassImpl type = typeRef.resolve(packageManager);
registerObjectType(id, type);
return type;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 7ece4f3..81c976e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -329,7 +329,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
CDOIDTyped typed = (CDOIDTyped)id;
CDOClassRef typeRef = typed.getType();
- type = session.getPackageManager().resolveClass(typeRef);
+ type = (CDOClassImpl)typeRef.resolve(session.getPackageManager());
session.registerObjectType(id, type);
return type;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
index eeb070a..3e4a8aa 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java
@@ -75,6 +75,6 @@ public class LoadRevisionRequest extends CDOClientRequest<CDORevisionImpl>
@Override
protected CDORevisionImpl confirming(ExtendedDataInputStream in) throws IOException
{
- return new CDORevisionImpl(getSession().getPackageManager(), in);
+ return new CDORevisionImpl(in, getSession().getPackageManager());
}
}
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 9e3f5bb..f799a4a 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,13 +11,11 @@
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;
/**
@@ -60,28 +58,4 @@ 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/internal/db/DBTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
deleted file mode 100644
index 05a8795..0000000
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************
- * 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/src/org/eclipse/net4j/internal/util/transaction/Transaction.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/transaction/Transaction.java
index a31963f..dae4d7b 100644
--- 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
@@ -20,16 +20,28 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class Transaction implements ITransaction
+public class Transaction<CONTEXT> implements ITransaction<CONTEXT>
{
private List<ITransactionalOperation> operations = new ArrayList();
+ private CONTEXT context;
+
+ public Transaction(CONTEXT context)
+ {
+ this.context = context;
+ }
+
public boolean isActive()
{
return operations != null;
}
- public <R> R execute(ITransactionalOperation<ITransaction, R> operation) throws TransactionException
+ public CONTEXT getContext()
+ {
+ return context;
+ }
+
+ public void execute(ITransactionalOperation<CONTEXT> operation) throws TransactionException
{
if (!isActive())
{
@@ -38,8 +50,8 @@ public class Transaction implements ITransaction
try
{
+ operation.phase1(context);
operations.add(operation);
- return operation.prepare(this);
}
catch (TransactionException ex)
{
@@ -53,33 +65,19 @@ public class Transaction implements ITransaction
}
}
- public void commit() throws TransactionException
+ public void commit()
{
for (ITransactionalOperation operation : end())
{
- try
- {
- operation.onCommit(this);
- }
- catch (RuntimeException ex)
- {
- throw new TransactionException("Unexpected problem during commit", ex);
- }
+ operation.phase2(context);
}
}
- public void rollback() throws TransactionException
+ public void rollback()
{
for (ITransactionalOperation operation : end())
{
- try
- {
- operation.onRollback(this);
- }
- catch (RuntimeException ex)
- {
- throw new TransactionException("Unexpected problem during rollback", ex);
- }
+ operation.undoPhase1(context);
}
}
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
index f3f8786..0eb87b0 100644
--- 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
@@ -13,13 +13,15 @@ package org.eclipse.net4j.util.transaction;
/**
* @author Eike Stepper
*/
-public interface ITransaction
+public interface ITransaction<CONTEXT>
{
public boolean isActive();
- public <R> R execute(ITransactionalOperation<ITransaction, R> operation) throws TransactionException;
+ public CONTEXT getContext();
- public void commit() throws TransactionException;
+ public void execute(ITransactionalOperation<CONTEXT> operation) throws TransactionException;
- public void rollback() throws TransactionException;
+ public void commit();
+
+ public void rollback();
}
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
index 8edff47..fce42f4 100644
--- 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
@@ -13,11 +13,11 @@ package org.eclipse.net4j.util.transaction;
/**
* @author Eike Stepper
*/
-public interface ITransactionalOperation<T extends ITransaction, R>
+public interface ITransactionalOperation<CONTEXT>
{
- public R prepare(T transaction) throws Exception;
+ public void phase1(CONTEXT context) throws Exception;
- public void onCommit(T transaction);
+ public void phase2(CONTEXT context);
- public void onRollback(T transaction);
+ public void undoPhase1(CONTEXT context);
}
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
index a3bb8ec..fde1b50 100644
--- 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
@@ -21,18 +21,10 @@ public final class TX
{
}
- public static <R> R execute(ITransactionalOperation<ITransaction, R> operation)
+ public static void execute(ITransactionalOperation<ITransaction> operation)
{
ITransaction transaction = get();
-
- try
- {
- return transaction.execute(operation);
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
+ transaction.execute(operation);
}
public static void begin(ITransaction transaction)
@@ -46,11 +38,6 @@ public final class TX
tx.set(transaction);
}
- public static void begin()
- {
- begin(TransactionUtil.createTransaction());
- }
-
public static void commit()
{
ITransaction transaction = get();
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
index fa101c2..5f1ad9d 100644
--- 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
@@ -21,8 +21,8 @@ public final class TransactionUtil
{
}
- public static ITransaction createTransaction()
+ public static <CONTEXT> ITransaction<CONTEXT> createTransaction(CONTEXT context)
{
- return new Transaction();
+ return new Transaction(context);
}
}