summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-23 03:20:58 (EST)
committerEike Stepper2008-02-23 03:20:58 (EST)
commitdf3b1fdd17dfabb7925a02139def2084203a8c2d (patch)
tree8eaeb7b8f8de863ebceabd8338476875ec532cca
parent5ca35c866363c9e2cdc36700f8408a4b2f97985e (diff)
downloadcdo-df3b1fdd17dfabb7925a02139def2084203a8c2d.zip
cdo-df3b1fdd17dfabb7925a02139def2084203a8c2d.tar.gz
cdo-df3b1fdd17dfabb7925a02139def2084203a8c2d.tar.bz2
[217117] Develop a HibernateStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=217117
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java103
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/.options1
-rw-r--r--plugins/org.eclipse.emf.cdo.server/CommitTransactionIndicationOLD.java403
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourceManager.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java117
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java123
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java453
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java369
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationNotification.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java79
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/plugin.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/HibernateTest.java106
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java59
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionFinishedEvent.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java29
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java106
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java39
48 files changed, 1568 insertions, 902 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index 4089dd8..2ab41d7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -560,6 +560,7 @@ public abstract class ClassMapping implements IClassMapping
{
TRACER.trace(sql);
}
+
ResultSet resultSet = null;
try
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 aec44d3..5f744b9 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
@@ -101,18 +101,21 @@ public class DBStore extends LongIDStore implements IDBStore
return dbConnectionProvider;
}
- @Override
public boolean hasAuditingSupport()
{
return true;
}
- @Override
public boolean hasBranchingSupport()
{
return false;
}
+ public boolean hasWriteDeltaSupport()
+ {
+ return false;
+ }
+
@Override
public DBStoreReader getReader(ISession session)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 3e88ccc..6ec6e29 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -34,8 +34,6 @@ import java.util.Set;
*/
public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
{
- // private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreAccessor.class);
-
private Connection connection;
private Statement statement;
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
index 00eb11e..b9d6789 100644
--- 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
@@ -12,7 +12,6 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
-import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDMeta;
import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
@@ -46,29 +45,52 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
super(store, view);
}
- public CDOID primeNewObject(CDOClass cdoClass)
+ @Override
+ public void commit(CommitContext context)
{
- return getStore().getNextCDOID();
+ super.commit(context);
+
+ try
+ {
+ getConnection().commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
}
- public void writePackages(CDOPackage... cdoPackages)
+ @Override
+ public void rollback(CommitContext context)
{
- for (CDOPackage cdoPackage : cdoPackages)
+ super.rollback(context);
+
+ try
{
- writePackage(cdoPackage);
+ getConnection().rollback();
}
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+ @Override
+ protected void writePackages(CDOPackage... cdoPackages)
+ {
+ super.writePackages(cdoPackages);
Set<IDBTable> affectedTables = mapPackages(cdoPackages);
getStore().getDBAdapter().createTables(affectedTables, getConnection());
}
+ @Override
protected void writePackage(CDOPackage cdoPackage)
{
int id = getStore().getNextPackageID();
PackageServerInfo.setDBID(cdoPackage, id);
if (TRACER.isEnabled())
{
- TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
+ TRACER.format("Writing package: {0} --> {1}", cdoPackage, id);
}
String packageURI = cdoPackage.getPackageURI();
@@ -76,8 +98,8 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
String ecore = cdoPackage.getEcore();
boolean dynamic = cdoPackage.isDynamic();
CDOIDMetaRange metaIDRange = cdoPackage.getMetaIDRange();
- long lowerBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getLowerBound()).getValue();
- long upperBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getUpperBound()).getValue();
+ long lowerBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getLowerBound()).getLongValue();
+ long upperBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getUpperBound()).getLongValue();
String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?)";
DBUtil.trace(sql);
@@ -113,12 +135,10 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
DBUtil.close(pstmt);
}
- for (CDOClass cdoClass : cdoPackage.getClasses())
- {
- writeClass((CDOClassImpl)cdoClass);
- }
+ super.writePackage(cdoPackage);
}
+ @Override
protected void writeClass(CDOClassImpl cdoClass)
{
int id = getStore().getNextClassID();
@@ -132,25 +152,19 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
DBUtil.insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.CLASSES, id, packageID, classifierID,
name, isAbstract);
- for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
- {
- writeSuperType(id, superType);
- }
-
- for (CDOFeature feature : cdoClass.getFeatures())
- {
- writeFeature(feature);
- }
+ super.writeClass(cdoClass);
}
- protected void writeSuperType(int type, CDOClassProxy superType)
+ @Override
+ protected void writeSuperType(CDOClassImpl type, CDOClassProxy superType)
{
+ int id = ClassServerInfo.getDBID(type);
String packageURI = superType.getPackageURI();
int classifierID = superType.getClassifierID();
- DBUtil
- .insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
+ DBUtil.insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.SUPERTYPES, id, packageURI, classifierID);
}
+ @Override
protected void writeFeature(CDOFeature feature)
{
int id = getStore().getNextFeatureID();
@@ -170,11 +184,12 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
type, packageURI, classifierID, many, containment, idx);
}
- public void writeRevision(CDORevision revision)
+ @Override
+ protected void writeRevision(CDORevision revision)
{
if (TRACER.isEnabled())
{
- TRACER.format("Inserting revision: {0}", revision);
+ TRACER.format("Writing revision: {0}", revision);
}
CDOClass cdoClass = revision.getCDOClass();
@@ -182,38 +197,4 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
mapping.writeRevision(this, revision);
}
-
- public void commit()
- {
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Committing transaction: {0}", getView());
- }
-
- getConnection().commit();
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- }
-
- public void rollback()
- {
- try
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Rolling back transaction: {0}", getView());
- }
-
- getConnection().rollback();
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
index f4b18fd..6b45441 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
@@ -85,13 +85,11 @@ public class NoClassMapping implements IClassMapping
{
}
- public void readRevisionByTime(IDBStoreReader storeReader, CDORevision revision, long timeStamp,
- int referenceChunk)
+ public void readRevisionByTime(IDBStoreReader storeReader, CDORevision revision, long timeStamp, int referenceChunk)
{
}
- public void readRevisionByVersion(IDBStoreReader storeReader, CDORevision revision, int version,
- int referenceChunk)
+ public void readRevisionByVersion(IDBStoreReader storeReader, CDORevision revision, int version, int referenceChunk)
{
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/.options b/plugins/org.eclipse.emf.cdo.server/.options
index 007def7..83038cb 100644
--- a/plugins/org.eclipse.emf.cdo.server/.options
+++ b/plugins/org.eclipse.emf.cdo.server/.options
@@ -4,6 +4,7 @@ org.eclipse.emf.cdo.server/debug = true
org.eclipse.emf.cdo.server/debug.protocol = true
org.eclipse.emf.cdo.server/debug.repository = true
org.eclipse.emf.cdo.server/debug.session = true
+org.eclipse.emf.cdo.server/debug.transaction = true
org.eclipse.emf.cdo.server/debug.revision = true
org.eclipse.emf.cdo.server/debug.resource = true
org.eclipse.emf.cdo.server/debug.store = true
diff --git a/plugins/org.eclipse.emf.cdo.server/CommitTransactionIndicationOLD.java b/plugins/org.eclipse.emf.cdo.server/CommitTransactionIndicationOLD.java
new file mode 100644
index 0000000..e95e2bb
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/CommitTransactionIndicationOLD.java
@@ -0,0 +1,403 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 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
+ * Simon McDuff - https://bugs.eclipse.org/bugs/show_bug.cgi?id=201266
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.server.protocol;
+
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDORevisionDeltaImpl;
+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.View;
+import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
+import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
+import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
+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.protocol.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.StoreUtil;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.internal.util.transaction.Transaction;
+import org.eclipse.net4j.util.ImplementationError;
+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.transaction.ITransaction;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Eike Stepper
+ */
+@SuppressWarnings("unused")
+public class CommitTransactionIndicationOLD extends CDOServerIndication
+{
+ private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionIndication.class);
+
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CommitTransactionIndication.class);
+
+ private CDOPackage[] newPackages;
+
+ private InternalCDORevision[] newResources;
+
+ private InternalCDORevision[] newObjects;
+
+ private CDORevisionDeltaImpl[] dirtyObjects;
+
+ private CDOID[] dirtyIDs;
+
+ private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+
+ private long timeStamp;
+
+ private PackageManager sessionPackageManager;
+
+ private CDOPackageManager transactionPackageManager;
+
+ private View view;
+
+ private String rollbackMessage;
+
+ public CommitTransactionIndicationOLD()
+ {
+ }
+
+ @Override
+ protected short getSignalID()
+ {
+ return CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws IOException
+ {
+ timeStamp = System.currentTimeMillis();
+ sessionPackageManager = getPackageManager();
+ transactionPackageManager = new TransactionPackageManager();
+
+ int viewID = in.readInt();
+ view = (View)getSession().getView(viewID);
+ if (view == null || view.getViewType() != IView.Type.TRANSACTION)
+ {
+ throw new IllegalStateException("Illegal view: " + view);
+ }
+
+ IStore store = getStore();
+ IStoreWriter storeWriter = store.getWriter(view);
+
+ try
+ {
+ StoreUtil.setReader(storeWriter);
+ newPackages = readNewPackages(in, storeWriter);
+ newResources = readNewResources(in, storeWriter);
+ newObjects = readNewObjects(in, storeWriter);
+ dirtyObjects = readDirtyObjects(in, storeWriter);
+ ITransaction<IStoreWriter> storeTransaction = new Transaction<IStoreWriter>(storeWriter, false);
+
+ try
+ {
+ addPackages(storeTransaction, newPackages);
+ addRevisions(storeTransaction, newResources);
+ addRevisions(storeTransaction, newObjects);
+ writeRevisions(storeTransaction, dirtyObjects);
+ // addRevisions(storeTransaction, dirtyObjects);
+
+ storeWriter.commit();
+ storeTransaction.commit();
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ rollbackMessage = ex.getLocalizedMessage();
+ storeWriter.rollback();
+ storeTransaction.rollback();
+ }
+ }
+ finally
+ {
+ storeWriter.release();
+ StoreUtil.setReader(null);
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws IOException
+ {
+ if (rollbackMessage != null)
+ {
+ out.writeBoolean(false);
+ out.writeString(rollbackMessage);
+ }
+ else
+ {
+ out.writeBoolean(true);
+ out.writeLong(timeStamp);
+ for (CDOPackage newPackage : newPackages)
+ {
+ CDOIDUtil.writeMetaRange(out, newPackage.getMetaIDRange());
+ }
+
+ writeIDMappings(out);
+ if (dirtyIDs.length > 0)
+ {
+ // getSessionManager().notifyInvalidation(timeStamp, dirtyIDs, getSession());
+ }
+ }
+ }
+
+ private CDOPackage[] readNewPackages(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} new packages", size);
+ }
+
+ CDOPackage[] newPackages = new CDOPackage[size];
+ for (int i = 0; i < size; i++)
+ {
+ newPackages[i] = CDOModelUtil.readPackage(transactionPackageManager, in);
+ mapMetaRange(newPackages[i]);
+ }
+
+ return newPackages;
+ }
+
+ private void mapMetaRange(CDOPackage newPackage)
+ {
+ Repository repository = getRepository();
+ CDOIDMetaRange oldRange = newPackage.getMetaIDRange();
+ if (oldRange != null && oldRange.isTemporary())
+ {
+ CDOIDMetaRange newRange = repository.getMetaIDRange(oldRange.size());
+ ((CDOPackageImpl)newPackage).setMetaIDRange(newRange);
+
+ for (int l = 0; l < oldRange.size(); l++)
+ {
+ CDOID oldID = oldRange.get(l);
+ CDOID newID = newRange.get(l);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
+ }
+
+ idMappings.put(oldID, newID);
+ }
+ }
+ }
+
+ private InternalCDORevision[] readNewResources(ExtendedDataInputStream in, IStoreWriter storeWriter)
+ throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} new resources", size);
+ }
+
+ return readRevisions(in, storeWriter, size);
+ }
+
+ private InternalCDORevision[] readNewObjects(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} new objects", size);
+ }
+
+ return readRevisions(in, storeWriter, size);
+ }
+
+ private CDORevisionDeltaImpl[] readDirtyObjects(ExtendedDataInputStream in, IStoreWriter storeWriter)
+ throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} dirty objects", size);
+ }
+
+ RevisionManager revisionManager = sessionPackageManager.getRepository().getRevisionManager();
+ CDORevisionDeltaImpl[] deltas = new CDORevisionDeltaImpl[size];
+ dirtyIDs = new CDOID[size];
+ for (int i = 0; i < size; i++)
+ {
+ deltas[i] = new CDORevisionDeltaImpl(in, transactionPackageManager);
+ dirtyIDs[i] = deltas[i].getID();
+ }
+
+ return deltas;
+ }
+
+ private InternalCDORevision[] readRevisions(ExtendedDataInputStream in, IStoreWriter storeWriter, int size)
+ throws IOException
+ {
+ RevisionManager revisionManager = sessionPackageManager.getRepository().getRevisionManager();
+ InternalCDORevision[] revisions = new InternalCDORevision[size];
+ for (int i = 0; i < size; i++)
+ {
+ revisions[i] = (InternalCDORevision)CDORevisionUtil.read(in, revisionManager, transactionPackageManager);
+ mapTemporaryID(revisions[i], storeWriter);
+ }
+
+ return revisions;
+ }
+
+ // TODO Remove newPackages parameter
+ private void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackage[] newPackages)
+ {
+ sessionPackageManager.addPackages(storeTransaction, newPackages);
+ }
+
+ private void addRevisions(ITransaction<IStoreWriter> storeTransaction, InternalCDORevision[] revisions)
+ {
+ RevisionManager revisionManager = getRevisionManager();
+ for (InternalCDORevision revision : revisions)
+ {
+ revision.setCreated(timeStamp);
+ revision.adjustReferences(idMappings);
+ revisionManager.addRevision(storeTransaction, revision);
+ }
+ }
+
+ // TODO Rename to addRevisionDeltas
+ // TODO Remove deltas parameter
+ private void writeRevisions(ITransaction<IStoreWriter> storeTransaction, CDORevisionDeltaImpl[] deltas)
+ {
+ for (CDORevisionDeltaImpl delta : deltas)
+ {
+ delta.adjustReferences(idMappings);
+ getRevisionManager().addRevisionDelta(storeTransaction, delta);
+ }
+ }
+
+ private void mapTemporaryID(InternalCDORevision revision, IStoreWriter storeWriter)
+ {
+ CDOID oldID = revision.getID();
+ if (oldID.isTemporary())
+ {
+ CDOID newID = storeWriter.primeNewObject(revision.getCDOClass());
+ if (newID == null || newID.isNull() || newID.isMeta() || newID.isTemporary())
+ {
+ throw new ImplementationError("Store writer returned bad CDOID " + newID);
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
+ }
+
+ idMappings.put(oldID, newID);
+ revision.setID(newID);
+ }
+ }
+
+ private void writeIDMappings(ExtendedDataOutputStream out) throws IOException
+ {
+ for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
+ {
+ CDOID oldID = entry.getKey();
+ if (!oldID.isMeta())
+ {
+ CDOID newID = entry.getValue();
+ CDOIDUtil.write(out, oldID);
+ CDOIDUtil.write(out, newID);
+ }
+ }
+
+ CDOIDUtil.write(out, CDOID.NULL);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class TransactionPackageManager implements CDOPackageManager
+ {
+ public TransactionPackageManager()
+ {
+ }
+
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return sessionPackageManager.getCDOIDObjectFactory();
+ }
+
+ public CDOPackage lookupPackage(String uri)
+ {
+ for (CDOPackage 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/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
index b8ec221..5793bf5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
@@ -12,10 +12,13 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOPathFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.net4j.util.ObjectUtil;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -132,13 +135,39 @@ public class MEMStore extends LongIDStore
return false;
}
- @Override
+ public synchronized CDORevision getResource(String path)
+ {
+ CDOPathFeature pathFeature = getRepository().getPackageManager().getCDOResourcePackage().getCDOResourceClass()
+ .getCDOPathFeature();
+ for (List<CDORevision> list : revisions.values())
+ {
+ if (!list.isEmpty())
+ {
+ CDORevision revision = list.get(0);
+ if (revision.isResource())
+ {
+ String p = (String)revision.getData().get(pathFeature, 0);
+ if (ObjectUtil.equals(p, path))
+ {
+ return revision;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public boolean hasBranchingSupport()
+ {
+ return false;
+ }
+
public boolean hasWriteDeltaSupport()
{
return true;
}
- @Override
public boolean hasAuditingSupport()
{
return true;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index e3d6665..02abd52 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
@@ -121,7 +120,8 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
public CDOID readResourceID(String path)
{
- throw new UnsupportedOperationException();
+ CDORevision revision = getStore().getResource(path);
+ return revision == null ? null : revision.getID();
}
public String readResourcePath(CDOID id)
@@ -129,40 +129,50 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
throw new UnsupportedOperationException();
}
- public CDOID primeNewObject(CDOClass cdoClass)
- {
- return getStore().getNextCDOID();
- }
-
- public void writePackages(CDOPackage... cdoPackages)
+ @Override
+ public void commit(CommitContext context)
{
+ MEMStore store = getStore();
+ synchronized (store)
+ {
+ super.commit(context);
+ }
}
- public void writeRevision(CDORevision revision)
+ @Override
+ public void rollback(CommitContext context)
{
- newRevisions.add(revision);
+ MEMStore store = getStore();
+ synchronized (store)
+ {
+ super.rollback(context);
+ for (CDORevision revision : newRevisions)
+ {
+ store.removeRevision(revision);
+ }
+ }
}
@Override
- public void writeRevisionDelta(CDORevisionDelta delta)
+ protected void writePackages(CDOPackage... cdoPackages)
{
- InternalCDORevision revision = (InternalCDORevision)getStore().getRevision(delta.getID());
- InternalCDORevision newRevision = (InternalCDORevision)CDORevisionUtil.copy(revision);
- delta.apply(newRevision);
- newRevisions.add(newRevision);
+ // Do nothing
}
- public void commit()
+ @Override
+ protected void writeRevision(CDORevision revision)
{
- MEMStore store = getStore();
- for (CDORevision revision : newRevisions)
- {
- store.addRevision(revision);
- }
+ newRevisions.add(revision);
+ getStore().addRevision(revision);
}
- public void rollback()
+ @Override
+ protected void writeRevisionDelta(CDORevisionDelta revisionDelta)
{
+ CDORevision revision = getStore().getRevision(revisionDelta.getID());
+ CDORevision newRevision = CDORevisionUtil.copy(revision);
+ revisionDelta.apply(newRevision);
+ writeRevision(newRevision);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
index 174f2a4..56e4acf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
@@ -25,7 +25,16 @@ public class NOOPStore extends LongIDStore
super(TYPE);
}
- @Override
+ public boolean hasBranchingSupport()
+ {
+ return false;
+ }
+
+ public boolean hasWriteDeltaSupport()
+ {
+ return true;
+ }
+
public boolean hasAuditingSupport()
{
return true;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
index 24e1bbb..03a140f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
@@ -98,25 +97,4 @@ public class NOOPStoreAccessor extends StoreAccessor implements IStoreReader, IS
{
throw new UnsupportedOperationException();
}
-
- public CDOID primeNewObject(CDOClass cdoClass)
- {
- return getStore().getNextCDOID();
- }
-
- public void writePackages(CDOPackage... cdoPackages)
- {
- }
-
- public void writeRevision(CDORevision revision)
- {
- }
-
- public void commit()
- {
- }
-
- public void rollback()
- {
- }
}
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 68b6ebd..3fac8c8 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
@@ -14,16 +14,11 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
-import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.IStoreReader;
-import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.StoreUtil;
-import org.eclipse.net4j.util.transaction.ITransaction;
-import org.eclipse.net4j.util.transaction.ITransactionalOperation;
-
import java.util.Collection;
/**
@@ -48,16 +43,6 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
return repository.getStore().getCDOIDObjectFactory();
}
- public void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackage[] cdoPackages)
- {
- for (CDOPackage cdoPackage : cdoPackages)
- {
- ((CDOPackageImpl)cdoPackage).setPackageManager(this);
- }
-
- storeTransaction.execute(new AddPackagesOperation(cdoPackages));
- }
-
@Override
protected void resolve(CDOPackageImpl cdoPackage)
{
@@ -98,34 +83,4 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
}
}
}
-
- /**
- * @author Eike Stepper
- */
- private final class AddPackagesOperation implements ITransactionalOperation<IStoreWriter>
- {
- private CDOPackage[] cdoPackages;
-
- private AddPackagesOperation(CDOPackage[] cdoPackages)
- {
- this.cdoPackages = cdoPackages;
- }
-
- public void phase1(IStoreWriter storeWriter) throws Exception
- {
- storeWriter.writePackages(cdoPackages);
- }
-
- public void phase2(IStoreWriter storeWriter)
- {
- for (CDOPackage cdoPackage : cdoPackages)
- {
- 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 97a1405..29d1838 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
@@ -230,6 +230,11 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
throw new IllegalArgumentException("store is null");
}
+ if (isSupportingRevisionDeltas() && !store.hasWriteDeltaSupport())
+ {
+ throw new IllegalStateException("Store without revision delta support");
+ }
+
if (isSupportingAudits() && !store.hasAuditingSupport())
{
throw new IllegalStateException("Store without auditing support");
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 3e09004..4776a1b 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
@@ -51,7 +51,10 @@ public class ResourceManager extends Lifecycle implements IResourceManager
if (id == null)
{
id = loadID(path);
- registerResource(id, path);
+ if (id != null)
+ {
+ registerResource(id, path);
+ }
}
return id;
@@ -63,7 +66,10 @@ public class ResourceManager extends Lifecycle implements IResourceManager
if (path == null)
{
path = loadPath(id);
- registerResource(id, path);
+ if (path != null)
+ {
+ registerResource(id, path);
+ }
}
return path;
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 a3a4574..e61a8cc 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,25 +15,19 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDORevisionDeltaImpl;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.resource.CDOPathFeature;
import org.eclipse.emf.cdo.protocol.revision.CDOReferenceProxy;
-import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.protocol.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
import org.eclipse.emf.cdo.server.IStoreReader;
-import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.emf.cdo.server.IRepository.Props;
import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.net4j.util.collection.MoveableList;
-import org.eclipse.net4j.util.transaction.ITransaction;
-import org.eclipse.net4j.util.transaction.ITransactionalOperation;
import java.util.ArrayList;
import java.util.Collection;
@@ -64,16 +58,6 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
return repository.getStore().getCDOIDObjectFactory();
}
- public void addRevision(ITransaction<IStoreWriter> storeTransaction, InternalCDORevision revision)
- {
- storeTransaction.execute(new AddRevisionOperation(revision));
- }
-
- public void addRevisionDelta(ITransaction<IStoreWriter> storeTransaction, CDORevisionDeltaImpl delta)
- {
- storeTransaction.execute(new AddRevisionDeltaOperation(delta));
- }
-
public CDOID resolveReferenceProxy(CDOReferenceProxy referenceProxy)
{
throw new UnsupportedOperationException("Reference proxies not supported on server side");
@@ -86,6 +70,18 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
}
@Override
+ public boolean addRevision(InternalCDORevision revision)
+ {
+ if (revision.isResource())
+ {
+ String path = (String)revision.get(cdoPathFeature, 0);
+ repository.getResourceManager().registerResource(revision.getID(), path);
+ }
+
+ return super.addRevision(revision);
+ }
+
+ @Override
protected InternalCDORevision verifyRevision(InternalCDORevision revision, int referenceChunk)
{
IStoreReader storeReader = null;
@@ -269,93 +265,4 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
String capacity = repository.getProperties().get(prop);
return capacity == null ? 0 : Integer.valueOf(capacity);
}
-
- /**
- * @author Eike Stepper
- */
- private final class AddRevisionOperation implements ITransactionalOperation<IStoreWriter>
- {
- private InternalCDORevision revision;
-
- private AddRevisionOperation(InternalCDORevision revision)
- {
- this.revision = revision;
- }
-
- public void phase1(IStoreWriter storeWriter) throws Exception
- {
- // Can throw an exception if duplicate
- storeWriter.writeRevision(revision);
- }
-
- public void phase2(IStoreWriter storeWriter)
- {
- addRevision(revision);
- if (revision.isResource())
- {
- String path = (String)revision.getData().get(cdoPathFeature, -1);
- repository.getResourceManager().registerResource(revision.getID(), path);
- }
- }
-
- public void undoPhase1(IStoreWriter storeWriter)
- {
- }
- }
-
- /**
- * @author Simon McDuff
- */
- private final class AddRevisionDeltaOperation implements ITransactionalOperation<IStoreWriter>
- {
- private CDORevisionDeltaImpl revisionDelta;
-
- private InternalCDORevision dirtyRevision;
-
- private AddRevisionDeltaOperation(CDORevisionDeltaImpl revisionDelta)
- {
- this.revisionDelta = revisionDelta;
- }
-
- public void phase1(IStoreWriter storeWriter) throws Exception
- {
- boolean supportDelta = getRepository().isSupportingRevisionDeltas();
- InternalCDORevision originRevision = getRevisionByVersion(revisionDelta.getID(), CDORevision.UNCHUNKED,
- revisionDelta.getOriginVersion(), !supportDelta);
-
- if (originRevision != null)
- {
- dirtyRevision = (InternalCDORevision)CDORevisionUtil.copy(originRevision);
- revisionDelta.apply(dirtyRevision);
- }
- else if (!supportDelta)
- {
- // Origin revision need to be accessible for stores that do not support deltas
- throw new IllegalStateException("Can not retrieve origin revision");
- }
-
- if (supportDelta)
- {
- // Can throw an exception if duplicate
- storeWriter.writeRevisionDelta(revisionDelta);
- }
- else
- {
- // Can throw an exception if duplicate
- storeWriter.writeRevision(dirtyRevision);
- }
- }
-
- public void phase2(IStoreWriter storeWriter)
- {
- if (dirtyRevision != null)
- {
- addRevision(dirtyRevision);
- }
- }
-
- 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 bcf3462..f0410c73c 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
@@ -11,7 +11,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol;
@@ -54,7 +53,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
private boolean disableLegacyObjects;
- private ConcurrentMap<Integer, View> views = new ConcurrentHashMap<Integer, View>();
+ private ConcurrentMap<Integer, IView> views = new ConcurrentHashMap<Integer, IView>();
private IListener protocolListener = new LifecycleEventAdapter()
{
@@ -120,7 +119,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
return views.values().toArray(new View[views.size()]);
}
- public View getView(int viewID)
+ public IView getView(int viewID)
{
return views.get(viewID);
}
@@ -129,7 +128,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
{
if (kind == CDOProtocolConstants.VIEW_CLOSED)
{
- View view = views.remove(viewID);
+ IView view = views.remove(viewID);
if (view != null)
{
fireElementRemovedEvent(view);
@@ -137,29 +136,31 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
}
else
{
- Type viewType = getViewType(kind);
- View view = new View(this, viewID, viewType);
+ IView view = createView(kind, viewID);
views.put(viewID, view);
fireElementAddedEvent(view);
}
}
- private Type getViewType(byte kind)
+ private IView createView(byte kind, int viewID)
{
switch (kind)
{
case CDOProtocolConstants.VIEW_TRANSACTION:
- return Type.TRANSACTION;
+ return new Transaction(this, viewID);
+
case CDOProtocolConstants.VIEW_READONLY:
- return Type.READONLY;
+ return new View(this, viewID, Type.READONLY);
+
case CDOProtocolConstants.VIEW_AUDIT:
- return Type.AUDIT;
- }
+ return new View(this, viewID, Type.AUDIT);
- throw new ImplementationError("Invalid kind: " + kind);
+ default:
+ throw new ImplementationError("Invalid kind: " + kind);
+ }
}
- public void notifyInvalidation(long timeStamp, CDOID[] dirtyIDs)
+ public void notifyInvalidation(long timeStamp, List<CDOID> dirtyIDs)
{
try
{
@@ -203,7 +204,7 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
List<InternalCDORevision> additionalRevisions)
{
RevisionManager revisionManager = getSessionManager().getRepository().getRevisionManager();
- CDOClassImpl cdoClass = (CDOClassImpl)revision.getCDOClass();
+ CDOClass cdoClass = revision.getCDOClass();
CDOFeature[] features = cdoClass.getAllFeatures();
for (int i = 0; i < features.length; i++)
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
index 8775779..7adafdb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
@@ -23,6 +23,7 @@ import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -103,13 +104,13 @@ public class SessionManager extends Container<ISession> implements ISessionManag
}
}
- public void notifyInvalidation(long timeStamp, CDOID[] dirtyObjects, Session excludedSession)
+ public void notifyInvalidation(long timeStamp, List<CDOID> dirtyIDs, Session excludedSession)
{
for (Session session : getSessions())
{
if (session != excludedSession)
{
- session.notifyInvalidation(timeStamp, dirtyObjects);
+ session.notifyInvalidation(timeStamp, dirtyIDs);
}
}
}
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
index b390f85..e753757 100644
--- 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
@@ -68,21 +68,6 @@ public abstract class Store extends Lifecycle implements IStore
this.repository = repository;
}
- public boolean hasWriteDeltaSupport()
- {
- return false;
- }
-
- public boolean hasAuditingSupport()
- {
- return false;
- }
-
- public boolean hasBranchingSupport()
- {
- return false;
- }
-
public IStoreReader getReader(ISession session)
{
return createReader(session);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
index 0c0b1a8..f3768fe 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
@@ -11,18 +11,31 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
/**
* @author Eike Stepper
*/
public class StoreAccessor implements IStoreAccessor
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, StoreAccessor.class);
+
private Store store;
private Object context;
@@ -90,7 +103,115 @@ public class StoreAccessor implements IStoreAccessor
return (InternalCDORevision)revision;
}
- public void writeRevisionDelta(CDORevisionDelta delta)
+ public void commit(CommitContext context)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Committing transaction: {0}", getView());
+ }
+
+ writePackages(context.getNewPackages());
+ addIDMappings(context);
+ context.applyIDMappings();
+ writeRevisions(context.getNewObjects());
+ if (store.hasWriteDeltaSupport() && store.getRepository().isSupportingRevisionDeltas())
+ {
+ writeRevisionDeltas(context.getDirtyObjectDeltas());
+ }
+ else
+ {
+ writeRevisions(context.getDirtyObjects());
+ }
+ }
+
+ public void rollback(CommitContext context)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Rolling back transaction: {0}", getView());
+ }
+ }
+
+ protected void addIDMappings(CommitContext context)
+ {
+ if (store instanceof LongIDStore)
+ {
+ LongIDStore longIDStore = (LongIDStore)getStore();
+ for (CDORevision revision : context.getNewObjects())
+ {
+ CDOIDTemp oldID = (CDOIDTemp)revision.getID();
+ CDOID newID = longIDStore.getNextCDOID();
+ if (newID == null || newID.isNull() || newID.isTemporary())
+ {
+ throw new IllegalStateException("newID=" + newID);
+ }
+
+ context.addIDMapping(oldID, newID);
+ }
+ }
+ }
+
+ protected void writePackages(CDOPackage... cdoPackages)
+ {
+ for (CDOPackage cdoPackage : cdoPackages)
+ {
+ writePackage(cdoPackage);
+ }
+ }
+
+ protected void writePackage(CDOPackage cdoPackage)
+ {
+ for (CDOClass cdoClass : cdoPackage.getClasses())
+ {
+ writeClass((CDOClassImpl)cdoClass);
+ }
+ }
+
+ protected void writeClass(CDOClassImpl cdoClass)
+ {
+ for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
+ {
+ writeSuperType(cdoClass, superType);
+ }
+
+ for (CDOFeature feature : cdoClass.getFeatures())
+ {
+ writeFeature(feature);
+ }
+ }
+
+ protected void writeSuperType(CDOClassImpl type, CDOClassProxy superType)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void writeFeature(CDOFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void writeRevisions(CDORevision[] revisions)
+ {
+ for (CDORevision revision : revisions)
+ {
+ writeRevision(revision);
+ }
+ }
+
+ protected void writeRevision(CDORevision revision)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected void writeRevisionDeltas(CDORevisionDelta[] revisionDeltas)
+ {
+ for (CDORevisionDelta revisionDelta : revisionDeltas)
+ {
+ writeRevisionDelta(revisionDelta);
+ }
+ }
+
+ protected void writeRevisionDelta(CDORevisionDelta revisionDelta)
{
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
new file mode 100644
index 0000000..bf956f2
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
@@ -0,0 +1,453 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 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.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.internal.protocol.revision.delta.InternalCDORevisionDelta;
+import org.eclipse.emf.cdo.internal.server.bundle.OM;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
+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.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver;
+import org.eclipse.emf.cdo.protocol.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.server.IPackageManager;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.StoreUtil;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.event.IListener;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class Transaction extends View implements ITransaction, IStoreWriter.CommitContext
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSACTION, Transaction.class);
+
+ private IRepository repository;
+
+ private IPackageManager repositoryPackageManager;
+
+ private TransactionPackageManager packageManager;
+
+ private IStoreWriter storeWriter;
+
+ private long timeStamp;
+
+ private CDOPackage[] newPackages;
+
+ private CDORevision[] newObjects;
+
+ private CDORevision[] dirtyObjects;
+
+ private CDORevisionDelta[] dirtyObjectDeltas;
+
+ private List<CDOIDMetaRange> metaIDRanges = new ArrayList<CDOIDMetaRange>();
+
+ private ConcurrentMap<CDOIDTemp, CDOID> idMappings = new ConcurrentHashMap<CDOIDTemp, CDOID>();
+
+ private String rollbackMessage;
+
+ public Transaction(Session session, int viewID)
+ {
+ super(session, viewID, Type.TRANSACTION);
+ repository = session.getSessionManager().getRepository();
+ repositoryPackageManager = repository.getPackageManager();
+ packageManager = new TransactionPackageManager();
+
+ }
+
+ public int getTransactionID()
+ {
+ return getViewID();
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public TransactionPackageManager getPackageManager()
+ {
+ return packageManager;
+ }
+
+ public CDOPackage[] getNewPackages()
+ {
+ return newPackages;
+ }
+
+ public CDORevision[] getNewObjects()
+ {
+ return newObjects;
+ }
+
+ public CDORevision[] getDirtyObjects()
+ {
+ return dirtyObjects;
+ }
+
+ public CDORevisionDelta[] getDirtyObjectDeltas()
+ {
+ return dirtyObjectDeltas;
+ }
+
+ public List<CDOIDMetaRange> getMetaIDRanges()
+ {
+ return Collections.unmodifiableList(metaIDRanges);
+ }
+
+ public Map<CDOIDTemp, CDOID> getIDMappings()
+ {
+ return Collections.unmodifiableMap(idMappings);
+ }
+
+ public void addIDMapping(CDOIDTemp oldID, CDOID newID)
+ {
+ if (newID == null || newID.isNull() || newID.isTemporary())
+ {
+ throw new IllegalStateException("newID=" + newID);
+ }
+
+ CDOID previousMapping = idMappings.putIfAbsent(oldID, newID);
+ if (previousMapping != null)
+ {
+ throw new IllegalStateException("previousMapping != null");
+ }
+ }
+
+ public void applyIDMappings()
+ {
+ applyIDMappings(newObjects);
+ applyIDMappings(dirtyObjects);
+ for (CDORevisionDelta dirtyObjectDelta : dirtyObjectDeltas)
+ {
+ ((InternalCDORevisionDelta)dirtyObjectDelta).adjustReferences(idMappings);
+ }
+ }
+
+ public String getRollbackMessage()
+ {
+ return rollbackMessage;
+ }
+
+ public void preCommit()
+ {
+ storeWriter = repository.getStore().getWriter(this);
+ StoreUtil.setReader(storeWriter);
+ }
+
+ public void commit(CDOPackage[] newPackages, CDORevision[] newObjects, CDORevisionDelta[] dirtyObjectDeltas)
+ {
+ timeStamp = System.currentTimeMillis();
+ this.newPackages = newPackages;
+ this.newObjects = newObjects;
+ this.dirtyObjectDeltas = dirtyObjectDeltas;
+ dirtyObjects = new CDORevision[dirtyObjectDeltas.length];
+
+ try
+ {
+ adjustMetaRanges();
+ adjustTimeStamps();
+ computeDirtyObjects(!repository.isSupportingRevisionDeltas());
+
+ storeWriter.commit(this);
+ updateInfraStructure();
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ rollbackMessage = ex.getMessage();
+ rollback();
+ }
+ }
+
+ public void postCommit(boolean success)
+ {
+ try
+ {
+ int modifications = dirtyObjectDeltas.length;
+ if (success && modifications > 0)
+ {
+ List<CDOID> dirtyIDs = new ArrayList<CDOID>(modifications);
+ for (int i = 0; i < modifications; i++)
+ {
+ dirtyIDs.add(dirtyObjectDeltas[i].getID());
+ }
+
+ SessionManager sessionManager = (SessionManager)repository.getSessionManager();
+ sessionManager.notifyInvalidation(timeStamp, dirtyIDs, getSession());
+ }
+ }
+ finally
+ {
+ // TODO Do this while indcating instead of responding
+ if (storeWriter != null)
+ {
+ StoreUtil.setReader(null);
+ storeWriter.release();
+ storeWriter = null;
+ }
+
+ timeStamp = 0L;
+ packageManager.clear();
+ metaIDRanges.clear();
+ idMappings.clear();
+ rollbackMessage = null;
+ newPackages = null;
+ newObjects = null;
+ dirtyObjectDeltas = null;
+ dirtyObjects = null;
+ }
+ }
+
+ private void adjustTimeStamps()
+ {
+ for (CDORevision newObject : newObjects)
+ {
+ InternalCDORevision revision = (InternalCDORevision)newObject;
+ revision.setCreated(timeStamp);
+ }
+ }
+
+ private void adjustMetaRanges()
+ {
+ for (CDOPackage newPackage : newPackages)
+ {
+ adjustMetaRange(newPackage);
+ }
+ }
+
+ private void adjustMetaRange(CDOPackage newPackage)
+ {
+ CDOIDMetaRange oldRange = newPackage.getMetaIDRange();
+ if (!oldRange.isTemporary())
+ {
+ throw new IllegalStateException("!oldRange.isTemporary()");
+ }
+
+ CDOIDMetaRange newRange = repository.getMetaIDRange(oldRange.size());
+ ((CDOPackageImpl)newPackage).setMetaIDRange(newRange);
+ for (int l = 0; l < oldRange.size(); l++)
+ {
+ CDOIDTemp oldID = (CDOIDTemp)oldRange.get(l);
+ CDOID newID = newRange.get(l);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Mapping meta ID: {0} --> {1}", oldID, newID);
+ }
+
+ idMappings.put(oldID, newID);
+ }
+
+ metaIDRanges.add(newRange);
+ }
+
+ private void computeDirtyObjects(boolean failOnNull)
+ {
+ for (int i = 0; i < dirtyObjectDeltas.length; i++)
+ {
+ dirtyObjects[i] = computeDirtyObject(dirtyObjectDeltas[i]);
+ if (dirtyObjects[i] == null && failOnNull)
+ {
+ throw new IllegalStateException("Can not retrieve origin revision for " + dirtyObjectDeltas[i]);
+ }
+ }
+ }
+
+ private CDORevision computeDirtyObject(CDORevisionDelta dirtyObjectDelta)
+ {
+ CDOID id = dirtyObjectDelta.getID();
+ int version = dirtyObjectDelta.getOriginVersion();
+
+ CDORevisionResolver revisionResolver = repository.getRevisionManager();
+ CDORevision originObject = revisionResolver.getRevisionByVersion(id, CDORevision.UNCHUNKED, version, false);
+ if (originObject != null)
+ {
+ InternalCDORevision dirtyObject = (InternalCDORevision)CDORevisionUtil.copy(originObject);
+ dirtyObjectDelta.apply(dirtyObject);
+ dirtyObject.setCreated(timeStamp);
+ // dirtyObject.setVersion(originObject.getVersion() + 1);
+ return dirtyObject;
+ }
+
+ return null;
+ }
+
+ private void applyIDMappings(CDORevision[] revisions)
+ {
+ for (CDORevision revision : revisions)
+ {
+ if (revision != null)
+ {
+ InternalCDORevision internal = (InternalCDORevision)revision;
+ CDOID newID = idMappings.get(internal.getID());
+ if (newID != null)
+ {
+ internal.setID(newID);
+ }
+
+ internal.adjustReferences(idMappings);
+ }
+ }
+ }
+
+ private void rollback()
+ {
+ if (storeWriter != null)
+ {
+ try
+ {
+ storeWriter.rollback(this);
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.warn("Problem while rolling back the transaction", ex);
+ }
+ }
+ }
+
+ private void updateInfraStructure()
+ {
+ try
+ {
+ addNewPackages();
+ addRevisions(newObjects);
+ addRevisions(dirtyObjects);
+ }
+ catch (RuntimeException ex)
+ {
+ // TODO Rethink this case
+ OM.LOG.error("FATAL: Memory infrastructure corrupted after successful commit operation of the store");
+ }
+ }
+
+ private void addNewPackages()
+ {
+ PackageManager packageManager = (PackageManager)repository.getPackageManager();
+ for (int i = 0; i < newPackages.length; i++)
+ {
+ CDOPackage cdoPackage = newPackages[i];
+ packageManager.addPackage(cdoPackage);
+ }
+ }
+
+ private void addRevisions(CDORevision[] revisions)
+ {
+ RevisionManager revisionManager = (RevisionManager)repository.getRevisionManager();
+ for (CDORevision revision : revisions)
+ {
+ if (revision != null)
+ {
+ revisionManager.addRevision((InternalCDORevision)revision);
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public final class TransactionPackageManager implements CDOPackageManager
+ {
+
+ private List<CDOPackage> newPackages = new ArrayList<CDOPackage>();
+
+ public TransactionPackageManager()
+ {
+ }
+
+ public void addPackage(CDOPackage cdoPackage)
+ {
+ newPackages.add(cdoPackage);
+ }
+
+ public void clear()
+ {
+ newPackages.clear();
+ }
+
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return repositoryPackageManager.getCDOIDObjectFactory();
+ }
+
+ public CDOPackage lookupPackage(String uri)
+ {
+ for (CDOPackage cdoPackage : newPackages)
+ {
+ if (ObjectUtil.equals(cdoPackage.getPackageURI(), uri))
+ {
+ return cdoPackage;
+ }
+ }
+
+ return repositoryPackageManager.lookupPackage(uri);
+ }
+
+ public CDOCorePackage getCDOCorePackage()
+ {
+ return repositoryPackageManager.getCDOCorePackage();
+ }
+
+ public CDOResourcePackage getCDOResourcePackage()
+ {
+ return repositoryPackageManager.getCDOResourcePackage();
+ }
+
+ 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/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
index cf3caaf..fc00e26 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/OM.java
@@ -35,6 +35,8 @@ public abstract class OM
public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$
+ public static final OMTracer DEBUG_TRANSACTION = DEBUG.tracer("transaction"); //$NON-NLS-1$
+
public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$
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 363ecb3..2469731 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
@@ -11,75 +11,41 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDORevisionDeltaImpl;
-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.View;
+import org.eclipse.emf.cdo.internal.server.Transaction;
+import org.eclipse.emf.cdo.internal.server.Transaction.TransactionPackageManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
-import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
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.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.protocol.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.StoreUtil;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.net4j.internal.util.transaction.Transaction;
-import org.eclipse.net4j.util.ImplementationError;
-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.transaction.ITransaction;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* @author Eike Stepper
*/
-@SuppressWarnings("unused")
public class CommitTransactionIndication extends CDOServerIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionIndication.class);
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CommitTransactionIndication.class);
-
- private CDOPackage[] newPackages;
-
- private InternalCDORevision[] newResources;
-
- private InternalCDORevision[] newObjects;
-
- private CDORevisionDeltaImpl[] dirtyObjects;
-
- private CDOID[] dirtyIDs;
-
- private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
-
- private long timeStamp;
-
- private PackageManager sessionPackageManager;
-
- private CDOPackageManager transactionPackageManager;
-
- private View view;
-
- private String rollbackMessage;
+ private Transaction transaction;
public CommitTransactionIndication()
{
@@ -94,305 +60,110 @@ public class CommitTransactionIndication extends CDOServerIndication
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- timeStamp = System.currentTimeMillis();
- sessionPackageManager = getPackageManager();
- transactionPackageManager = new TransactionPackageManager();
+ IRepository repository = getRepository();
+ CDORevisionResolver revisionResolver = repository.getRevisionManager();
int viewID = in.readInt();
- view = getSession().getView(viewID);
- if (view == null || view.getViewType() != IView.Type.TRANSACTION)
- {
- throw new IllegalStateException("Illegal view: " + view);
- }
-
- IStore store = getStore();
- IStoreWriter storeWriter = store.getWriter(view);
-
- try
- {
- StoreUtil.setReader(storeWriter);
- newPackages = readNewPackages(in, storeWriter);
- newResources = readNewResources(in, storeWriter);
- newObjects = readNewObjects(in, storeWriter);
- dirtyObjects = readDirtyObjects(in, storeWriter);
- ITransaction<IStoreWriter> storeTransaction = new Transaction<IStoreWriter>(storeWriter, false);
-
- try
- {
- addPackages(storeTransaction, newPackages);
- addRevisions(storeTransaction, newResources);
- addRevisions(storeTransaction, newObjects);
- writeRevisions(storeTransaction, dirtyObjects);
- // addRevisions(storeTransaction, dirtyObjects);
-
- storeWriter.commit();
- storeTransaction.commit();
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- rollbackMessage = ex.getLocalizedMessage();
- storeWriter.rollback();
- storeTransaction.rollback();
- }
- }
- finally
- {
- storeWriter.release();
- StoreUtil.setReader(null);
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws IOException
- {
- if (rollbackMessage != null)
- {
- out.writeBoolean(false);
- out.writeString(rollbackMessage);
- }
- else
- {
- out.writeBoolean(true);
- out.writeLong(timeStamp);
- for (CDOPackage newPackage : newPackages)
- {
- CDOIDUtil.writeMetaRange(out, newPackage.getMetaIDRange());
- }
+ transaction = getTransaction(viewID);
+ transaction.preCommit();
- writeIDMappings(out);
- if (dirtyIDs.length > 0)
- {
- getSessionManager().notifyInvalidation(timeStamp, dirtyIDs, getSession());
- }
- }
- }
+ TransactionPackageManager packageManager = transaction.getPackageManager();
+ CDOPackage[] newPackages = new CDOPackage[in.readInt()];
+ CDORevision[] newObjects = new CDORevision[in.readInt()];
+ CDORevisionDelta[] dirtyObjectDeltas = new CDORevisionDelta[in.readInt()];
- private CDOPackage[] readNewPackages(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
- {
- int size = in.readInt();
+ // New packages
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Reading {0} new packages", size);
+ PROTOCOL.format("Reading {0} new packages", newPackages.length);
}
- Repository repository = getRepository();
- CDOPackage[] newPackages = new CDOPackage[size];
- for (int i = 0; i < size; i++)
+ for (int i = 0; i < newPackages.length; i++)
{
- newPackages[i] = CDOModelUtil.readPackage(transactionPackageManager, in);
- CDOIDMetaRange oldRange = newPackages[i].getMetaIDRange();
- if (oldRange != null && oldRange.isTemporary())
- {
- CDOIDMetaRange newRange = repository.getMetaIDRange(oldRange.size());
- ((CDOPackageImpl)newPackages[i]).setMetaIDRange(newRange);
-
- for (int l = 0; l < oldRange.size(); l++)
- {
- CDOID oldID = oldRange.get(l);
- CDOID newID = newRange.get(l);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
- }
-
- idMappings.put(oldID, newID);
- }
- }
+ newPackages[i] = CDOModelUtil.readPackage(packageManager, in);
+ packageManager.addPackage(newPackages[i]);
}
- return newPackages;
- }
-
- private InternalCDORevision[] readNewResources(ExtendedDataInputStream in, IStoreWriter storeWriter)
- throws IOException
- {
- int size = in.readInt();
+ // New objects
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Reading {0} new resources", size);
+ PROTOCOL.format("Reading {0} new objects", newObjects.length);
}
- return readRevisions(in, storeWriter, size);
- }
-
- private InternalCDORevision[] readNewObjects(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
- {
- int size = in.readInt();
- if (PROTOCOL.isEnabled())
+ for (int i = 0; i < newObjects.length; i++)
{
- PROTOCOL.format("Reading {0} new objects", size);
+ newObjects[i] = CDORevisionUtil.read(in, revisionResolver, packageManager);
}
- return readRevisions(in, storeWriter, size);
- }
-
- private CDORevisionDeltaImpl[] readDirtyObjects(ExtendedDataInputStream in, IStoreWriter storeWriter)
- throws IOException
- {
- int size = in.readInt();
+ // Dirty objects
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Reading {0} dirty objects", size);
- }
-
- RevisionManager revisionManager = sessionPackageManager.getRepository().getRevisionManager();
- CDORevisionDeltaImpl[] deltas = new CDORevisionDeltaImpl[size];
- dirtyIDs = new CDOID[size];
- for (int i = 0; i < size; i++)
- {
- deltas[i] = new CDORevisionDeltaImpl(in, transactionPackageManager);
- dirtyIDs[i] = deltas[i].getID();
+ PROTOCOL.format("Reading {0} dirty object deltas", dirtyObjectDeltas.length);
}
- return deltas;
- }
-
- private InternalCDORevision[] readRevisions(ExtendedDataInputStream in, IStoreWriter storeWriter, int size)
- throws IOException
- {
- RevisionManager revisionManager = sessionPackageManager.getRepository().getRevisionManager();
- InternalCDORevision[] revisions = new InternalCDORevision[size];
- for (int i = 0; i < size; i++)
+ for (int i = 0; i < dirtyObjectDeltas.length; i++)
{
- revisions[i] = (InternalCDORevision)CDORevisionUtil.read(in, revisionManager, transactionPackageManager);
- mapTemporaryID(revisions[i], storeWriter);
+ dirtyObjectDeltas[i] = new CDORevisionDeltaImpl(in, packageManager);
}
- return revisions;
- }
-
- // TODO Remove newPackages parameter
- private void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackage[] newPackages)
- {
- sessionPackageManager.addPackages(storeTransaction, newPackages);
- }
-
- private void addRevisions(ITransaction<IStoreWriter> storeTransaction, InternalCDORevision[] revisions)
- {
- RevisionManager revisionManager = getRevisionManager();
- for (InternalCDORevision revision : revisions)
- {
- revision.setCreated(timeStamp);
- revision.adjustReferences(idMappings);
- revisionManager.addRevision(storeTransaction, revision);
- }
+ transaction.commit(newPackages, newObjects, dirtyObjectDeltas);
}
- // TODO Rename to addRevisionDeltas
- // TODO Remove deltas parameter
- private void writeRevisions(ITransaction<IStoreWriter> storeTransaction, CDORevisionDeltaImpl[] deltas)
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws IOException
{
- for (CDORevisionDeltaImpl delta : deltas)
- {
- delta.adjustReferences(idMappings);
- getRevisionManager().addRevisionDelta(storeTransaction, delta);
- }
- }
+ boolean success = false;
- private void mapTemporaryID(InternalCDORevision revision, IStoreWriter storeWriter)
- {
- CDOID oldID = revision.getID();
- if (oldID.isTemporary())
+ try
{
- CDOID newID = storeWriter.primeNewObject(revision.getCDOClass());
- if (newID == null || newID.isNull() || newID.isMeta() || newID.isTemporary())
+ String rollbackMessage = transaction.getRollbackMessage();
+ success = rollbackMessage == null;
+ out.writeBoolean(success);
+ if (success)
{
- throw new ImplementationError("Store writer returned bad CDOID " + newID);
- }
+ out.writeLong(transaction.getTimeStamp());
- if (TRACER.isEnabled())
- {
- TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
- }
+ // Meta ID ranges
+ List<CDOIDMetaRange> metaRanges = transaction.getMetaIDRanges();
+ for (CDOIDMetaRange metaRange : metaRanges)
+ {
+ CDOIDUtil.writeMetaRange(out, metaRange);
+ }
- idMappings.put(oldID, newID);
- revision.setID(newID);
- }
- }
+ // ID mappings
+ Map<CDOIDTemp, CDOID> idMappings = transaction.getIDMappings();
+ for (Entry<CDOIDTemp, CDOID> entry : idMappings.entrySet())
+ {
+ CDOIDTemp oldID = entry.getKey();
+ if (!oldID.isMeta())
+ {
+ CDOID newID = entry.getValue();
+ CDOIDUtil.write(out, oldID);
+ CDOIDUtil.write(out, newID);
+ }
+ }
- private void writeIDMappings(ExtendedDataOutputStream out) throws IOException
- {
- for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
- {
- CDOID oldID = entry.getKey();
- if (!oldID.isMeta())
- {
- CDOID newID = entry.getValue();
- CDOIDUtil.write(out, oldID);
- CDOIDUtil.write(out, newID);
+ CDOIDUtil.write(out, CDOID.NULL);
}
- }
-
- CDOIDUtil.write(out, CDOID.NULL);
- }
-
- /**
- * @author Eike Stepper
- */
- private final class TransactionPackageManager implements CDOPackageManager
- {
- public TransactionPackageManager()
- {
- }
-
- public CDOIDObjectFactory getCDOIDObjectFactory()
- {
- return sessionPackageManager.getCDOIDObjectFactory();
- }
-
- public CDOPackage lookupPackage(String uri)
- {
- for (CDOPackage cdoPackage : newPackages)
+ else
{
- if (ObjectUtil.equals(cdoPackage.getPackageURI(), uri))
- {
- return cdoPackage;
- }
+ out.writeString(rollbackMessage);
}
-
- 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()
+ finally
{
- throw new UnsupportedOperationException();
+ transaction.postCommit(success);
}
+ }
- public void addListener(IListener listener)
+ private Transaction getTransaction(int viewID)
+ {
+ IView view = getSession().getView(viewID);
+ if (view instanceof Transaction)
{
- throw new UnsupportedOperationException();
+ return (Transaction)view;
}
- public void removeListener(IListener listener)
- {
- throw new UnsupportedOperationException();
- }
+ throw new IllegalStateException("Illegal transaction: " + view);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationNotification.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationNotification.java
index f4d586d..e07c179 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationNotification.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationNotification.java
@@ -22,6 +22,7 @@ import org.eclipse.net4j.signal.Request;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
+import java.util.List;
/**
* @author Eike Stepper
@@ -32,9 +33,9 @@ public class InvalidationNotification extends Request
private long timeStamp;
- private CDOID[] dirtyIDs;
+ private List<CDOID> dirtyIDs;
- public InvalidationNotification(IChannel channel, long timeStamp, CDOID[] dirtyIDs)
+ public InvalidationNotification(IChannel channel, long timeStamp, List<CDOID> dirtyIDs)
{
super(channel);
this.timeStamp = timeStamp;
@@ -56,17 +57,15 @@ public class InvalidationNotification extends Request
}
out.writeLong(timeStamp);
-
- int size = dirtyIDs.length;
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing {0} IDs", size);
+ PROTOCOL.format("Writing {0} dirty IDs", dirtyIDs.size());
}
- out.writeInt(size);
- for (int i = 0; i < dirtyIDs.length; i++)
+ out.writeInt(dirtyIDs.size());
+ for (CDOID dirtyID : dirtyIDs)
{
- CDOIDUtil.write(out, dirtyIDs[i]);
+ CDOIDUtil.write(out, dirtyID);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 3f43851..9d9ceb7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDObjectFactoryImpl;
import org.eclipse.emf.cdo.internal.server.PackageManager;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.Session;
@@ -165,17 +166,24 @@ public class OpenSessionIndication extends IndicationWithResponse
private void writeCDOIDObjectFactory(ExtendedDataOutputStream out, CDOIDObjectFactory factory) throws IOException
{
- Class<?>[] classes = factory.getCDOIDObjectClasses();
- if (classes == null)
+ if (factory.getClass() == CDOIDObjectFactoryImpl.class)
{
- classes = new Class<?>[0];
+ out.writeInt(0);
}
-
- out.writeInt(1 + classes.length);
- serializeClass(out, factory.getClass());
- for (Class<?> c : classes)
+ else
{
- serializeClass(out, c);
+ Class<?>[] classes = factory.getCDOIDObjectClasses();
+ if (classes == null)
+ {
+ classes = new Class<?>[0];
+ }
+
+ out.writeInt(1 + classes.length);
+ serializeClass(out, factory.getClass());
+ for (Class<?> c : classes)
+ {
+ serializeClass(out, c);
+ }
}
}
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 6c40628..10fbfd8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+
import org.eclipse.net4j.util.container.IContainer;
import java.util.Map;
@@ -33,6 +35,8 @@ public interface IRepository extends IContainer<IRepositoryElement>
public String getUUID();
+ public boolean isSupportingRevisionDeltas();
+
public boolean isSupportingAudits();
public boolean isVerifyingRevisions();
@@ -45,6 +49,8 @@ public interface IRepository extends IContainer<IRepositoryElement>
public IRevisionManager getRevisionManager();
+ public CDOIDMetaRange getMetaIDRange(int count);
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
index 07c543a..f6cc603 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IResourceManager.java
@@ -17,7 +17,13 @@ import org.eclipse.emf.cdo.protocol.id.CDOID;
*/
public interface IResourceManager extends IRepositoryElement
{
+ /**
+ * Returns the <code>CDOID</code> of the resource with the given path.
+ */
public CDOID getResourceID(String path);
+ /**
+ * Returns the path of the resource with the given <code>CDOID</code>.
+ */
public String getResourcePath(CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index 87ab5dc..86e02a7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -56,8 +56,16 @@ public interface IStoreReader extends IStoreAccessor
public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version);
+ /**
+ * Returns the <code>CDOID</code> of the resource with the given path if a resource with this path exists in the
+ * store, <code>null</code> otherwise.
+ */
public CDOID readResourceID(String path);
+ /**
+ * Returns the path of the resource with the given <code>CDOID</code> if a resource with this <code>CDOID</code>
+ * exists in the store, <code>null</code> otherwise.
+ */
public String readResourcePath(CDOID id);
public CDORevision verifyRevision(CDORevision revision);
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
index f29a6da..db8136b 100644
--- 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
@@ -11,13 +11,15 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClass;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
+import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
+import java.util.Map;
+
/**
* @author Eike Stepper
*/
@@ -25,27 +27,70 @@ public interface IStoreWriter extends IStoreReader
{
public IView getView();
+ public void commit(CommitContext context);
+
+ public void rollback(CommitContext context);
+
/**
- * Stores an array of complete package descriptions so that they can be restored to an identical state at a later
- * point in time.
- * <p>
- * <b>Note:</b> The implementor of this method must not assume that references to classes in this package or in any
- * other package are already resolved or are resolveable at the point in time when this method is called by the
- * framework.
- * <p>
+ * Represents the state of a single, logical commit operation which is driven through multiple calls to several
+ * methods on the {@link IStoreWriter} API. All these method calls get the same <code>CommitContext</code> instance
+ * passed so that the implementor of the {@link IStoreWriter} can track the state and progress of the commit
+ * operation.
*
- * @see CDOClassProxy#getPackageURI()
- * @see CDOClassProxy#getClassifierID()
+ * @author Eike Stepper
*/
- public void writePackages(CDOPackage... cdoPackages);
+ public interface CommitContext
+ {
+ /**
+ * Returns the ID of the transactional view (<code>ITransaction</code>) which is the scope of the commit
+ * operation represented by this <code>CommitContext</code>.
+ */
+ public int getTransactionID();
+
+ /**
+ * Returns the time stamp of this commit operation.
+ */
+ public long getTimeStamp();
+
+ /**
+ * Returns the temporary, transactional package manager associated with the commit operation represented by this
+ * <code>CommitContext</code>. In addition to the packages registered with the session this package manager also
+ * contains the new packages that are part of this commit operation.
+ */
+ public CDOPackageManager getPackageManager();
+
+ /**
+ * Returns an array of the new packages that are part of the commit operation represented by this
+ * <code>CommitContext</code>.
+ */
+ public CDOPackage[] getNewPackages();
+
+ /**
+ * Returns an array of the new objects that are part of the commit operation represented by this
+ * <code>CommitContext</code>.
+ */
+ public CDORevision[] getNewObjects();
- public CDOID primeNewObject(CDOClass cdoClass);
+ /**
+ * Returns an array of the dirty objects that are part of the commit operation represented by this
+ * <code>CommitContext</code>.
+ */
+ public CDORevision[] getDirtyObjects();
- public void writeRevision(CDORevision revision);
+ /**
+ * Returns an array of the dirty object deltas that are part of the commit operation represented by this
+ * <code>CommitContext</code>.
+ */
+ public CDORevisionDelta[] getDirtyObjectDeltas();
- public void writeRevisionDelta(CDORevisionDelta delta);
+ /**
+ * Returns an unmodifiable map from all temporary IDs (meta or not) to their persistent counter parts. It is
+ * initially populated with the mappings of all new meta objects.
+ */
+ public Map<CDOIDTemp, CDOID> getIDMappings();
- public void commit();
+ public void addIDMapping(CDOIDTemp oldID, CDOID newID);
- public void rollback();
+ public void applyIDMappings();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java
new file mode 100644
index 0000000..4c70f54
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITransaction.java
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 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.protocol.CDOProtocolView;
+import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ITransaction extends IView
+{
+ /**
+ * Returns the ID of this transactional view. Same as {@link CDOProtocolView#getViewID() getViewID()}.
+ */
+ public int getTransactionID();
+
+ /**
+ * Returns the temporary, transactional package manager associated with this ITransaction during the process of a
+ * commit operation. In addition to the packages registered with the session
+ * {@link IRepository#getPackageManager() package manager} this package manager also contains the new packages that
+ * are part of the commit operation.
+ *
+ * @return a temporary, transactional package manager if this ITransaction is in the process of a commit operation,
+ * <code>null</code> otherwise.
+ */
+ public CDOPackageManager getPackageManager();
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
index c74c605..b4da8ce 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -9,13 +9,14 @@ Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)",
- org.eclipse.net4j.jvm;bundle-version="0.8.0";resolution:=optional,
- org.eclipse.net4j.tcp;bundle-version="[0.8.0,0.9.0)";resolution:=optional,
- org.eclipse.emf.cdo.server;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.server.hibernate;bundle-version="[0.8.0,0.9.0)";resolution:=optional,
- org.eclipse.emf.cdo;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.tests.model1;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.tests.mango;bundle-version="[0.8.0,0.9.0)",
+ org.eclipse.emf.ecore.xmi;bundle-version="[2.3.0,3.0.0)";visibility:=reexport,
+ org.eclipse.net4j.jvm;bundle-version="[0.8.0,0.9.0)";resolution:=optional;visibility:=reexport,
+ org.eclipse.net4j.tcp;bundle-version="[0.8.0,0.9.0)";resolution:=optional;visibility:=reexport,
+ org.eclipse.emf.cdo.server;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
+ org.eclipse.emf.cdo;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.model1;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.mango;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.junit;visibility:=reexport
+Export-Package: org.eclipse.emf.cdo.tests,
+ org.eclipse.net4j.tests
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo.tests/plugin.properties b/plugins/org.eclipse.emf.cdo.tests/plugin.properties
index c28b294..ccd9d9d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.tests/plugin.properties
@@ -16,7 +16,7 @@
# append it to the end of the file, and change the code to use the new name.
# ==============================================================================
-pluginName = CDO Tests TDD (Incubation)
+pluginName = CDO Tests (Incubation)
providerName = Eclipse.org
# ==============================================================================
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index e4fcba9..8a3c0dc 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -25,6 +25,7 @@ public class AllTests
// $JUnit-BEGIN$
suite.addTestSuite(InitialTest.class);
suite.addTestSuite(StateMachineTest.class);
+ suite.addTestSuite(ViewTest.class);
suite.addTestSuite(ResourceTest.class);
suite.addTestSuite(ContainmentTest.class);
suite.addTestSuite(InvalidationTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/HibernateTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/HibernateTest.java
deleted file mode 100644
index 609b536..0000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/HibernateTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 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.tests;
-
-/**
- * @author Eike Stepper
- */
-public class HibernateTest
-{
- // private static final String REPOSITORY_NAME = "repo1";
- //
- // public static void main(String[] args) throws Exception
- // {
- // IManagedContainer container = initContainer();
- //
- // // Start the transport and create a repository
- // JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
- // CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository
- //
- // // Establish a communications connection and open a session with the repository
- // IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
- // CDOSession session = CDOUtil.openSession(connector, REPOSITORY_NAME, true);// Open a CDO session
- // session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);// Not needed after first commit!!!
- //
- // // Open a transaction, and create a new resource
- // CDOTransaction transaction = session.openTransaction();
- // Resource resource = transaction.createResource("/my/big/resource");
- // resource.getContents().add(getInputModel());
- // transaction.commit();
- //
- // // Cleanup
- // session.close();
- // connector.disconnect();
- // }
- //
- // private static IManagedContainer initContainer()
- // {
- // // Turn on tracing
- // OMPlatform.INSTANCE.setDebugging(true);
- // OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- // OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- //
- // // Prepare the standalone infra structure (not needed when running inside Eclipse)
- // IManagedContainer container = ContainerUtil.createContainer(); // Create a wiring container
- // Net4jUtil.prepareContainer(container); // Prepare the Net4j kernel
- // JVMUtil.prepareContainer(container); // Prepare the JVM transport
- // CDOServerUtil.prepareContainer(container); // Prepare the CDO server
- // CDOUtil.prepareContainer(container, false); // Prepare the CDO client
- // return container;
- // }
- //
- // private static IRepository createRepository() throws Exception
- // {
- // Map<String, String> props = new HashMap<String, String>();
- // props.put(Props.PROP_SUPPORTING_AUDITS, "false");
- // props.put(Props.PROP_SUPPORTING_REVISION_DELTAS, "true");
- // props.put(Props.PROP_VERIFYING_REVISIONS, "false");
- // props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
- // props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
- // return CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
- // }
- //
- // private static IStore createStore() throws Exception
- // {
- // DriverManager.setLogWriter(new PrintWriter(System.out));
- // Driver driver = new com.mysql.jdbc.Driver();
- // DriverManager.registerDriver(driver);
- // String driverName = driver.getClass().getName();
- // String dialectName = MySQLDialect.class.getName();
- //
- // Configuration configuration = new Configuration();
- // configuration.setProperty(Environment.DRIVER, driverName);
- // configuration.setProperty(Environment.URL, "jdbc:mysql://localhost/cdohibernate");
- // configuration.setProperty(Environment.USER, "root");
- // configuration.setProperty(Environment.DIALECT, dialectName);
- // configuration.setProperty(Environment.SHOW_SQL, "true");
- // return new HibernateStore(configuration);
- // }
- //
- // private static EObject getInputModel()
- // {
- // Category cat1 = Model1Factory.eINSTANCE.createCategory();
- // cat1.setName("CAT1");
- // Category cat2 = Model1Factory.eINSTANCE.createCategory();
- // cat2.setName("CAT2");
- // cat1.getCategories().add(cat2);
- // Product p1 = Model1Factory.eINSTANCE.createProduct();
- // p1.setName("P1");
- // cat1.getProducts().add(p1);
- // Product p2 = Model1Factory.eINSTANCE.createProduct();
- // p2.setName("P2");
- // cat1.getProducts().add(p2);
- // Product p3 = Model1Factory.eINSTANCE.createProduct();
- // p3.setName("P3");
- // cat2.getProducts().add(p3);
- // return cat1;
- // }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
index 68c79f6..5928fd3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
@@ -57,7 +57,7 @@ public class ImportXML
// Start the transport and create a repository
JVMUtil.getAcceptor(container, "default"); // Start the JVM transport
- CDOServerUtil.addRepository(container, createRepository()); // Start a CDO respository
+ CDOServerUtil.addRepository(container, createRepository()); // Start a CDO repository
// Establish a communications connection and open a session with the repository
IConnector connector = JVMUtil.getConnector(container, "default"); // Open a JVM connection
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
index 5ed5141..c32e966 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java
@@ -318,7 +318,7 @@ public class InvalidationTest extends AbstractCDOTest
msg("Changing name");
category1A.setName("CHANGED NAME");
- ITimeOuter timeOuter = new PollingTimeOuter(10, 100)
+ ITimeOuter timeOuter = new PollingTimeOuter(20, 100)
{
@Override
protected boolean successful()
@@ -328,14 +328,12 @@ public class InvalidationTest extends AbstractCDOTest
};
msg("Checking before commit");
- boolean timedOut = timeOuter.timedOut();
- assertEquals(true, timedOut);
+ assertEquals(true, timeOuter.timedOut());
msg("Committing");
transaction.commit();
msg("Checking after commit");
- timedOut = timeOuter.timedOut();
- assertEquals(false, timedOut);
+ assertEquals(false, timeOuter.timedOut());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
new file mode 100644
index 0000000..e4e2804
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 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.tests;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+
+/**
+ * @author Eike Stepper
+ */
+public class ViewTest extends AbstractCDOTest
+{
+ public void testHasResource() throws Exception
+ {
+ {
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ transaction.createResource("/test1");
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openModel1Session();
+ CDOView view = session.openView();
+ assertEquals(true, view.hasResource("/test1"));
+ assertEquals(false, view.hasResource("/test2"));
+ session.close();
+ }
+
+ public void testGetOrCreateResource() throws Exception
+ {
+ CDOID id;
+ {
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ transaction.commit();
+ id = resource.cdoID();
+ session.close();
+ }
+
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = session.openTransaction();
+ assertEquals(id, transaction.getOrCreateResource("/test1").cdoID());
+ assertNotSame(id, transaction.getOrCreateResource("/test2").cdoID());
+ session.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
index 63c5999..7e20f9c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
@@ -116,37 +116,15 @@ public class RollbackTransactionDialog extends TitleAreaDialog
protected String formatMessage()
{
- int newResources = transaction.getNewResources().size();
int newObjects = transaction.getNewObjects().size();
int dirtyObjects = transaction.getDirtyObjects().size();
- int count = (newResources > 0 ? 1 : 0) + (newObjects > 0 ? 1 : 0) + (dirtyObjects > 0 ? 1 : 0);
+ int count = (newObjects > 0 ? 1 : 0) + (dirtyObjects > 0 ? 1 : 0);
StringBuilder builder = new StringBuilder();
builder.append("This transaction contains ");
- if (newResources > 0)
- {
- builder.append(newResources);
- builder.append(" new resource");
- if (newResources > 1)
- {
- builder.append("s");
- }
- }
if (newObjects > 0)
{
- if (newResources > 0)
- {
- if (count > 2)
- {
- builder.append(", ");
- }
- else
- {
- builder.append(" and ");
- }
- }
-
builder.append(newObjects);
builder.append(" new object");
if (newObjects > 1)
@@ -157,7 +135,7 @@ public class RollbackTransactionDialog extends TitleAreaDialog
if (dirtyObjects > 0)
{
- if (count > 1)
+ if (count > 0)
{
builder.append(" and ");
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
index 2c9d188..34b3f49 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
@@ -42,6 +42,8 @@ public interface CDOTransaction extends CDOView
*/
public CDOResource createResource(String path);
+ public CDOResource getOrCreateResource(String path);
+
public CDOObject newInstance(EClass eClass);
public CDOObject newInstance(CDOClass cdoClass);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionFinishedEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionFinishedEvent.java
index 34524ec..535f158 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionFinishedEvent.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionFinishedEvent.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import java.util.Map;
@@ -21,7 +22,7 @@ public interface CDOTransactionFinishedEvent extends CDOViewEvent
{
public Type getType();
- public Map<CDOID, CDOID> getIDMappings();
+ public Map<CDOIDTemp, CDOID> getIDMappings();
public enum Type
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index a774bc2..e81c106 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -55,6 +55,8 @@ public interface CDOView extends CDOProtocolView, INotifier
*/
public CDORevision getRevision(CDOID id);
+ public boolean hasResource(String path);
+
/**
* @see ResourceSet#getResource(URI, boolean)
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java
index c8fc2eb..e36d510 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java
@@ -39,7 +39,7 @@ public class EresourceFactoryImpl extends EFactoryImpl implements EresourceFacto
try
{
EresourceFactory theEresourceFactory = (EresourceFactory)EPackage.Registry.INSTANCE
- .getEFactory("http://www.eclipse.org/emf/CDO/resource/1.0.0");
+ .getEFactory("http://www.eclipse.org/emf/CDO/resource/1.0.0");
if (theEresourceFactory != null)
{
return theEresourceFactory;
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 f81815c..a5f78e9 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
@@ -427,7 +427,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
CDOIDTemp lowerBound = new CDOIDTempMetaImpl(lastTempMetaID + 1);
CDOIDMetaRange range = CDOIDUtil.createMetaRange(lowerBound, 0);
range = registerMetaInstance((InternalEObject)ePackage, range);
- lastTempMetaID = ((CDOIDTemp)range.getUpperBound()).getValue();
+ lastTempMetaID = ((CDOIDTemp)range.getUpperBound()).getIntValue();
return range;
}
@@ -700,14 +700,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
/**
* @author Eike Stepper
*/
- private final class CDOIDObjectFactoryClassLoader extends ClassLoader
- {
- public CDOIDObjectFactoryClassLoader()
- {
- super(OM.BUNDLE.getClass().getClassLoader());
- }
- }
-
private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index bafcf04..d8d3351 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.protocol.revision.delta.CDOFeatureDelta;
@@ -421,7 +422,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CommitTransactionResult data)
{
CDOViewImpl view = (CDOViewImpl)object.cdoView();
- Map<CDOID, CDOID> idMappings = data.getIDMappings();
+ Map<CDOIDTemp, CDOID> idMappings = data.getIDMappings();
// Adjust object
CDOID id = object.cdoID();
@@ -593,7 +594,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, ResourceAndView data)
{
CDOID id = requestID(data.resource, data.view);
- if (id == CDOID.NULL)
+ if (id.isNull())
{
throw new ServerException("Resource not available: " + data.resource.getPath());
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 313a370..3dcba3a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -167,11 +167,17 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
return Collections.unmodifiableMap(newObjects);
}
+ /**
+ * TODO Consolidate with {@link #getRevisionDeltas()}
+ */
public Map<CDOID, CDOObject> getDirtyObjects()
{
return Collections.unmodifiableMap(dirtyObjects);
}
+ /**
+ * TODO Consolidate with {@link #getDirtyObjects()}
+ */
public Map<CDOID, CDORevisionDelta> getRevisionDeltas()
{
return Collections.unmodifiableMap(revisionDeltas);
@@ -188,6 +194,19 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
return (CDOResource)getResourceSet().createResource(createURI);
}
+ public CDOResource getOrCreateResource(String path)
+ {
+ CDOID id = getResourceID(path);
+ if (id == null || id.isNull())
+ {
+ return createResource(path);
+ }
+ else
+ {
+ return addResource(id, path);
+ }
+ }
+
public void commit() throws TransactionException
{
if (dirty)
@@ -236,7 +255,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
}
cleanUp();
- Map<CDOID, CDOID> idMappings = result.getIDMappings();
+ Map<CDOIDTemp, CDOID> idMappings = result.getIDMappings();
fireEvent(new FinishedEvent(CDOTransactionFinishedEvent.Type.COMMITTED, idMappings));
}
catch (RuntimeException ex)
@@ -280,7 +299,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
}
cleanUp();
- Map<CDOID, CDOID> idMappings = Collections.emptyMap();
+ Map<CDOIDTemp, CDOID> idMappings = Collections.emptyMap();
fireEvent(new FinishedEvent(CDOTransactionFinishedEvent.Type.ROLLED_BACK, idMappings));
}
catch (RuntimeException ex)
@@ -475,9 +494,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
private Type type;
- private Map<CDOID, CDOID> idMappings;
+ private Map<CDOIDTemp, CDOID> idMappings;
- private FinishedEvent(Type type, Map<CDOID, CDOID> idMappings)
+ private FinishedEvent(Type type, Map<CDOIDTemp, CDOID> idMappings)
{
this.type = type;
this.idMappings = idMappings;
@@ -488,7 +507,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
return type;
}
- public Map<CDOID, CDOID> getIDMappings()
+ public Map<CDOIDTemp, CDOID> getIDMappings()
{
return idMappings;
}
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 6f37962..5ac3d46 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
@@ -37,6 +37,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.ReadOnlyException;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest;
import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
@@ -45,6 +46,7 @@ import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.ref.ReferenceValueMap;
+import org.eclipse.net4j.util.transaction.TransactionException;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
@@ -182,6 +184,26 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
throw new ReadOnlyException("CDO view is read only: " + this);
}
+ public boolean hasResource(String path)
+ {
+ CDOID id = getResourceID(path);
+ return id != null && !id.isNull();
+ }
+
+ public CDOID getResourceID(String path)
+ {
+ try
+ {
+ IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
+ ResourceIDRequest request = new ResourceIDRequest(session.getChannel(), path);
+ return failOverStrategy.send(request);
+ }
+ catch (Exception ex)
+ {
+ throw new TransactionException(ex);
+ }
+ }
+
public CDOResource getResource(String path)
{
URI uri = CDOUtil.createResourceURI(path);
@@ -190,11 +212,12 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
public CDOResourceImpl getResource(CDOID resourceID)
{
- if (resourceID == null || resourceID == CDOID.NULL)
+ if (resourceID == null || resourceID.isNull())
{
throw new IllegalArgumentException("resourceID == null || resourceID == CDOID.NULL");
}
+ // TODO What about somply looking in the objects cache of this view as well?
ResourceSet resourceSet = getResourceSet();
EList<Resource> resources = resourceSet.getResources();
for (Resource resource : resources)
@@ -214,18 +237,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
ResourcePathRequest request = new ResourcePathRequest(session.getChannel(), resourceID);
String path = failOverStrategy.send(request);
-
- CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource();
- resource.setPath(path);
-
- InternalCDOObject resourceObject = resource;
- resourceObject.cdoInternalSetID(resourceID);
- resourceObject.cdoInternalSetView(this);
- resourceObject.cdoInternalSetResource(resource);
- resourceObject.cdoInternalSetState(CDOState.PROXY);
-
- resourceSet.getResources().add(resource);
- return resource;
+ return addResource(resourceID, path);
}
catch (RuntimeException ex)
{
@@ -237,6 +249,22 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
+ public CDOResourceImpl addResource(CDOID id, String path)
+ {
+ CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource();
+ resource.setPath(path);
+
+ InternalCDOObject resourceObject = resource;
+ resourceObject.cdoInternalSetID(id);
+ resourceObject.cdoInternalSetView(this);
+ resourceObject.cdoInternalSetResource(resource);
+ resourceObject.cdoInternalSetState(CDOState.PROXY);
+
+ ResourceSet resourceSet = getResourceSet();
+ resourceSet.getResources().add(resource);
+ return resource;
+ }
+
public InternalCDOObject newInstance(EClass eClass)
{
EObject eObject = EcoreUtil.create(eClass);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index d159cc5..c10727c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
@@ -63,11 +64,47 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
+ List<CDOPackage> newPackages = transaction.getNewPackages();
+ Collection<CDOResource> newResources = transaction.getNewResources().values();
+ Collection<CDOObject> newObjects = transaction.getNewObjects().values();
+ Collection<CDORevisionDelta> dirtyObjects = transaction.getRevisionDeltas().values();
+
out.writeInt(transaction.getViewID());
- writeNewPackages(out);
- writeNewResources(out);
- writeNewObjects(out);
- writeRevisionDeltas(out);
+ out.writeInt(newPackages.size());
+ out.writeInt(newResources.size() + newObjects.size());
+ out.writeInt(dirtyObjects.size());
+
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing {0} new packages", newPackages.size());
+ }
+
+ for (CDOPackage newPackage : newPackages)
+ {
+ CDOModelUtil.writePackage(out, newPackage);
+ }
+
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing {0} new objects", newResources.size() + newObjects.size());
+ }
+
+ writeRevisions(out, newResources);
+ writeRevisions(out, newObjects);
+
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing {0} dirty objects", dirtyObjects.size());
+ }
+
+ RevisionAdjuster revisionAdjuster = new RevisionAdjuster(transaction);
+ for (CDORevisionDelta revisionDelta : dirtyObjects)
+ {
+ revisionDelta.write(out, transaction);
+ CDOObject object = transaction.getDirtyObjects().get(revisionDelta.getID());
+ InternalCDORevision revision = (InternalCDORevision)object.cdoRevision();
+ revisionAdjuster.adjustRevision(revision, revisionDelta);
+ }
}
@Override
@@ -93,7 +130,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
((CDOPackageImpl)newPackage).setMetaIDRange(newRange);
for (int i = 0; i < oldRange.size(); i++)
{
- CDOID oldID = oldRange.get(i);
+ CDOIDTemp oldID = (CDOIDTemp)oldRange.get(i);
CDOID newID = newRange.get(i);
session.remapMetaInstance(oldID, newID);
result.addIDMapping(oldID, newID);
@@ -102,7 +139,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
for (;;)
{
- CDOID oldID = CDOIDUtil.read(in, session);
+ CDOIDTemp oldID = (CDOIDTemp)CDOIDUtil.read(in, session);
if (oldID.isNull())
{
break;
@@ -115,43 +152,6 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
return result;
}
- private void writeNewPackages(ExtendedDataOutputStream out) throws IOException
- {
- List<CDOPackage> newPackages = transaction.getNewPackages();
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Writing {0} new packages", newPackages.size());
- }
-
- out.writeInt(newPackages.size());
- for (CDOPackage newPackage : newPackages)
- {
- CDOModelUtil.writePackage(out, newPackage);
- }
- }
-
- private void writeNewResources(ExtendedDataOutputStream out) throws IOException
- {
- Collection<CDOResource> newResources = transaction.getNewResources().values();
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Writing {0} new resources", newResources.size());
- }
-
- writeRevisions(out, newResources);
- }
-
- private void writeNewObjects(ExtendedDataOutputStream out) throws IOException
- {
- Collection<CDOObject> newObjects = transaction.getNewObjects().values();
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Writing {0} new objects", newObjects.size());
- }
-
- writeRevisions(out, newObjects);
- }
-
@SuppressWarnings("unused")
private void writeDirtyObjects(ExtendedDataOutputStream out) throws IOException
{
@@ -164,28 +164,8 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
writeRevisions(out, dirtyObjects);
}
- private void writeRevisionDeltas(ExtendedDataOutputStream out) throws IOException
- {
- Collection<CDORevisionDelta> revisionDeltas = transaction.getRevisionDeltas().values();
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Writing {0} revision deltas", revisionDeltas.size());
- }
-
- RevisionAdjuster revisionAdjuster = new RevisionAdjuster(transaction);
- out.writeInt(revisionDeltas.size());
- for (CDORevisionDelta revisionDelta : revisionDeltas)
- {
- revisionDelta.write(out, transaction);
- CDOObject object = transaction.getDirtyObjects().get(revisionDelta.getID());
- InternalCDORevision revision = (InternalCDORevision)object.cdoRevision();
- revisionAdjuster.adjustRevision(revision, revisionDelta);
- }
- }
-
private void writeRevisions(ExtendedDataOutputStream out, Collection<?> objects) throws IOException
{
- out.writeInt(objects.size());
for (Iterator<?> it = objects.iterator(); it.hasNext();)
{
CDOObject object = (CDOObject)it.next();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
index 2c332c7..fe75980 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionResult.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import java.util.HashMap;
import java.util.Map;
@@ -24,7 +25,7 @@ public final class CommitTransactionResult
private long timeStamp;
- private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+ private Map<CDOIDTemp, CDOID> idMappings = new HashMap<CDOIDTemp, CDOID>();
public CommitTransactionResult(String rollbackMessage)
{
@@ -46,12 +47,12 @@ public final class CommitTransactionResult
return timeStamp;
}
- public Map<CDOID, CDOID> getIDMappings()
+ public Map<CDOIDTemp, CDOID> getIDMappings()
{
return idMappings;
}
- void addIDMapping(CDOID oldID, CDOID newID)
+ void addIDMapping(CDOIDTemp oldID, CDOID newID)
{
idMappings.put(oldID, newID);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
index 71cb799..f4af60f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDObjectFactoryImpl;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
@@ -118,10 +119,17 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
}
int classes = in.readInt();
- result.setCDOIDObjectFactoryClass(deserializeClass(in));
- for (int i = 1; i < classes; i++)
+ if (classes == 0)
{
- result.addCDOIDObjectClass(deserializeClass(in));
+ result.setCDOIDObjectFactoryClass(CDOIDObjectFactoryImpl.class);
+ }
+ else
+ {
+ result.setCDOIDObjectFactoryClass(deserializeClass(in));
+ for (int i = 1; i < classes; i++)
+ {
+ result.addCDOIDObjectClass(deserializeClass(in));
+ }
}
return result;
@@ -158,29 +166,4 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
throw WrappedException.wrap(ex);
}
}
-
- private static final class CustomObjectInputStream extends ObjectInputStream
- {
- public CustomObjectInputStream(InputStream in) throws IOException
- {
- super(in);
- }
-
- @Override
- protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException
- {
- String className = v.getName();
- ClassLoader loader = getClass().getClassLoader();
-
- try
- {
- return loader.loadClass(className);
- }
- catch (ClassNotFoundException ex)
- {
- ex.printStackTrace();
- return super.resolveClass(v);
- }
- }
- }
}