summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-02-01 14:22:44 (EST)
committerEike Stepper2008-02-01 14:22:44 (EST)
commit25816af54d97d5c24bec1476fc934d2ce453b818 (patch)
tree25ccfcbf31d06aced74d1747388fca068f1215aa
parent904f18144ce187fb17aa3d8ba9db9ed42c20acce (diff)
downloadcdo-25816af54d97d5c24bec1476fc934d2ce453b818.zip
cdo-25816af54d97d5c24bec1476fc934d2ce453b818.tar.gz
cdo-25816af54d97d5c24bec1476fc934d2ce453b818.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/db/IMappingStrategy.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LongIDStore.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreWriter.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java63
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java19
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java141
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java35
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java19
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java19
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java72
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java105
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java33
55 files changed, 676 insertions, 451 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
index 72256ba..549d162 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
@@ -45,7 +45,7 @@ public interface IMappingStrategy
public String readResourcePath(IDBStoreReader storeReader, CDOID id);
/**
- * Must return the next CDOID value to be used for new objects.
+ * Must return the maximum CDOID value .
*/
public long repairAfterCrash(Connection connection);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
index f1efcf4..e3d00d4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/AttributeMapping.java
@@ -126,7 +126,7 @@ public abstract class AttributeMapping extends FeatureMapping implements IAttrib
return null;
}
- return CDOIDUtil.create(id);
+ return CDOIDUtil.createCDOID(id);
}
}
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 ed003d6..4089dd8 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
@@ -141,7 +141,7 @@ public abstract class ClassMapping implements IClassMapping
protected void appendRevisionInfos(StringBuilder builder, InternalCDORevision revision, boolean full)
{
- builder.append(revision.getID().getValue());
+ builder.append(CDOIDUtil.getLong(revision.getID()));
builder.append(", ");
builder.append(revision.getVersion());
if (full)
@@ -153,9 +153,9 @@ public abstract class ClassMapping implements IClassMapping
builder.append(", ");
builder.append(revision.getRevised());
builder.append(", ");
- builder.append(revision.getResourceID().getValue());
+ builder.append(CDOIDUtil.getLong(revision.getResourceID()));
builder.append(", ");
- builder.append(revision.getContainerID().getValue());
+ builder.append(CDOIDUtil.getLong(revision.getContainerID()));
builder.append(", ");
builder.append(revision.getContainingFeatureID());
}
@@ -467,7 +467,7 @@ public abstract class ClassMapping implements IClassMapping
builder.append(" WHERE ");
builder.append(CDODBSchema.ATTRIBUTES_ID);
builder.append("=");
- builder.append(revision.getID().getValue());
+ builder.append(CDOIDUtil.getLong(revision.getID()));
builder.append(" AND ");
builder.append(CDODBSchema.ATTRIBUTES_VERSION);
builder.append("=");
@@ -546,7 +546,7 @@ public abstract class ClassMapping implements IClassMapping
protected void readAttributes(IDBStoreReader storeReader, InternalCDORevision revision, String where,
boolean readVersion)
{
- long id = revision.getID().getValue();
+ long id = CDOIDUtil.getLong(revision.getID());
StringBuilder builder = new StringBuilder(readVersion ? selectPrefixWithVersion : selectPrefix);
builder.append(id);
if (where != null)
@@ -580,8 +580,8 @@ public abstract class ClassMapping implements IClassMapping
revision.setCreated(resultSet.getLong(i++));
revision.setRevised(resultSet.getLong(i++));
- revision.setResourceID(CDOIDUtil.create(resultSet.getLong(i++)));
- revision.setContainerID(CDOIDUtil.create(resultSet.getLong(i++)));
+ revision.setResourceID(CDOIDUtil.createCDOID(resultSet.getLong(i++)));
+ revision.setContainerID(CDOIDUtil.createCDOID(resultSet.getLong(i++)));
revision.setContainingFeatureID(resultSet.getInt(i++));
}
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 36d8154..aec44d3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.server.LongIDStore;
import org.eclipse.emf.cdo.internal.server.Repository;
-import org.eclipse.emf.cdo.internal.server.Store;
import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
@@ -39,7 +39,7 @@ import java.util.Set;
/**
* @author Eike Stepper
*/
-public class DBStore extends Store implements IDBStore
+public class DBStore extends LongIDStore implements IDBStore
{
public static final String TYPE = "db";
@@ -202,7 +202,7 @@ public class DBStore extends Store implements IDBStore
{
// First start
DBUtil.insertRow(connection, dbAdapter, CDODBSchema.REPOSITORY, repository.getName(), repository.getUUID(), 1,
- System.currentTimeMillis(), 0, 0, 0);
+ System.currentTimeMillis(), 0, CRASHED, CRASHED);
MappingStrategy mappingStrategy = (MappingStrategy)getMappingStrategy();
@@ -216,15 +216,15 @@ public class DBStore extends Store implements IDBStore
else
{
// Restart
- long nextCDOID = DBUtil.selectMaximumLong(connection, CDODBSchema.REPOSITORY_NEXT_CDOID);
- long nextMetaID = DBUtil.selectMaximumLong(connection, CDODBSchema.REPOSITORY_NEXT_METAID);
- if (nextCDOID == 0L || nextMetaID == 0L)
+ long lastObjectID = DBUtil.selectMaximumLong(connection, CDODBSchema.REPOSITORY_NEXT_CDOID);
+ long lastMetaID = DBUtil.selectMaximumLong(connection, CDODBSchema.REPOSITORY_NEXT_METAID);
+ if (lastObjectID == CRASHED || lastMetaID == CRASHED)
{
OM.LOG.warn("Detected restart after crash");
}
- setNextOIDValue(nextCDOID);
- repository.setNextMetaIDValue(nextMetaID);
+ setLastObjectID(lastObjectID);
+ repository.setLastMetaID(lastMetaID);
StringBuilder builder = new StringBuilder();
builder.append("UPDATE ");
@@ -241,9 +241,12 @@ public class DBStore extends Store implements IDBStore
builder.append(CDODBSchema.REPOSITORY_STOPPED);
builder.append("=0, ");
builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID);
- builder.append("=0, ");
+ builder.append("=");
+ builder.append(CRASHED);
+ builder.append(", ");
builder.append(CDODBSchema.REPOSITORY_NEXT_METAID);
- builder.append("=0");
+ builder.append("=");
+ builder.append(CRASHED);
String sql = builder.toString();
int count = DBUtil.update(connection, sql);
@@ -272,11 +275,11 @@ public class DBStore extends Store implements IDBStore
builder.append(", ");
builder.append(CDODBSchema.REPOSITORY_NEXT_CDOID);
builder.append("=");
- builder.append(getNextOIDValue());
+ builder.append(getLastObjectID());
builder.append(", ");
builder.append(CDODBSchema.REPOSITORY_NEXT_METAID);
builder.append("=");
- builder.append(repository.getNextMetaIDValue());
+ builder.append(repository.getLastMetaID());
String sql = builder.toString();
int count = DBUtil.update(connection, sql);
@@ -295,16 +298,12 @@ public class DBStore extends Store implements IDBStore
try
{
Connection connection = storeReader.getConnection();
- long nextCDOID = mappingStrategy.repairAfterCrash(connection);
- long nextMetaID = DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGES_RANGE_UB) + 2L;
- if (nextMetaID == 2L)
- {
- nextMetaID = 1L;
- }
+ long maxObjectID = mappingStrategy.repairAfterCrash(connection);
+ long maxMetaID = DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGES_RANGE_UB);
- OM.LOG.info(MessageFormat.format("Repaired after crash: nextCDOID={0}, nextMetaID={1}", nextCDOID, nextMetaID));
- setNextOIDValue(nextCDOID);
- repository.setNextMetaIDValue(nextMetaID);
+ OM.LOG.info(MessageFormat.format("Repaired after crash: maxObjectID={0}, maxMetaID={1}", maxObjectID, maxMetaID));
+ setLastObjectID(maxObjectID);
+ repository.setLastMetaID(maxMetaID);
}
finally
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index db8550e..2f92c40 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -16,9 +16,9 @@ import org.eclipse.emf.cdo.server.IStoreFactory;
import org.eclipse.emf.cdo.server.db.CDODBUtil;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
-import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
index 242314d..89c20af 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -10,18 +10,18 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDMetaImpl;
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.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
+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.CDOModelUtil;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.protocol.model.CDOType;
@@ -77,9 +77,10 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
{
String packageURI = (String)values[0];
boolean dynamic = getBoolean(values[1]);
- long rangeLB = (Long)values[2];
- long rangeUB = (Long)values[3];
- CDOIDRange metaIDRange = rangeLB == 0L && rangeUB == 0L ? null : CDOIDUtil.createRange(rangeLB, rangeUB);
+ long lowerBound = (Long)values[2];
+ long upperBound = (Long)values[3];
+ CDOIDMetaRange metaIDRange = lowerBound == 0 ? null : CDOIDUtil.createMetaRange(new CDOIDMetaImpl(lowerBound),
+ (int)(upperBound - lowerBound) + 1);
result.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
return true;
}
@@ -90,7 +91,7 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
return result;
}
- public void readPackage(final CDOPackage cdoPackage)
+ public void readPackage(CDOPackage cdoPackage)
{
String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
Object[] values = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
@@ -98,12 +99,11 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
PackageServerInfo.setDBID(cdoPackage, (Integer)values[0]);
((CDOPackageImpl)cdoPackage).setName((String)values[1]);
((CDOPackageImpl)cdoPackage).setEcore((String)values[2]);
- readClasses((CDOPackageImpl)cdoPackage);
-
+ readClasses(cdoPackage);
mapPackages(cdoPackage);
}
- protected void readClasses(final CDOPackageImpl cdoPackage)
+ protected void readClasses(final CDOPackage cdoPackage)
{
IDBRowHandler rowHandler = new IDBRowHandler()
{
@@ -113,9 +113,9 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
int classifierID = (Integer)values[1];
String name = (String)values[2];
boolean isAbstract = getBoolean(values[3]);
- CDOClassImpl cdoClass = new CDOClassImpl(cdoPackage, classifierID, name, isAbstract);
+ CDOClass cdoClass = CDOModelUtil.createClass(cdoPackage, classifierID, name, isAbstract);
ClassServerInfo.setDBID(cdoClass, classID);
- cdoPackage.addClass(cdoClass);
+ ((CDOPackageImpl)cdoPackage).addClass(cdoClass);
readSuperTypes(cdoClass, classID);
readFeatures(cdoClass, classID);
return true;
@@ -127,7 +127,7 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
}
- protected void readSuperTypes(final CDOClassImpl cdoClass, int classID)
+ protected void readSuperTypes(final CDOClass cdoClass, int classID)
{
IDBRowHandler rowHandler = new IDBRowHandler()
{
@@ -135,7 +135,7 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
{
String packageURI = (String)values[0];
int classifierID = (Integer)values[1];
- cdoClass.addSuperType(new CDOClassRefImpl(packageURI, classifierID));
+ ((CDOClassImpl)cdoClass).addSuperType(CDOModelUtil.createClassRef(packageURI, classifierID));
return true;
}
};
@@ -145,7 +145,7 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
CDODBSchema.SUPERTYPES_SUPERTYPE_CLASSIFIER);
}
- protected void readFeatures(final CDOClassImpl cdoClass, int classID)
+ protected void readFeatures(final CDOClass cdoClass, int classID)
{
IDBRowHandler rowHandler = new IDBRowHandler()
{
@@ -153,26 +153,26 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
{
int featureID = (Integer)values[1];
String name = (String)values[2];
- CDOTypeImpl type = CDOTypeImpl.getType((Integer)values[3]);
+ CDOType type = CDOModelUtil.getType((Integer)values[3]);
boolean many = getBoolean(values[6]);
- CDOFeatureImpl feature;
+ CDOFeature feature;
if (type == CDOType.OBJECT)
{
String packageURI = (String)values[4];
int classifierID = (Integer)values[5];
boolean containment = getBoolean(values[7]);
- CDOClassRefImpl classRef = new CDOClassRefImpl(packageURI, classifierID);
+ CDOClassRef classRef = CDOModelUtil.createClassRef(packageURI, classifierID);
CDOClassProxy referenceType = new CDOClassProxy(classRef, cdoClass.getPackageManager());
- feature = new CDOFeatureImpl(cdoClass, featureID, name, referenceType, many, containment);
+ feature = CDOModelUtil.createReference(cdoClass, featureID, name, referenceType, many, containment);
}
else
{
- feature = new CDOFeatureImpl(cdoClass, featureID, name, type, many);
+ feature = CDOModelUtil.createAttribute(cdoClass, featureID, name, type, many);
}
FeatureServerInfo.setDBID(feature, (Integer)values[0]);
- cdoClass.addFeature(feature);
+ ((CDOClassImpl)cdoClass).addFeature(feature);
return true;
}
};
@@ -216,7 +216,7 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
Object[] res = DBUtil.select(getConnection(), where, CDODBSchema.CLASSES_CLASSIFIER, CDODBSchema.CLASSES_PACKAGE);
int classifierID = (Integer)res[0];
String packageURI = readPackageURI((Integer)res[1]);
- return new CDOClassRefImpl(packageURI, classifierID);
+ return CDOModelUtil.createClassRef(packageURI, classifierID);
}
public CDORevision readRevision(CDOID id, int referenceChunk)
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 fef4260..00eb11e 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,10 +12,11 @@ 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.internal.protocol.model.CDOFeatureImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+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;
+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.server.IView;
@@ -45,6 +46,11 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
super(store, view);
}
+ public CDOID primeNewObject(CDOClass cdoClass)
+ {
+ return getStore().getNextCDOID();
+ }
+
public void writePackages(CDOPackage... cdoPackages)
{
for (CDOPackage cdoPackage : cdoPackages)
@@ -69,9 +75,9 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
String name = cdoPackage.getName();
String ecore = cdoPackage.getEcore();
boolean dynamic = cdoPackage.isDynamic();
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
- long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
- long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
+ CDOIDMetaRange metaIDRange = cdoPackage.getMetaIDRange();
+ long lowerBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getLowerBound()).getValue();
+ long upperBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getUpperBound()).getValue();
String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?)";
DBUtil.trace(sql);
@@ -85,8 +91,8 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
pstmt.setString(3, name);
pstmt.setString(4, ecore);
pstmt.setBoolean(5, dynamic);
- pstmt.setLong(6, lb);
- pstmt.setLong(7, ub);
+ pstmt.setLong(6, lowerBound);
+ pstmt.setLong(7, upperBound);
if (pstmt.execute())
{
@@ -118,7 +124,7 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
int id = getStore().getNextClassID();
ClassServerInfo.setDBID(cdoClass, id);
- CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
+ CDOPackage cdoPackage = cdoClass.getContainingPackage();
int packageID = ServerInfo.getDBID(cdoPackage);
int classifierID = cdoClass.getClassifierID();
String name = cdoClass.getName();
@@ -131,7 +137,7 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
writeSuperType(id, superType);
}
- for (CDOFeatureImpl feature : cdoClass.getFeatures())
+ for (CDOFeature feature : cdoClass.getFeatures())
{
writeFeature(feature);
}
@@ -145,7 +151,7 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
.insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
}
- protected void writeFeature(CDOFeatureImpl feature)
+ protected void writeFeature(CDOFeature feature)
{
int id = getStore().getNextFeatureID();
FeatureServerInfo.setDBID(feature, id);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index 237bb3c..1e676f2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -73,7 +73,10 @@ public class HorizontalMappingStrategy extends MappingStrategy
if (table != null)
{
String sql = prefix + table + suffix;
- if (TRACER.isEnabled()) TRACER.trace(sql);
+ if (TRACER.isEnabled())
+ {
+ 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/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index f91149d..6b9d5c1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -329,7 +329,7 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
}
long id = resultSet.getLong(1);
- return CDOIDUtil.create(id);
+ return CDOIDUtil.createCDOID(id);
}
catch (SQLException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
index d5da0d9..94e3fe9 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObject;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.server.db.IDBStoreReader;
@@ -88,16 +89,14 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
if (currentResultSet.next())
{
long id = currentResultSet.getLong(1);
- if (withTypes)
+ nextID = CDOIDUtil.createCDOID(id);
+ if (withTypes && nextID instanceof CDOIDObject)
{
int classID = currentResultSet.getInt(2);
- CDOClassRef type = mappingStrategy.getClassRef(storeReader, classID);
- nextID = CDOIDUtil.create(id, type);
- }
- else
- {
- nextID = CDOIDUtil.create(id);
+ CDOClassRef classRef = mappingStrategy.getClassRef(storeReader, classID);
+ nextID = ((CDOIDObject)nextID).asLegacy(classRef);
}
+
return true;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
index 1a7fb52..fd1435e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectTypeCache.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.server.db.IDBStoreReader;
@@ -73,7 +74,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
builder.append(" WHERE ");
builder.append(idField);
builder.append("=");
- builder.append(id.getValue());
+ builder.append(CDOIDUtil.getLong(id));
String sql = builder.toString();
DBUtil.trace(sql);
@@ -109,7 +110,7 @@ public class ObjectTypeCache extends Lifecycle implements IObjectTypeCache
builder.append("INSERT INTO ");
builder.append(table);
builder.append(" VALUES (");
- builder.append(id.getValue());
+ builder.append(CDOIDUtil.getLong(id));
builder.append(", ");
builder.append(ClassServerInfo.getDBID(type));
builder.append(")");
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index a6ee1c7..f13935a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -75,13 +75,13 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
public void writeReference(IDBStoreWriter storeWriter, CDORevision revision)
{
- long source = revision.getID().getValue();
+ long source = CDOIDUtil.getLong(revision.getID());
int version = revision.getVersion();
int idx = 0;
for (Object element : ((InternalCDORevision)revision).getList(getFeature()))
{
- long target = ((CDOID)element).getValue();
+ long target = CDOIDUtil.getLong((CDOID)element);
StringBuilder builder = new StringBuilder(insertPrefix);
builder.append(source);
builder.append(", ");
@@ -115,7 +115,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
while (resultSet.next() && (referenceChunk == CDORevision.UNCHUNKED || --referenceChunk >= 0))
{
long target = resultSet.getLong(1);
- list.add(CDOIDUtil.create(target));
+ list.add(CDOIDUtil.createCDOID(target));
}
// TODO Optimize this?
@@ -164,7 +164,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
chunkSize = chunk.size();
}
- chunk.addID(indexInChunk++, CDOIDUtil.create(target));
+ chunk.addID(indexInChunk++, CDOIDUtil.createCDOID(target));
if (indexInChunk == chunkSize)
{
chunk = null;
@@ -221,7 +221,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
protected String createSelect(CDOID source, int version, String where)
{
StringBuilder builder = new StringBuilder(selectPrefix);
- builder.append(source.getValue());
+ builder.append(CDOIDUtil.getLong(source));
builder.append(" AND ");
builder.append(CDODBSchema.REFERENCES_VERSION);
builder.append("=");
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java
index 41b9f65..303f239 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ToOneReferenceMapping.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
/**
@@ -28,6 +29,6 @@ public class ToOneReferenceMapping extends AttributeMapping.AMObject
protected Long getRevisionValue(InternalCDORevision revision)
{
CDOID id = (CDOID)super.getRevisionValue(revision);
- return id.getValue();
+ return CDOIDUtil.getLong(id);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LongIDStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LongIDStore.java
new file mode 100644
index 0000000..6fbe661
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LongIDStore.java
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * 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.id.CDOIDObjectFactoryImpl;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
+import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class LongIDStore extends Store
+{
+ protected static final long CRASHED = -1L;
+
+ private static final CDOIDObjectFactory CDOID_OBJECT_FACTORY = new CDOIDObjectFactoryImpl();
+
+ private transient long lastObjectID;
+
+ public LongIDStore(String type)
+ {
+ super(type);
+ }
+
+ public synchronized CDOID getNextCDOID()
+ {
+ return CDOIDUtil.createCDOID(++lastObjectID);
+ }
+
+ public long getLastObjectID()
+ {
+ return lastObjectID;
+ }
+
+ public void setLastObjectID(long lastObjectID)
+ {
+ this.lastObjectID = lastObjectID;
+ }
+
+ public boolean wasCrashed()
+ {
+ return lastObjectID == CRASHED;
+ }
+
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return CDOID_OBJECT_FACTORY;
+ }
+}
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 aeba898..b8ec221 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
@@ -25,7 +25,7 @@ import java.util.Map;
/**
* @author Simon McDuff
*/
-public class MEMStore extends Store
+public class MEMStore extends LongIDStore
{
public static final String TYPE = "mem";
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 611577f..e3d6665 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,6 +13,7 @@ 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;
@@ -128,6 +129,11 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
throw new UnsupportedOperationException();
}
+ public CDOID primeNewObject(CDOClass cdoClass)
+ {
+ return getStore().getNextCDOID();
+ }
+
public void writePackages(CDOPackage... cdoPackages)
{
}
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 5033b39..174f2a4 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
@@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.server.IView;
/**
* @author Eike Stepper
*/
-public class NOOPStore extends Store
+public class NOOPStore extends LongIDStore
{
public static final String TYPE = "noop";
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 e437246..24e1bbb 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,6 +11,7 @@
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,6 +99,11 @@ public class NOOPStoreAccessor extends StoreAccessor implements IStoreReader, IS
throw new UnsupportedOperationException();
}
+ public CDOID primeNewObject(CDOClass cdoClass)
+ {
+ return getStore().getNextCDOID();
+ }
+
public void writePackages(CDOPackage... cdoPackages)
{
}
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 614611d..68b6ebd 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -12,6 +12,9 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
+import org.eclipse.emf.cdo.protocol.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;
@@ -40,11 +43,16 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
return repository;
}
- public void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackageImpl[] cdoPackages)
+ public CDOIDObjectFactory getCDOIDObjectFactory()
{
- for (CDOPackageImpl cdoPackage : cdoPackages)
+ return repository.getStore().getCDOIDObjectFactory();
+ }
+
+ public void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackage[] cdoPackages)
+ {
+ for (CDOPackage cdoPackage : cdoPackages)
{
- cdoPackage.setPackageManager(this);
+ ((CDOPackageImpl)cdoPackage).setPackageManager(this);
}
storeTransaction.execute(new AddPackagesOperation(cdoPackages));
@@ -79,7 +87,7 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
Collection<CDOPackageInfo> packageInfos = storeReader.readPackageInfos();
for (CDOPackageInfo info : packageInfos)
{
- addPackage(new CDOPackageImpl(this, info.getPackageURI(), info.isDynamic(), info.getMetaIDRange()));
+ addPackage(CDOModelUtil.createProxyPackage(this, info.getPackageURI(), info.isDynamic(), info.getMetaIDRange()));
}
}
finally
@@ -96,9 +104,9 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
*/
private final class AddPackagesOperation implements ITransactionalOperation<IStoreWriter>
{
- private CDOPackageImpl[] cdoPackages;
+ private CDOPackage[] cdoPackages;
- private AddPackagesOperation(CDOPackageImpl[] cdoPackages)
+ private AddPackagesOperation(CDOPackage[] cdoPackages)
{
this.cdoPackages = cdoPackages;
}
@@ -110,7 +118,7 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
public void phase2(IStoreWriter storeWriter)
{
- for (CDOPackageImpl cdoPackage : cdoPackages)
+ for (CDOPackage cdoPackage : cdoPackages)
{
addPackage(cdoPackage);
}
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 1cd082d..97a1405 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
@@ -11,7 +11,9 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDMetaImpl;
+import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IRepositoryElement;
@@ -31,8 +33,6 @@ import java.util.UUID;
*/
public class Repository extends Container<IRepositoryElement> implements IRepository
{
- private static final long INITIAL_META_ID_VALUE = 1;
-
private String name;
private IStore store;
@@ -57,7 +57,7 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
private IRepositoryElement[] elements;
- private long nextMetaIDValue = INITIAL_META_ID_VALUE;
+ private transient long lastMetaID;
public Repository()
{
@@ -173,22 +173,21 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return false;
}
- public CDOIDRange getMetaIDRange(long count)
+ public synchronized CDOIDMetaRange getMetaIDRange(int count)
{
- long lowerBound = nextMetaIDValue;
- nextMetaIDValue += count;
- nextMetaIDValue += count;
- return CDOIDUtil.createRange(lowerBound, nextMetaIDValue - 2);
+ CDOID lowerBound = new CDOIDMetaImpl(lastMetaID + 1);
+ lastMetaID += count;
+ return CDOIDUtil.createMetaRange(lowerBound, count);
}
- public void setNextMetaIDValue(long nextMetaIDValue)
+ public long getLastMetaID()
{
- this.nextMetaIDValue = nextMetaIDValue;
+ return lastMetaID;
}
- public long getNextMetaIDValue()
+ public void setLastMetaID(long lastMetaID)
{
- return nextMetaIDValue;
+ this.lastMetaID = lastMetaID;
}
@Override
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 47be3f6..a3a4574 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
@@ -13,13 +13,13 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOPathFeatureImpl;
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;
@@ -46,7 +46,7 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
{
private Repository repository;
- private CDOPathFeatureImpl cdoPathFeature;
+ private CDOPathFeature cdoPathFeature;
public RevisionManager(Repository repository)
{
@@ -59,6 +59,11 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
return repository;
}
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return repository.getStore().getCDOIDObjectFactory();
+ }
+
public void addRevision(ITransaction<IStoreWriter> storeTransaction, InternalCDORevision revision)
{
storeTransaction.execute(new AddRevisionOperation(revision));
@@ -98,10 +103,10 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
protected void ensureChunks(InternalCDORevision revision, int referenceChunk, IStoreReader storeReader)
{
CDOClassImpl cdoClass = (CDOClassImpl)revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ CDOFeature[] features = cdoClass.getAllFeatures();
for (int i = 0; i < features.length; i++)
{
- CDOFeatureImpl feature = features[i];
+ CDOFeature feature = features[i];
if (feature.isReference() && feature.isMany())
{
MoveableList<Object> list = revision.getList(feature);
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 ab09f92..bcf3462 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
@@ -12,7 +12,6 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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;
@@ -20,10 +19,11 @@ import org.eclipse.emf.cdo.internal.server.protocol.InvalidationNotification;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.CDOProtocolView.Type;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObject;
import org.eclipse.emf.cdo.protocol.id.CDOIDProvider;
-import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
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.server.ISession;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.SessionCreationException;
@@ -179,11 +179,17 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
return id;
}
- CDOClassRef type = getObjectTypeRef(id);
- return CDOIDUtil.create(id.getValue(), type);
+ CDOIDObject objectID = (CDOIDObject)id;
+ if (objectID.getClassRef() == null)
+ {
+ CDOClassRef classRef = getClassRef(objectID);
+ objectID = objectID.asLegacy(classRef);
+ }
+
+ return objectID;
}
- public CDOClassRef getObjectTypeRef(CDOID id)
+ public CDOClassRef getClassRef(CDOID id)
{
RevisionManager revisionManager = sessionManager.getRepository().getRevisionManager();
CDOClass cdoClass = revisionManager.getObjectType(id);
@@ -198,10 +204,10 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
{
RevisionManager revisionManager = getSessionManager().getRepository().getRevisionManager();
CDOClassImpl cdoClass = (CDOClassImpl)revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ CDOFeature[] features = cdoClass.getAllFeatures();
for (int i = 0; i < features.length; i++)
{
- CDOFeatureImpl feature = features[i];
+ CDOFeature feature = features[i];
if (feature.isReference() && !feature.isMany() && feature.isContainment())
{
Object value = revision.getValue(feature);
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 9d8c3f4..b390f85 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
@@ -10,8 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
-import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStore;
@@ -29,16 +27,12 @@ import java.util.Map;
*/
public abstract class Store extends Lifecycle implements IStore
{
- private static final long INITIAL_OID_VALUE = 2;
-
private String type;
private Map<String, String> properties;
private IRepository repository;
- private long nextOIDValue = INITIAL_OID_VALUE;
-
public Store(String type)
{
this.type = type;
@@ -74,29 +68,6 @@ public abstract class Store extends Lifecycle implements IStore
this.repository = repository;
}
- public CDOID getNextCDOID()
- {
- CDOID id = CDOIDUtil.create(nextOIDValue);
- ++nextOIDValue;
- ++nextOIDValue;
- return id;
- }
-
- public long getNextOIDValue()
- {
- return nextOIDValue;
- }
-
- public void setNextOIDValue(long nextOIDValue)
- {
- this.nextOIDValue = nextOIDValue;
- }
-
- public boolean wasCrashed()
- {
- return nextOIDValue == 0L;
- }
-
public boolean hasWriteDeltaSupport()
{
return false;
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 f9c22d5..0c0b1a8 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
@@ -12,8 +12,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.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.server.ISession;
@@ -92,11 +90,6 @@ public class StoreAccessor implements IStoreAccessor
return (InternalCDORevision)revision;
}
- public CDOID primeNewObject(CDOClass cdoClass)
- {
- return store.getNextCDOID();
- }
-
public void writeRevisionDelta(CDORevisionDelta delta)
{
throw new UnsupportedOperationException();
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 5f64874..363ecb3 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
@@ -21,8 +21,10 @@ 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.CDOIDRange;
+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;
@@ -57,7 +59,7 @@ public class CommitTransactionIndication extends CDOServerIndication
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CommitTransactionIndication.class);
- private CDOPackageImpl[] newPackages;
+ private CDOPackage[] newPackages;
private InternalCDORevision[] newResources;
@@ -153,9 +155,9 @@ public class CommitTransactionIndication extends CDOServerIndication
{
out.writeBoolean(true);
out.writeLong(timeStamp);
- for (CDOPackageImpl newPackage : newPackages)
+ for (CDOPackage newPackage : newPackages)
{
- CDOIDUtil.writeRange(out, newPackage.getMetaIDRange());
+ CDOIDUtil.writeMetaRange(out, newPackage.getMetaIDRange());
}
writeIDMappings(out);
@@ -166,7 +168,7 @@ public class CommitTransactionIndication extends CDOServerIndication
}
}
- private CDOPackageImpl[] readNewPackages(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
+ private CDOPackage[] readNewPackages(ExtendedDataInputStream in, IStoreWriter storeWriter) throws IOException
{
int size = in.readInt();
if (PROTOCOL.isEnabled())
@@ -175,18 +177,17 @@ public class CommitTransactionIndication extends CDOServerIndication
}
Repository repository = getRepository();
- CDOPackageImpl[] newPackages = new CDOPackageImpl[size];
+ CDOPackage[] newPackages = new CDOPackage[size];
for (int i = 0; i < size; i++)
{
- newPackages[i] = new CDOPackageImpl(transactionPackageManager, in);
- CDOIDRange oldRange = newPackages[i].getMetaIDRange();
+ newPackages[i] = CDOModelUtil.readPackage(transactionPackageManager, in);
+ CDOIDMetaRange oldRange = newPackages[i].getMetaIDRange();
if (oldRange != null && oldRange.isTemporary())
{
- CDOIDRange newRange = repository.getMetaIDRange(oldRange.getCount());
- newPackages[i].setMetaIDRange(newRange);
+ CDOIDMetaRange newRange = repository.getMetaIDRange(oldRange.size());
+ ((CDOPackageImpl)newPackages[i]).setMetaIDRange(newRange);
- long count = oldRange.getCount();
- for (long l = 0; l < count; l++)
+ for (int l = 0; l < oldRange.size(); l++)
{
CDOID oldID = oldRange.get(l);
CDOID newID = newRange.get(l);
@@ -263,7 +264,7 @@ public class CommitTransactionIndication extends CDOServerIndication
}
// TODO Remove newPackages parameter
- private void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackageImpl[] newPackages)
+ private void addPackages(ITransaction<IStoreWriter> storeTransaction, CDOPackage[] newPackages)
{
sessionPackageManager.addPackages(storeTransaction, newPackages);
}
@@ -336,9 +337,14 @@ public class CommitTransactionIndication extends CDOServerIndication
{
}
- public CDOPackageImpl lookupPackage(String uri)
+ public CDOIDObjectFactory getCDOIDObjectFactory()
{
- for (CDOPackageImpl cdoPackage : newPackages)
+ return sessionPackageManager.getCDOIDObjectFactory();
+ }
+
+ public CDOPackage lookupPackage(String uri)
+ {
+ for (CDOPackage cdoPackage : newPackages)
{
if (ObjectUtil.equals(cdoPackage.getPackageURI(), uri))
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
index a5d0356..e34097e 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
@@ -11,7 +11,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.internal.server.Session;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
@@ -21,6 +20,7 @@ import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
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.CDOModelUtil;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.collection.MoveableList;
@@ -59,7 +59,7 @@ public class LoadChunkIndication extends CDOReadIndication
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- id = CDOIDUtil.read(in);
+ id = CDOIDUtil.read(in, getStore().getCDOIDObjectFactory());
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read revision ID: {0}", id);
@@ -71,7 +71,7 @@ public class LoadChunkIndication extends CDOReadIndication
PROTOCOL.format("Read revision version: {0}", version);
}
- CDOClassRef classRef = new CDOClassRefImpl(in, null);
+ CDOClassRef classRef = CDOModelUtil.readClassRef(in);
int featureID = in.readInt();
CDOClass cdoClass = classRef.resolve(getPackageManager());
feature = cdoClass.lookupFeature(featureID);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
index eb55651..20915db 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
@@ -10,9 +10,10 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.ImplementationError;
@@ -28,7 +29,7 @@ public class LoadPackageIndication extends CDOReadIndication
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, LoadPackageIndication.class);
- private CDOPackageImpl cdoPackage;
+ private CDOPackage cdoPackage;
public LoadPackageIndication()
{
@@ -64,6 +65,6 @@ public class LoadPackageIndication extends CDOReadIndication
PROTOCOL.format("Writing package: {0}", cdoPackage);
}
- cdoPackage.write(out);
+ CDOModelUtil.writePackage(out, cdoPackage);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
index d4cb32b..a7574d8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadRevisionIndication.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.analyzer.CDOFetchRule;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
@@ -76,10 +77,11 @@ public class LoadRevisionIndication extends CDOReadIndication
PROTOCOL.format("Reading {0} IDs", size);
}
+ CDOIDObjectFactory factory = getStore().getCDOIDObjectFactory();
ids = new CDOID[size];
for (int i = 0; i < size; i++)
{
- CDOID id = CDOIDUtil.read(in);
+ CDOID id = CDOIDUtil.read(in, factory);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read ID: {0}", id);
@@ -97,7 +99,7 @@ public class LoadRevisionIndication extends CDOReadIndication
loadRevisionCollectionChunkSize = 1;
}
- contextID = CDOIDUtil.read(in);
+ contextID = CDOIDUtil.read(in, factory);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Reading fetch rules for context {0}", contextID);
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 52a77e9..3f43851 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
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.internal.server.Session;
import org.eclipse.emf.cdo.internal.server.SessionManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.server.IRepository;
@@ -83,6 +84,7 @@ public class OpenSessionIndication extends IndicationWithResponse
writeSessionID(out, session);
writeRepositoryUUID(out, repository);
writePackageURIs(out, repository.getPackageManager());
+ writeCDOIDObjectFactory(out, repository.getStore().getCDOIDObjectFactory());
}
catch (RepositoryNotFoundException ex)
{
@@ -154,10 +156,31 @@ public class OpenSessionIndication extends IndicationWithResponse
out.writeString(p.getPackageURI());
out.writeBoolean(p.isDynamic());
- CDOIDUtil.writeRange(out, p.getMetaIDRange());
+ CDOIDUtil.writeMetaRange(out, p.getMetaIDRange());
}
}
out.writeString(null);
}
+
+ private void writeCDOIDObjectFactory(ExtendedDataOutputStream out, CDOIDObjectFactory factory) throws IOException
+ {
+ 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);
+ }
+ }
+
+ private void serializeClass(ExtendedDataOutputStream out, Class<?> c) throws IOException
+ {
+ out.writeObject(c);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
index df7d2bb..e8eb25f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
@@ -10,12 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
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.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -51,10 +52,11 @@ public class QueryObjectTypesIndication extends CDOReadIndication
PROTOCOL.format("Reading {0} IDs", size);
}
+ CDOIDObjectFactory factory = getStore().getCDOIDObjectFactory();
ids = new CDOID[size];
for (int i = 0; i < ids.length; i++)
{
- ids[i] = CDOIDUtil.read(in);
+ ids[i] = CDOIDUtil.read(in, factory);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read ID: {0}", ids[i]);
@@ -67,13 +69,13 @@ public class QueryObjectTypesIndication extends CDOReadIndication
{
for (CDOID id : ids)
{
- CDOClassRef classRef = getSession().getObjectTypeRef(id);
+ CDOClassRef classRef = getSession().getClassRef(id);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Wrinting type: {0}", classRef);
}
- ((CDOClassRefImpl)classRef).write(out, null);
+ CDOModelUtil.writeClassRef(out, classRef);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
index f1050f6..eb9b415 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
@@ -43,7 +43,7 @@ public class ResourcePathIndication extends CDOReadIndication
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- final CDOID id = CDOIDUtil.read(in);
+ final CDOID id = CDOIDUtil.read(in, getStore().getCDOIDObjectFactory());
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read ID: {0}", id);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java
index 6209082..7d42e60 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.server.RevisionManager;
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.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -46,15 +47,22 @@ public class VerifyRevisionIndication extends CDOReadIndication
protected void indicating(ExtendedDataInputStream in) throws IOException
{
int size = in.readInt();
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading {0} IDs and versions", size);
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} IDs and versions", size);
+ }
RevisionManager revisionManager = getRevisionManager();
+ CDOIDObjectFactory factory = getStore().getCDOIDObjectFactory();
timeStamps = new long[size];
for (int i = 0; i < size; i++)
{
- CDOID id = CDOIDUtil.read(in);
+ CDOID id = CDOIDUtil.read(in, factory);
int version = in.readInt();
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID and version: {0}v{1}", id, version);
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Read ID and version: {0}v{1}", id, version);
+ }
InternalCDORevision revision = revisionManager.getRevisionByVersion(id, 0, version);
timeStamps[i] = revision.getRevised();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index e3598cf..3dae83d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
/**
@@ -21,12 +22,14 @@ public interface IStore extends IRepositoryElement
public String getStoreType();
+ public CDOIDObjectFactory getCDOIDObjectFactory();
+
/**
* Returns if this store supports the writing of modified newRevisions in terms of deltas.
* <p>
* The contract includes that store implementations with write delta support must also implement
- * {@link IStoreWriter#writeRevisionDelta(CDORevisionDelta) IStoreWriter.writeRevisionDelta(CDORevisionDeltaImpl)}
- * to not throw an <code>UnsupportedOperationException</code>.
+ * {@link IStoreWriter#writeRevisionDelta(CDORevisionDelta) IStoreWriter.writeRevisionDelta(CDORevisionDeltaImpl)} to
+ * not throw an <code>UnsupportedOperationException</code>.
*
* @return <code>true</code> if this store supports the writing of modified newRevisions in terms of deltas,
* <code>false</code> otherwise.
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 4d69af6..f29a6da 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
@@ -14,7 +14,6 @@ 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.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;
@@ -27,17 +26,12 @@ public interface IStoreWriter extends IStoreReader
public IView getView();
/**
- * Stores a complete description of a package so that it can be restored to an identical state at a later point in
- * time.
+ * 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. References to classes frequently appear in {@link CDOClass#getSuperTypes()} and in
- * {@link CDOFeature#getReferenceType()}. Instead
- * {@link org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl#getSuperTypeProxies() CDOClassImpl.getSuperTypeProxies()}
- * and
- * {@link org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl#getReferenceTypeProxy() CDOFeatureImpl.getReferenceTypeProxy()}
- * should be used.
+ * framework.
* <p>
*
* @see CDOClassProxy#getPackageURI()
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
index 4a01dd3..6baa148 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
@@ -39,7 +39,7 @@ public class PackageRegistryTest extends AbstractCDOTest
{
{
// Create resource in session 1
- CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
session.getPackageRegistry().putEPackage(Model1Package.eINSTANCE);
CDOTransaction transaction = session.openTransaction();
CDOResource res = transaction.createResource("/res");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
index 0cecbfd..dc25739 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java
@@ -192,7 +192,7 @@ public class RevisionHolderTest extends AbstractOMTest
public RevisionStub(long id)
{
- this.id = CDOIDUtil.create(id);
+ this.id = CDOIDUtil.createCDOID(id);
}
public CDOClass getCDOClass()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 5400c23..a075954 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.internal.cdo.CDOSessionFactory;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
@@ -153,7 +152,7 @@ public final class CDOUtil
public static CDOSession openSession(IConnector connector, String repositoryName) throws ConnectorException
{
- return openSession(connector, repositoryName, false);
+ return openSession(connector, repositoryName, true);
}
public static CDOSession openSession(IManagedContainer container, String description) throws ConnectorException
@@ -214,37 +213,39 @@ public final class CDOUtil
return uri.path();
}
+ @Deprecated
public static CDOID extractResourceID(URI uri)
{
- if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme()))
- {
- return null;
- }
-
- if (uri.hasAuthority())
- {
- return null;
- }
-
- if (!uri.isHierarchical())
- {
- return null;
- }
-
- if (uri.hasAbsolutePath())
- {
- return null;
- }
-
- try
- {
- String path = uri.path();
- return CDOIDUtil.parse(path);
- }
- catch (RuntimeException ex)
- {
- return null;
- }
+ throw new UnsupportedOperationException();
+ // if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme()))
+ // {
+ // return null;
+ // }
+ //
+ // if (uri.hasAuthority())
+ // {
+ // return null;
+ // }
+ //
+ // if (!uri.isHierarchical())
+ // {
+ // return null;
+ // }
+ //
+ // if (uri.hasAbsolutePath())
+ // {
+ // return null;
+ // }
+ //
+ // try
+ // {
+ // String path = uri.path();
+ // return CDOModelUtil.parse(path);
+ // }
+ // catch (RuntimeException ex)
+ // {
+ // return null;
+ // }
}
public static URI createResourceURI(String path)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
index 425ccb9..2ab2626 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
@@ -15,10 +15,11 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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.model.CDOClass;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
@@ -86,7 +87,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
return resource;
}
- public CDOClassImpl cdoClass()
+ public CDOClass cdoClass()
{
return CDOObjectImpl.getCDOClass(this);
}
@@ -268,10 +269,10 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
// Handle values
CDOClassImpl cdoClass = (CDOClassImpl)revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ CDOFeature[] features = cdoClass.getAllFeatures();
for (int i = 0; i < features.length; i++)
{
- CDOFeatureImpl feature = features[i];
+ CDOFeature feature = features[i];
Object instanceValue = getInstanceValue(instance, feature);
if (feature.isMany())
{
@@ -341,8 +342,8 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
// Handle values
CDOClassImpl cdoClass = (CDOClassImpl)revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
- for (CDOFeatureImpl feature : features)
+ CDOFeature[] features = cdoClass.getAllFeatures();
+ for (CDOFeature feature : features)
{
transferFeatureToInstance(view, feature);
}
@@ -388,7 +389,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
}
@SuppressWarnings("unchecked")
- protected void transferFeatureToInstance(CDOViewImpl view, CDOFeatureImpl feature)
+ protected void transferFeatureToInstance(CDOViewImpl view, CDOFeature feature)
{
Object value = revision.getValue(feature);
if (feature.isMany())
@@ -449,13 +450,13 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
throw new ImplementationError();
}
- protected Object getInstanceValue(InternalEObject instance, CDOFeatureImpl feature)
+ protected Object getInstanceValue(InternalEObject instance, CDOFeature feature)
{
EStructuralFeature eFeature = ModelUtil.getEFeature(feature, cdoView().getSession().getPackageRegistry());
return instance.eGet(eFeature);
}
- protected void setInstanceValue(InternalEObject instance, CDOFeatureImpl feature, Object value)
+ protected void setInstanceValue(InternalEObject instance, CDOFeature feature, Object value)
{
// TODO Don't use Java reflection
Class<?> instanceClass = instance.getClass();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 8d6eb59..dc318ca 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -14,10 +14,10 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.internal.cdo.bundle.OM;
@@ -84,7 +84,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return revision;
}
- public CDOClassImpl cdoClass()
+ public CDOClass cdoClass()
{
return getCDOClass(this);
}
@@ -220,7 +220,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
private void populateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature,
Object[] eSettings, int i)
{
- CDOFeatureImpl cdoFeature = ModelUtil.getCDOFeature(eFeature, view.getSession().getPackageManager());
+ CDOFeature cdoFeature = ModelUtil.getCDOFeature(eFeature, view.getSession().getPackageManager());
if (TRACER.isEnabled())
{
TRACER.format("Populating feature {0}", cdoFeature);
@@ -293,7 +293,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
private void depopulateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature,
Object[] eSettings, int i)
{
- CDOFeatureImpl cdoFeature = ModelUtil.getCDOFeature(eFeature, view.getSession().getPackageManager());
+ CDOFeature cdoFeature = ModelUtil.getCDOFeature(eFeature, view.getSession().getPackageManager());
if (TRACER.isEnabled())
{
TRACER.format("Depopulating feature {0}", cdoFeature);
@@ -583,7 +583,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return eClass().getName() + "@" + id;
}
- static CDOClassImpl getCDOClass(InternalCDOObject cdoObject)
+ static CDOClass getCDOClass(InternalCDOObject cdoObject)
{
CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
CDOSessionPackageManagerImpl packageManager = view.getSession().getPackageManager();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
index 6b90c46..0b7f472 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.EMFUtil;
@@ -50,7 +51,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
return session;
}
- public void putPackageDescriptor(CDOPackageImpl cdoPackage)
+ public void putPackageDescriptor(CDOPackage cdoPackage)
{
EPackage.Descriptor descriptor = new CDOPackageDescriptor(cdoPackage);
String uri = cdoPackage.getPackageURI();
@@ -81,8 +82,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
ModelUtil.prepareEPackage(ePackage);
}
- CDOPackageImpl cdoPackage = ModelUtil.getCDOPackage(ePackage, session.getPackageManager());
- cdoPackage.setPersistent(!cdoPackage.getMetaIDRange().isTemporary());
+ CDOPackage cdoPackage = ModelUtil.getCDOPackage(ePackage, session.getPackageManager());
+ ((CDOPackageImpl)cdoPackage).setPersistent(!cdoPackage.getMetaIDRange().isTemporary());
}
return super.put(key, value);
@@ -99,9 +100,9 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
*/
private final class CDOPackageDescriptor implements EPackage.Descriptor
{
- private CDOPackageImpl cdoPackage;
+ private CDOPackage cdoPackage;
- private CDOPackageDescriptor(CDOPackageImpl cdoPackage)
+ private CDOPackageDescriptor(CDOPackage cdoPackage)
{
this.cdoPackage = cdoPackage;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
index 5971e23..9d0ec88 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionResolverImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
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.revision.CDOReferenceProxy;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
@@ -56,6 +57,11 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C
return session;
}
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return session;
+ }
+
public CDOID resolveReferenceProxy(CDOReferenceProxy referenceProxy)
{
// Get proxy values
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 60678cd..cad14e1 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
@@ -13,13 +13,17 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.id.CDOIDTempMetaImpl;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObject;
+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.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -61,6 +65,7 @@ import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -69,14 +74,10 @@ import java.util.concurrent.ConcurrentMap;
/**
* @author Eike Stepper
*/
-public class CDOSessionImpl extends Container<CDOView> implements CDOSession
+public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CDOIDObjectFactory
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class);
- private static final long INITIAL_TEMPORARY_ID = -1L;
-
- private transient long nextTemporaryID = INITIAL_TEMPORARY_ID;
-
private int sessionID;
private boolean disableLegacyObjects;
@@ -115,11 +116,13 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
private Map<InternalEObject, CDOID> metaInstanceToIDMap = new HashMap<InternalEObject, CDOID>();
- private ConcurrentMap<CDOID, CDOClassImpl> types = new ConcurrentHashMap<CDOID, CDOClassImpl>();
+ private ConcurrentMap<CDOID, CDOClass> types = new ConcurrentHashMap<CDOID, CDOClass>();
private Map<ResourceSet, CDOViewImpl> views = new HashMap<ResourceSet, CDOViewImpl>();
- private transient int lastViewID = 0;
+ private transient int lastViewID;
+
+ private transient int lastTempMetaID;
private IListener channelListener = new LifecycleEventAdapter()
{
@@ -130,6 +133,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
}
};
+ private CDOIDObjectFactory cdoidObjectFactory;
+
public CDOSessionImpl(EPackage.Registry delegate)
{
packageRegistry = createPackageRegistry(delegate);
@@ -143,6 +148,16 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
return sessionID;
}
+ public Class<?>[] getCDOIDObjectClasses()
+ {
+ return cdoidObjectFactory.getCDOIDObjectClasses();
+ }
+
+ public CDOIDObject createCDOIDObject()
+ {
+ return cdoidObjectFactory.createCDOIDObject();
+ }
+
public boolean isDisableLegacyObjects()
{
return disableLegacyObjects;
@@ -357,12 +372,11 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
fireElementRemovedEvent(view);
}
- public CDOIDRange getTemporaryIDRange(long count)
+ public synchronized CDOIDMetaRange getTempMetaIDRange(int count)
{
- long id1 = nextTemporaryID;
- nextTemporaryID -= count + count;
- long id2 = nextTemporaryID + 2;
- return CDOIDUtil.createRange(id1, id2);
+ CDOIDTemp lowerBound = new CDOIDTempMetaImpl(lastTempMetaID + 1);
+ lastTempMetaID += count;
+ return CDOIDUtil.createMetaRange(lowerBound, count);
}
public InternalEObject lookupMetaInstance(CDOID id)
@@ -370,10 +384,10 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
InternalEObject metaInstance = idToMetaInstanceMap.get(id);
if (metaInstance == null)
{
- CDOPackageImpl[] cdoPackages = packageManager.getPackages();
- for (CDOPackageImpl cdoPackage : cdoPackages)
+ CDOPackage[] cdoPackages = packageManager.getPackages();
+ for (CDOPackage cdoPackage : cdoPackages)
{
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ CDOIDMetaRange metaIDRange = cdoPackage.getMetaIDRange();
if (metaIDRange != null && metaIDRange.contains(id))
{
EPackage ePackage = ModelUtil.getEPackage(cdoPackage, packageRegistry);
@@ -392,40 +406,37 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
return metaInstanceToIDMap.get(metaInstance);
}
- public void registerEPackage(EPackage ePackage, CDOIDRange metaIDRange)
+ public void registerEPackage(EPackage ePackage, CDOIDMetaRange metaIDRange)
{
if (metaIDRange.isTemporary())
{
throw new IllegalArgumentException("metaIDRange.isTemporary()");
}
- if (!metaIDRange.isMeta())
- {
- throw new IllegalArgumentException("!metaIDRange.isMeta()");
- }
-
- long count = registerMetaInstance((InternalEObject)ePackage, metaIDRange.getLowerBound().getValue());
- if (count != metaIDRange.getCount())
+ CDOIDMetaRange range = CDOIDUtil.createMetaRange(metaIDRange.getLowerBound(), 0);
+ range = registerMetaInstance((InternalEObject)ePackage, range);
+ if (range.size() != metaIDRange.size())
{
- throw new IllegalStateException("count != metaIDRange.getCount()");
+ throw new IllegalStateException("range.getCount() != metaIDRange.getCount()");
}
}
- public CDOIDRange registerEPackage(EPackage ePackage)
+ public CDOIDMetaRange registerEPackage(EPackage ePackage)
{
- long count = registerMetaInstance((InternalEObject)ePackage, nextTemporaryID);
- long newTempID = nextTemporaryID - 2L * count;
- CDOIDRange range = CDOIDUtil.createRange(nextTemporaryID, newTempID + 2L);
- nextTemporaryID = newTempID;
+ CDOIDTemp lowerBound = new CDOIDTempMetaImpl(lastTempMetaID + 1);
+ CDOIDMetaRange range = CDOIDUtil.createMetaRange(lowerBound, 0);
+ range = registerMetaInstance((InternalEObject)ePackage, range);
+ lastTempMetaID = ((CDOIDTemp)range.getUpperBound()).getValue();
return range;
}
/**
* TODO Synchronize?
*/
- private long registerMetaInstance(InternalEObject metaInstance, long idValue)
+ private CDOIDMetaRange registerMetaInstance(InternalEObject metaInstance, CDOIDMetaRange range)
{
- CDOID id = CDOIDUtil.create(idValue);
+ range = range.increase();
+ CDOID id = range.getUpperBound();
if (TRACER.isEnabled())
{
TRACER.format("Registering meta instance: {0} <-> {1}", id, metaInstance);
@@ -434,34 +445,12 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
idToMetaInstanceMap.put(id, metaInstance);
metaInstanceToIDMap.put(metaInstance, id);
- // EClass eClass = metaInstance.eClass();
- // for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- // {
- // Object value = metaInstance.eGet(feature);
- // if (value instanceof InternalEObject)
- // {
- // metaInstance.eResolveProxy((InternalEObject)value);
- // }
- // else if (value instanceof Collection)
- // {
- // for (Object element : (Collection)value)
- // {
- // if (element instanceof InternalEObject)
- // {
- // metaInstance.eResolveProxy((InternalEObject)element);
- // }
- // }
- // }
- // }
-
- long step = id.isTemporary() ? -2L : 2L;
- long count = 1L;
for (EObject content : metaInstance.eContents())
{
- count += registerMetaInstance((InternalEObject)content, idValue + step * count);
+ range = registerMetaInstance((InternalEObject)content, range);
}
- return count;
+ return range;
}
public void remapMetaInstance(CDOID oldID, CDOID newID)
@@ -481,18 +470,18 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
metaInstanceToIDMap.put(metaInstance, newID);
}
- public CDOClassImpl getObjectType(CDOID id)
+ public CDOClass getObjectType(CDOID id)
{
return types.get(id);
}
- public CDOClassImpl requestObjectType(CDOID id)
+ public CDOClass requestObjectType(CDOID id)
{
try
{
QueryObjectTypesRequest request = new QueryObjectTypesRequest(channel, Collections.singletonList(id));
CDOClassRef[] typeRefs = getFailOverStrategy().send(request);
- CDOClassImpl type = (CDOClassImpl)typeRefs[0].resolve(packageManager);
+ CDOClass type = typeRefs[0].resolve(packageManager);
registerObjectType(id, type);
return type;
}
@@ -502,7 +491,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
}
}
- public void registerObjectType(CDOID id, CDOClassImpl type)
+ public void registerObjectType(CDOID id, CDOClass type)
{
types.put(id, type);
}
@@ -630,6 +619,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
sessionID = result.getSessionID();
repositoryUUID = result.getRepositoryUUID();
+ cdoidObjectFactory = createCDOIDFactory(result.getCDOIDObjectFactoryClass(), result.getCDOIDObjectClasses());
packageManager.addPackageProxies(result.getPackageInfos());
packageManager.activate();
revisionManager.activate();
@@ -660,6 +650,22 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
super.doDeactivate();
}
+ private CDOIDObjectFactory createCDOIDFactory(Class<?> objectFactoryClass, List<Class<?>> objectClasses)
+ {
+ // ClassLoader classLoader = new CDOIDObjectFactoryClassLoader();
+
+ // return new CDOIDObjectFactoryImpl();
+
+ try
+ {
+ return (CDOIDObjectFactory)objectFactoryClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
private void sendViewsNotification(CDOViewImpl view)
{
try
@@ -690,6 +696,17 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
throw new ImplementationError("Invalid view type: " + type);
}
+ /**
+ * @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/CDOSessionPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
index 8413e80..6a0b11c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
@@ -11,13 +11,13 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOSessionPackageManager;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
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.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+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.protocol.util.TransportException;
@@ -53,6 +53,11 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
return session;
}
+ public CDOIDObjectFactory getCDOIDObjectFactory()
+ {
+ return session;
+ }
+
public CDOPackage convert(EPackage ePackage)
{
return ModelUtil.getCDOPackage(ePackage, this);
@@ -70,17 +75,17 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
public EPackage convert(CDOPackage cdoPackage)
{
- return ModelUtil.getEPackage((CDOPackageImpl)cdoPackage, session.getPackageRegistry());
+ return ModelUtil.getEPackage(cdoPackage, session.getPackageRegistry());
}
public EClass convert(CDOClass cdoClass)
{
- return ModelUtil.getEClass((CDOClassImpl)cdoClass, session.getPackageRegistry());
+ return ModelUtil.getEClass(cdoClass, session.getPackageRegistry());
}
public EStructuralFeature convert(CDOFeature cdoFeature)
{
- return ModelUtil.getEFeature((CDOFeatureImpl)cdoFeature, session.getPackageRegistry());
+ return ModelUtil.getEFeature(cdoFeature, session.getPackageRegistry());
}
public void addPackageProxies(Collection<CDOPackageInfo> packageInfos)
@@ -89,9 +94,9 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
{
String packageURI = info.getPackageURI();
boolean dynamic = info.isDynamic();
- CDOIDRange metaIDRange = info.getMetaIDRange();
+ CDOIDMetaRange metaIDRange = info.getMetaIDRange();
- CDOPackageImpl proxy = new CDOPackageImpl(this, packageURI, dynamic, metaIDRange);
+ CDOPackage proxy = CDOModelUtil.createProxyPackage(this, packageURI, dynamic, metaIDRange);
addPackage(proxy);
session.getPackageRegistry().putPackageDescriptor(proxy);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index d11d070..a3ce644 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -11,7 +11,6 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDOAddFeatureDeltaImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDOClearFeatureDeltaImpl;
@@ -111,7 +110,7 @@ public final class CDOStore implements EStore
public Object get(InternalEObject eObject, EStructuralFeature eFeature, int index)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("get({0}, {1}, {2})", cdoObject, cdoFeature, index);
@@ -135,7 +134,7 @@ public final class CDOStore implements EStore
return value;
}
- private void loadAhead(InternalCDORevision revision, CDOFeatureImpl cdoFeature, CDOID id, int index)
+ private void loadAhead(InternalCDORevision revision, CDOFeature cdoFeature, CDOID id, int index)
{
CDOSessionImpl session = view.getSession();
CDORevisionManagerImpl revisionManager = session.getRevisionManager();
@@ -191,7 +190,7 @@ public final class CDOStore implements EStore
public boolean isSet(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("isSet({0}, {1})", cdoObject, cdoFeature);
@@ -204,7 +203,7 @@ public final class CDOStore implements EStore
public int size(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("size({0}, {1})", cdoObject, cdoFeature);
@@ -217,7 +216,7 @@ public final class CDOStore implements EStore
public boolean isEmpty(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("isEmpty({0}, {1})", cdoObject, cdoFeature);
@@ -230,7 +229,7 @@ public final class CDOStore implements EStore
public boolean contains(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("contains({0}, {1}, {2})", cdoObject, cdoFeature, value);
@@ -248,7 +247,7 @@ public final class CDOStore implements EStore
public int indexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("indexOf({0}, {1}, {2})", cdoObject, cdoFeature, value);
@@ -266,7 +265,7 @@ public final class CDOStore implements EStore
public int lastIndexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("lastIndexOf({0}, {1}, {2})", cdoObject, cdoFeature, value);
@@ -284,7 +283,7 @@ public final class CDOStore implements EStore
public int hashCode(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("hashCode({0}, {1})", cdoObject, cdoFeature);
@@ -297,7 +296,7 @@ public final class CDOStore implements EStore
public Object[] toArray(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("toArray({0}, {1})", cdoObject, cdoFeature);
@@ -344,7 +343,7 @@ public final class CDOStore implements EStore
public Object set(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("set({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value);
@@ -383,7 +382,7 @@ public final class CDOStore implements EStore
public void unset(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("unset({0}, {1})", cdoObject, cdoFeature);
@@ -398,7 +397,7 @@ public final class CDOStore implements EStore
public void add(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("add({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value);
@@ -422,7 +421,7 @@ public final class CDOStore implements EStore
public Object remove(InternalEObject eObject, EStructuralFeature eFeature, int index)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("remove({0}, {1}, {2})", cdoObject, cdoFeature, index);
@@ -451,7 +450,7 @@ public final class CDOStore implements EStore
public void clear(InternalEObject eObject, EStructuralFeature eFeature)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("clear({0}, {1})", cdoObject, cdoFeature);
@@ -466,7 +465,7 @@ public final class CDOStore implements EStore
public Object move(InternalEObject eObject, EStructuralFeature eFeature, int target, int source)
{
InternalCDOObject cdoObject = getCDOObject(eObject);
- CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
+ CDOFeature cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
TRACER.format("move({0}, {1}, {2}, {3})", cdoObject, cdoFeature, target, source);
@@ -504,7 +503,7 @@ public final class CDOStore implements EStore
return FSMUtil.adapt(object, view);
}
- private CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
+ private CDOFeature getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
{
CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
if (view == null)
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 8a949b6..313a370 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
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.delta.InternalCDORevisionDelta;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.revision.delta.CDOFeatureDelta;
@@ -63,10 +64,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSCTION, CDOTransactionImpl.class);
- private static final long INITIAL_TEMPORARY_ID = -2L;
-
- private transient long nextTemporaryID = INITIAL_TEMPORARY_ID;
-
/**
* TODO Optimize by storing an array. See {@link Notifier}.
*/
@@ -88,6 +85,8 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
private long commitTimeout;
+ private int lastTemporaryID;
+
public CDOTransactionImpl(int id, CDOSessionImpl session)
{
super(id, session);
@@ -178,12 +177,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
return Collections.unmodifiableMap(revisionDeltas);
}
- public CDOID getNextTemporaryID()
+ public CDOIDTemp getNextTemporaryID()
{
- long id = nextTemporaryID;
- --nextTemporaryID;
- --nextTemporaryID;
- return CDOIDUtil.create(id);
+ return CDOIDUtil.createCDOIDTempObject(++lastTemporaryID);
}
public CDOResource createResource(String path)
@@ -401,7 +397,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
List<CDOPackage> newPackages = new ArrayList<CDOPackage>();
for (EPackage usedPackage : usedPackages)
{
- CDOPackageImpl cdoPackage = ModelUtil.getCDOPackage(usedPackage, packageManager);
+ CDOPackage cdoPackage = ModelUtil.getCDOPackage(usedPackage, packageManager);
if (cdoPackage == null)
{
throw new IllegalStateException("Missing CDO package: " + usedPackage.getNsURI());
@@ -449,7 +445,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
revisionDeltas.clear();
dirty = false;
conflict = false;
- nextTemporaryID = INITIAL_TEMPORARY_ID;
+ lastTemporaryID = 0;
}
/**
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 79183cb..6f37962 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
@@ -26,6 +26,8 @@ import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.InternalCDORevision;
import org.eclipse.emf.cdo.protocol.id.CDOID;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMeta;
+import org.eclipse.emf.cdo.protocol.id.CDOIDObject;
import org.eclipse.emf.cdo.protocol.id.CDOIDProvider;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
@@ -243,7 +245,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
public InternalCDOObject newInstance(CDOClass cdoClass)
{
- EClass eClass = ModelUtil.getEClass((CDOClassImpl)cdoClass, session.getPackageRegistry());
+ EClass eClass = ModelUtil.getEClass(cdoClass, session.getPackageRegistry());
if (eClass == null)
{
throw new IllegalStateException("No EClass for " + cdoClass);
@@ -278,7 +280,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
if (id.isMeta())
{
- lastLookupObject = createMetaObject(id);
+ lastLookupObject = createMetaObject((CDOIDMeta)id);
}
else
{
@@ -318,7 +320,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
/**
* @return Never <code>null</code>
*/
- private InternalCDOObject createMetaObject(CDOID id)
+ private InternalCDOObject createMetaObject(CDOIDMeta id)
{
if (TRACER.isEnabled())
{
@@ -376,7 +378,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
TRACER.format("Creating proxy for " + id);
}
- CDOClassImpl cdoClass = getObjectType(id);
+ CDOClass cdoClass = getObjectType(id);
InternalCDOObject object = newInstance(cdoClass);
if (object instanceof CDOResourceImpl)
{
@@ -389,18 +391,18 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return object;
}
- private CDOClassImpl getObjectType(CDOID id)
+ private CDOClass getObjectType(CDOID id)
{
- CDOClassImpl type = session.getObjectType(id);
+ CDOClass type = session.getObjectType(id);
if (type != null)
{
return type;
}
- CDOClassRef typeRef = id.getType();
- if (typeRef != null)
+ if (id.isLegacy())
{
- type = (CDOClassImpl)typeRef.resolve(session.getPackageManager());
+ CDOClassRef typeRef = ((CDOIDObject)id).getClassRef();
+ type = typeRef.resolve(session.getPackageManager());
session.registerObjectType(id, type);
return type;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index b21358e..d159cc5 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
@@ -17,12 +17,14 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
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.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
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.revision.CDORevision;
import org.eclipse.emf.cdo.protocol.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.internal.cdo.CDOSessionImpl;
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.RevisionAdjuster;
@@ -82,30 +84,31 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
long timeStamp = in.readLong();
CommitTransactionResult result = new CommitTransactionResult(timeStamp);
+ CDOSessionImpl session = transaction.getSession();
List<CDOPackage> newPackages = transaction.getNewPackages();
for (CDOPackage newPackage : newPackages)
{
- CDOIDRange oldRange = newPackage.getMetaIDRange();
- CDOIDRange newRange = CDOIDUtil.readRange(in);
+ CDOIDMetaRange oldRange = newPackage.getMetaIDRange();
+ CDOIDMetaRange newRange = CDOIDUtil.readMetaRange(in);
((CDOPackageImpl)newPackage).setMetaIDRange(newRange);
- for (long i = 0; i < oldRange.getCount(); i++)
+ for (int i = 0; i < oldRange.size(); i++)
{
CDOID oldID = oldRange.get(i);
CDOID newID = newRange.get(i);
- transaction.getSession().remapMetaInstance(oldID, newID);
+ session.remapMetaInstance(oldID, newID);
result.addIDMapping(oldID, newID);
}
}
for (;;)
{
- CDOID oldID = CDOIDUtil.read(in);
+ CDOID oldID = CDOIDUtil.read(in, session);
if (oldID.isNull())
{
break;
}
- CDOID newID = CDOIDUtil.read(in);
+ CDOID newID = CDOIDUtil.read(in, session);
result.addIDMapping(oldID, newID);
}
@@ -123,7 +126,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
out.writeInt(newPackages.size());
for (CDOPackage newPackage : newPackages)
{
- ((CDOPackageImpl)newPackage).write(out);
+ CDOModelUtil.writePackage(out, newPackage);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
index 5912cd4..2095975 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
@@ -57,14 +57,15 @@ public class InvalidationIndication extends Indication
PROTOCOL.format("Reading {0} IDs", size);
}
+ CDOSessionImpl session = getSession();
Set<CDOID> dirtyOIDs = new HashSet<CDOID>();
for (int i = 0; i < size; i++)
{
- CDOID dirtyOID = CDOIDUtil.read(in);
+ CDOID dirtyOID = CDOIDUtil.read(in, session);
dirtyOIDs.add(dirtyOID);
}
- getSession().notifyInvalidation(timeStamp, dirtyOIDs, null);
+ session.notifyInvalidation(timeStamp, dirtyOIDs, null);
}
protected CDOSessionImpl getSession()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
index ab69417..c147a0f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadChunkRequest.java
@@ -10,13 +10,15 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
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.CDOIDUtil;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
+import org.eclipse.emf.internal.cdo.CDOSessionImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.net4j.channel.IChannel;
@@ -69,8 +71,8 @@ public class LoadChunkRequest extends CDOClientRequest<CDOID>
{
PROTOCOL.format("Writing revision ID: {0}", id);
}
- CDOIDUtil.write(out, id);
+ CDOIDUtil.write(out, id);
int version = revision.getVersion();
if (revision.isTransactional())
{
@@ -81,37 +83,38 @@ public class LoadChunkRequest extends CDOClientRequest<CDOID>
{
PROTOCOL.format("Writing revision version: {0}", version);
}
- out.writeInt(version);
+ out.writeInt(version);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Writing feature: {0}", feature);
}
- CDOClassRefImpl classRef = (CDOClassRefImpl)feature.getContainingClass().createClassRef();
- classRef.write(out, null);
+ CDOClassRef classRef = feature.getContainingClass().createClassRef();
+ CDOModelUtil.writeClassRef(out, classRef);
out.writeInt(feature.getFeatureID());
-
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Writing fromIndex: {0}", fromIndex);
}
- out.writeInt(fromIndex);
+ out.writeInt(fromIndex);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Writing toIndex: {0}", toIndex);
}
+
out.writeInt(toIndex);
}
@Override
protected CDOID confirming(ExtendedDataInputStream in) throws IOException
{
+ CDOSessionImpl session = getSession();
CDOID accessID = null;
MoveableList<Object> list = revision.getList(feature);
for (int i = fromIndex; i <= toIndex; i++)
{
- CDOID id = CDOIDUtil.read(in);
+ CDOID id = CDOIDUtil.read(in, session);
list.set(i, id);
if (i == accessIndex)
{
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 accb02b..71cb799 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
@@ -11,7 +11,7 @@
package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.util.ServerException;
@@ -20,10 +20,14 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.signal.RequestWithConfirmation;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
import java.text.MessageFormat;
/**
@@ -104,7 +108,7 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
}
boolean dynamic = in.readBoolean();
- CDOIDRange metaIDRange = CDOIDUtil.readRange(in);
+ CDOIDMetaRange metaIDRange = CDOIDUtil.readMetaRange(in);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read package info: uri={0}, dynamic={1}, metaIDRange={2}", packageURI, dynamic, metaIDRange);
@@ -113,6 +117,70 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
result.addPackageInfo(packageURI, dynamic, metaIDRange);
}
+ int classes = in.readInt();
+ result.setCDOIDObjectFactoryClass(deserializeClass(in));
+ for (int i = 1; i < classes; i++)
+ {
+ result.addCDOIDObjectClass(deserializeClass(in));
+ }
+
return result;
}
+
+ private Class<?> deserializeClass(InputStream in) throws IOException
+ {
+ ObjectInputStream ois = new ObjectInputStream(in)
+ {
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException
+ {
+ String className = v.getName();
+ ClassLoader loader = OM.class.getClassLoader();
+
+ try
+ {
+ return loader.loadClass(className);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ ex.printStackTrace();
+ return super.resolveClass(v);
+ }
+ }
+ };
+
+ try
+ {
+ return (Class<?>)ois.readObject();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ 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);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
index 40e0ec0..b541b2f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
@@ -10,7 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import java.util.ArrayList;
@@ -27,6 +27,10 @@ public final class OpenSessionResult
private List<CDOPackageInfo> packageInfos = new ArrayList<CDOPackageInfo>();
+ private Class<?> cdoidFactoryClass;
+
+ private List<Class<?>> cdoidObjectClasses = new ArrayList<Class<?>>();
+
public OpenSessionResult(int sessionID, String repositoryUUID)
{
this.sessionID = sessionID;
@@ -48,8 +52,28 @@ public final class OpenSessionResult
return packageInfos;
}
- void addPackageInfo(String packageURI, boolean dynamic, CDOIDRange metaIDRange)
+ public Class<?> getCDOIDObjectFactoryClass()
+ {
+ return cdoidFactoryClass;
+ }
+
+ public List<Class<?>> getCDOIDObjectClasses()
+ {
+ return cdoidObjectClasses;
+ }
+
+ void addPackageInfo(String packageURI, boolean dynamic, CDOIDMetaRange metaIDRange)
{
packageInfos.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
}
+
+ void setCDOIDObjectFactoryClass(Class<?> c)
+ {
+ cdoidFactoryClass = c;
+ }
+
+ void addCDOIDObjectClass(Class<?> c)
+ {
+ cdoidObjectClasses.add(c);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
index 9f95f6d..aeb1450 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
@@ -10,11 +10,11 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOModelUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
@@ -73,7 +73,7 @@ public class QueryObjectTypesRequest extends CDOClientRequest<CDOClassRef[]>
CDOClassRef[] types = new CDOClassRef[ids.size()];
for (int i = 0; i < types.length; i++)
{
- types[i] = new CDOClassRefImpl(in, null);
+ types[i] = CDOModelUtil.readClassRef(in);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read type: {0}", types[i]);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
index bdc8be3..ae7b6b4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
@@ -59,7 +59,7 @@ public class ResourceIDRequest extends CDOClientRequest<CDOID>
@Override
protected CDOID confirming(ExtendedDataInputStream in) throws IOException
{
- CDOID id = CDOIDUtil.read(in);
+ CDOID id = CDOIDUtil.read(in, getSession());
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read ID: {0}", id);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
index a2423b1..9dde5c1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
@@ -13,15 +13,18 @@ package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
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.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.core.CDOCorePackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOResourceClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOResourcePackageImpl;
-import org.eclipse.emf.cdo.protocol.id.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
+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.CDOModelUtil;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
+import org.eclipse.emf.cdo.protocol.model.CDOType;
+import org.eclipse.emf.cdo.protocol.model.core.CDOCorePackage;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOResourceClass;
+import org.eclipse.emf.cdo.protocol.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.util.EMFUtil;
import org.eclipse.emf.internal.cdo.CDOFactoryImpl;
@@ -52,7 +55,7 @@ public final class ModelUtil
{
}
- public static CDOTypeImpl getCDOType(EStructuralFeature eFeature)
+ public static CDOType getCDOType(EStructuralFeature eFeature)
{
if (eFeature instanceof EReference)
{
@@ -83,8 +86,8 @@ public final class ModelUtil
case EcorePackage.ELONG_OBJECT:
case EcorePackage.ESHORT:
case EcorePackage.ESHORT_OBJECT:
- CDOTypeImpl type = CDOTypeImpl.getType(classifierID);
- if (type == CDOTypeImpl.OBJECT)
+ CDOType type = CDOModelUtil.getType(classifierID);
+ if (type == CDOType.OBJECT)
{
throw new ImplementationError("Attributes can not be of type OBJECT");
}
@@ -93,23 +96,23 @@ public final class ModelUtil
}
}
- return CDOTypeImpl.STRING;
+ return CDOType.STRING;
}
- public static void initializeCDOPackage(EPackage ePackage, CDOPackageImpl cdoPackage)
+ public static void initializeCDOPackage(EPackage ePackage, CDOPackage cdoPackage)
{
cdoPackage.setClientInfo(ePackage);
for (EClass eClass : EMFUtil.getPersistentClasses(ePackage))
{
- CDOClassImpl cdoClass = createCDOClass(eClass, cdoPackage);
- cdoPackage.addClass(cdoClass);
+ CDOClass cdoClass = createCDOClass(eClass, cdoPackage);
+ ((CDOPackageImpl)cdoPackage).addClass(cdoClass);
}
}
- public static CDOPackageImpl getCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
+ public static CDOPackage getCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
{
String packageURI = ePackage.getNsURI();
- CDOPackageImpl cdoPackage = packageManager.lookupPackage(packageURI);
+ CDOPackage cdoPackage = packageManager.lookupPackage(packageURI);
if (cdoPackage == null)
{
cdoPackage = createCDOPackage(ePackage, packageManager);
@@ -119,15 +122,15 @@ public final class ModelUtil
return cdoPackage;
}
- public static CDOClassImpl getCDOClass(EClass eClass, CDOSessionPackageManagerImpl packageManager)
+ public static CDOClass getCDOClass(EClass eClass, CDOSessionPackageManagerImpl packageManager)
{
- CDOPackageImpl cdoPackage = getCDOPackage(eClass.getEPackage(), packageManager);
+ CDOPackage cdoPackage = getCDOPackage(eClass.getEPackage(), packageManager);
return cdoPackage.lookupClass(eClass.getClassifierID());
}
- public static CDOFeatureImpl getCDOFeature(EStructuralFeature eFeature, CDOSessionPackageManagerImpl packageManager)
+ public static CDOFeature getCDOFeature(EStructuralFeature eFeature, CDOSessionPackageManagerImpl packageManager)
{
- CDOClassImpl cdoClass = getCDOClass(eFeature.getEContainingClass(), packageManager);
+ CDOClass cdoClass = getCDOClass(eFeature.getEContainingClass(), packageManager);
return cdoClass.lookupFeature(eFeature.getFeatureID());
}
@@ -135,7 +138,7 @@ public final class ModelUtil
* @see EMFUtil#getPersistentFeatures(org.eclipse.emf.common.util.EList)
* @see http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
*/
- private static CDOPackageImpl createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
+ private static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
{
String packageURI = ePackage.getNsURI();
String name = ePackage.getName();
@@ -148,51 +151,51 @@ public final class ModelUtil
String ecore = EcorePackage.eINSTANCE.getNsURI().equals(packageURI) ? null : EMFUtil.ePackageToString(ePackage);
// String ecore = EMFUtil.ePackageToString(ePackage);
- CDOIDRange idRange = packageManager.getSession().registerEPackage(ePackage);
+ CDOIDMetaRange idRange = packageManager.getSession().registerEPackage(ePackage);
- CDOPackageImpl cdoPackage = new CDOPackageImpl(packageManager, packageURI, name, ecore, dynamic, idRange);
+ CDOPackage cdoPackage = CDOModelUtil.createPackage(packageManager, packageURI, name, ecore, dynamic, idRange);
initializeCDOPackage(ePackage, cdoPackage);
return cdoPackage;
}
- private static CDOClassImpl createCDOClass(EClass eClass, CDOPackageImpl containingPackage)
+ private static CDOClass createCDOClass(EClass eClass, CDOPackage containingPackage)
{
- CDOClassImpl cdoClass = new CDOClassImpl(containingPackage, eClass.getClassifierID(), eClass.getName(), eClass
+ CDOClass cdoClass = CDOModelUtil.createClass(containingPackage, eClass.getClassifierID(), eClass.getName(), eClass
.isAbstract());
cdoClass.setClientInfo(eClass);
for (EClass superType : eClass.getESuperTypes())
{
- CDOClassRefImpl classRef = createClassRef(superType);
- cdoClass.addSuperType(classRef);
+ CDOClassRef classRef = createClassRef(superType);
+ ((CDOClassImpl)cdoClass).addSuperType(classRef);
}
for (EStructuralFeature eFeature : EMFUtil.getPersistentFeatures(eClass.getEStructuralFeatures()))
{
- CDOFeatureImpl cdoFeature = createCDOFeature(eFeature, cdoClass);
- cdoClass.addFeature(cdoFeature);
+ CDOFeature cdoFeature = createCDOFeature(eFeature, cdoClass);
+ ((CDOClassImpl)cdoClass).addFeature(cdoFeature);
}
return cdoClass;
}
- private static CDOFeatureImpl createCDOFeature(EStructuralFeature eFeature, CDOClassImpl containingClass)
+ private static CDOFeature createCDOFeature(EStructuralFeature eFeature, CDOClass containingClass)
{
- CDOFeatureImpl cdoFeature = EMFUtil.isReference(eFeature) ? createCDOReference((EReference)eFeature,
- containingClass) : createCDOAttribute((EAttribute)eFeature, containingClass);
+ CDOFeature cdoFeature = EMFUtil.isReference(eFeature) ? createCDOReference((EReference)eFeature, containingClass)
+ : createCDOAttribute((EAttribute)eFeature, containingClass);
cdoFeature.setClientInfo(eFeature);
return cdoFeature;
}
- private static CDOFeatureImpl createCDOReference(EReference eFeature, CDOClassImpl containingClass)
+ private static CDOFeature createCDOReference(EReference eFeature, CDOClass containingClass)
{
CDOPackageManager packageManager = containingClass.getPackageManager();
int featureID = eFeature.getFeatureID();
String name = eFeature.getName();
- CDOClassRefImpl classRef = createClassRef(eFeature.getEType());
+ CDOClassRef classRef = createClassRef(eFeature.getEType());
boolean many = eFeature.isMany();
boolean containment = EMFUtil.isContainment(eFeature);
- CDOFeatureImpl cdoFeature = new CDOFeatureImpl(containingClass, featureID, name, new CDOClassProxy(classRef,
+ CDOFeature cdoFeature = CDOModelUtil.createReference(containingClass, featureID, name, new CDOClassProxy(classRef,
packageManager), many, containment);
EReference opposite = eFeature.getEOpposite();
@@ -205,16 +208,16 @@ public final class ModelUtil
return cdoFeature;
}
- private static CDOFeatureImpl createCDOAttribute(EAttribute eFeature, CDOClassImpl containingClass)
+ private static CDOFeature createCDOAttribute(EAttribute eFeature, CDOClass containingClass)
{
int featureID = eFeature.getFeatureID();
String name = eFeature.getName();
- CDOTypeImpl type = getCDOType(eFeature);
+ CDOType type = getCDOType(eFeature);
boolean many = EMFUtil.isMany(eFeature);
- return new CDOFeatureImpl(containingClass, featureID, name, type, many);
+ return CDOModelUtil.createAttribute(containingClass, featureID, name, type, many);
}
- public static EPackage getEPackage(CDOPackageImpl cdoPackage, CDOPackageRegistryImpl packageRegistry)
+ public static EPackage getEPackage(CDOPackage cdoPackage, CDOPackageRegistryImpl packageRegistry)
{
EPackage ePackage = (EPackage)cdoPackage.getClientInfo();
if (ePackage == null)
@@ -233,7 +236,7 @@ public final class ModelUtil
return ePackage;
}
- public static EClass getEClass(CDOClassImpl cdoClass, CDOPackageRegistryImpl packageRegistry)
+ public static EClass getEClass(CDOClass cdoClass, CDOPackageRegistryImpl packageRegistry)
{
EClass eClass = (EClass)cdoClass.getClientInfo();
if (eClass == null)
@@ -246,7 +249,7 @@ public final class ModelUtil
return eClass;
}
- public static EStructuralFeature getEFeature(CDOFeatureImpl cdoFeature, CDOPackageRegistryImpl packageRegistry)
+ public static EStructuralFeature getEFeature(CDOFeature cdoFeature, CDOPackageRegistryImpl packageRegistry)
{
EStructuralFeature eFeature = (EStructuralFeature)cdoFeature.getClientInfo();
if (eFeature == null)
@@ -259,7 +262,7 @@ public final class ModelUtil
return eFeature;
}
- public static EPackage createEPackage(CDOPackageImpl cdoPackage)
+ public static EPackage createEPackage(CDOPackage cdoPackage)
{
if (!cdoPackage.isDynamic())
{
@@ -283,7 +286,7 @@ public final class ModelUtil
return EPackage.Registry.INSTANCE.getEPackage(packageURI);
}
- public static EPackageImpl createDynamicEPackage(CDOPackageImpl cdoPackage)
+ public static EPackageImpl createDynamicEPackage(CDOPackage cdoPackage)
{
String ecore = cdoPackage.getEcore();
EPackageImpl ePackage = (EPackageImpl)EMFUtil.ePackageFromString(ecore);
@@ -297,13 +300,13 @@ public final class ModelUtil
EMFUtil.fixEClassifiers(ePackage);
}
- public static CDOClassRefImpl createClassRef(EClassifier classifier)
+ public static CDOClassRef createClassRef(EClassifier classifier)
{
if (classifier instanceof EClass)
{
String packageURI = classifier.getEPackage().getNsURI();
int classifierID = classifier.getClassifierID();
- return new CDOClassRefImpl(packageURI, classifierID);
+ return CDOModelUtil.createClassRef(packageURI, classifierID);
}
return null;
@@ -312,14 +315,14 @@ public final class ModelUtil
public static void addModelInfos(CDOSessionPackageManagerImpl packageManager)
{
// Ecore
- CDOCorePackageImpl corePackage = packageManager.getCDOCorePackage();
+ CDOCorePackage corePackage = packageManager.getCDOCorePackage();
corePackage.setClientInfo(EcorePackage.eINSTANCE);
corePackage.getCDOObjectClass().setClientInfo(EcorePackage.eINSTANCE.getEObject());
// Eresource
- CDOResourcePackageImpl resourcePackage = packageManager.getCDOResourcePackage();
+ CDOResourcePackage resourcePackage = packageManager.getCDOResourcePackage();
resourcePackage.setClientInfo(EresourcePackage.eINSTANCE);
- CDOResourceClassImpl resourceClass = resourcePackage.getCDOResourceClass();
+ CDOResourceClass resourceClass = resourcePackage.getCDOResourceClass();
resourceClass.setClientInfo(EresourcePackage.eINSTANCE.getCDOResource());
resourceClass.getCDOContentsFeature().setClientInfo(EresourcePackage.eINSTANCE.getCDOResource_Contents());
resourceClass.getCDOPathFeature().setClientInfo(EresourcePackage.eINSTANCE.getCDOResource_Path());
@@ -329,14 +332,14 @@ public final class ModelUtil
public static void removeModelInfos(CDOSessionPackageManagerImpl packageManager)
{
// Ecore
- CDOCorePackageImpl corePackage = packageManager.getCDOCorePackage();
+ CDOCorePackage corePackage = packageManager.getCDOCorePackage();
corePackage.setClientInfo(null);
corePackage.getCDOObjectClass().setClientInfo(null);
// Eresource
- CDOResourcePackageImpl resourcePackage = packageManager.getCDOResourcePackage();
+ CDOResourcePackage resourcePackage = packageManager.getCDOResourcePackage();
resourcePackage.setClientInfo(null);
- CDOResourceClassImpl resourceClass = resourcePackage.getCDOResourceClass();
+ CDOResourceClass resourceClass = resourcePackage.getCDOResourceClass();
resourceClass.setClientInfo(null);
resourceClass.getCDOContentsFeature().setClientInfo(null);
resourceClass.getCDOPathFeature().setClientInfo(null);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
index a82e8d6..813fb20 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
@@ -10,13 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.util;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.protocol.id.CDOID;
-import org.eclipse.emf.cdo.protocol.id.CDOIDUtil;
-
-import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
-import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
@@ -24,7 +18,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
@@ -58,18 +51,20 @@ final class ProxyResolverResource implements Resource
*/
public EObject getEObject(String uriFragment)
{
- CDOID id = CDOIDUtil.create(Long.parseLong(uriFragment));
- InternalCDOObject object = view.getObject(id);
- InternalEObject instance = object.cdoInternalInstance();
- if (instance instanceof CDOAdapterImpl)
- {
- if (object.cdoState() == CDOState.PROXY)
- {
- object.cdoInternalPostLoad();
- }
- }
-
- return instance;
+ // TODO Implement me
+ throw new UnsupportedOperationException("Not yet implemented");
+ // CDOID id = CDOIDUtil.create(Long.parseLong(uriFragment));
+ // InternalCDOObject object = view.getObject(id);
+ // InternalEObject instance = object.cdoInternalInstance();
+ // if (instance instanceof CDOAdapterImpl)
+ // {
+ // if (object.cdoState() == CDOState.PROXY)
+ // {
+ // object.cdoInternalPostLoad();
+ // }
+ // }
+ //
+ // return instance;
}
public TreeIterator<EObject> getAllContents()