Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-02-21 02:57:11 -0500
committerEike Stepper2013-02-21 02:57:11 -0500
commitccc143cdbf937af334cb50a69582bb3f8899758e (patch)
tree978fb585501a9a86d4e98e03030bea7b3536eacc
parentcf49b7c79567c2428ecfca6d42867eda592cefca (diff)
downloadcdo-ccc143cdbf937af334cb50a69582bb3f8899758e.tar.gz
cdo-ccc143cdbf937af334cb50a69582bb3f8899758e.tar.xz
cdo-ccc143cdbf937af334cb50a69582bb3f8899758e.zip
[400892] Intern all CDOIDs
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400892
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java213
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OLockArea.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateRawCommitContext.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LockingManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerBrowser.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessorBase.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapTest.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerTest.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java34
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/DefaultCDOMerger.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java4
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java3
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableArrayList.java4
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java361
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap2.java452
81 files changed, 850 insertions, 818 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
index 8e1c6b7398..e305ff194e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
@@ -36,7 +36,6 @@ import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.UUIDGenerator;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -44,6 +43,8 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
/**
* Various static methods that may help with CDO {@link CDOID IDs}.
@@ -59,6 +60,11 @@ public final class CDOIDUtil
{
}
+ public static <V> Map<CDOID, V> createMap()
+ {
+ return new HashMap<CDOID, V>();
+ }
+
/**
* @since 4.0
*/
@@ -519,17 +525,22 @@ public final class CDOIDUtil
*/
public static boolean equals(CDOID id1, CDOID id2)
{
+ if (id1 == id2)
+ {
+ return true;
+ }
+
if (id1 == null)
{
- id1 = CDOID.NULL;
+ return id2 == CDOID.NULL;
}
if (id2 == null)
{
- id2 = CDOID.NULL;
+ return id1 == CDOID.NULL;
}
- return ObjectUtil.equals(id1, id2);
+ return false;
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
index 476f7b4e97..60c15c4154 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
@@ -347,7 +347,7 @@ public final class CDORevisionUtil
{
return null;
}
- else if (parentID.equals(revision.getID()))
+ else if (parentID == revision.getID())
{
// This must be the root resource!
return null;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
index 3283cb40ab..f21899e9e8 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
@@ -280,18 +280,7 @@ public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBr
@Override
public boolean equals(Object obj)
{
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranch)
- {
- CDOBranch that = (CDOBranch)obj;
- return id == that.getID();
- }
-
- return false;
+ return obj == this;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
index 93bc6909e7..52a725d4ed 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java
@@ -14,8 +14,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.net4j.util.ObjectUtil;
-
import java.text.MessageFormat;
/**
@@ -71,7 +69,7 @@ public class CDOBranchPointImpl implements CDOBranchPoint, Comparable<CDOBranchP
if (obj instanceof CDOBranchPoint)
{
CDOBranchPoint that = (CDOBranchPoint)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && timeStamp == that.getTimeStamp();
+ return branch == that.getBranch() && timeStamp == that.getTimeStamp();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
index 1d5050875f..b662c8b635 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java
@@ -13,8 +13,6 @@ package org.eclipse.emf.cdo.internal.common.branch;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.net4j.util.ObjectUtil;
-
import java.text.MessageFormat;
/**
@@ -59,7 +57,7 @@ public class CDOBranchVersionImpl implements CDOBranchVersion
if (obj instanceof CDOBranchVersion)
{
CDOBranchVersion that = (CDOBranchVersion)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && version == that.getVersion();
+ return branch == that.getBranch() && version == that.getVersion();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
index dd0694cead..33b53498dc 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.common.commit;
import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
@@ -24,7 +25,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -115,18 +115,18 @@ public class CDOChangeSetDataImpl implements CDOChangeSetData
public void merge(CDOChangeSetData changeSetData)
{
- Map<CDOID, CDOIDAndVersion> newMap = new HashMap<CDOID, CDOIDAndVersion>();
+ Map<CDOID, CDOIDAndVersion> newMap = CDOIDUtil.createMap();
fillMap(newMap, newObjects);
fillMap(newMap, changeSetData.getNewObjects());
- Map<CDOID, CDORevisionKey> changedMap = new HashMap<CDOID, CDORevisionKey>();
+ Map<CDOID, CDORevisionKey> changedMap = CDOIDUtil.createMap();
fillMap(changedMap, changedObjects);
for (CDORevisionKey key : changeSetData.getChangedObjects())
{
mergeChangedObject(key, newMap, changedMap);
}
- Map<CDOID, CDOIDAndVersion> detachedMap = new HashMap<CDOID, CDOIDAndVersion>();
+ Map<CDOID, CDOIDAndVersion> detachedMap = CDOIDUtil.createMap();
fillMap(detachedMap, detachedObjects);
for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java
deleted file mode 100644
index 9e4cb8d1c7..0000000000
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.common.model;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public final class GenUtil
-{
- private GenUtil()
- {
- }
-
- /**
- * See GenGenBaseImpl.isPrimitiveType
- */
- public static boolean isPrimitiveType(EClassifier eType)
- {
- try
- {
- // J9 2.2 has problems assigning null to a Class variable.
- Object result = eType.getInstanceClass();
- if (result == null)
- {
- return false;
- }
-
- Class<?> instanceClass = (Class<?>)result;
- return instanceClass.isPrimitive();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- /**
- * See GenFeatureImpl.getUpperName
- */
- public static String getFeatureUpperName(String featureName)
- {
- return format(featureName, '_', null, false, true).toUpperCase();
- }
-
- /**
- * See GenFeatureImpl.getGetAccessor
- */
- public static String getFeatureGetterName(String featureName, boolean isBooleanType)
- {
- String capName = StringUtil.cap(featureName);
- // if (isMapEntryFeature())
- // return "getTyped" + capName;
- String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // if (isListType() && !isFeatureMapType() && !isMapType() &&
- // getGenModel().isArrayAccessors())
- // {
- // result += "List";
- // }
-
- // GenClass rootImplementsInterface =
- // getGenModel().getRootImplementsInterfaceGenClass();
- // GenClass context = getContext();
- // if (rootImplementsInterface != null &&
- // !rootImplementsInterface.isEObject())
- // {
- // for (GenOperation genOperation :
- // rootImplementsInterface.getAllGenOperations())
- // {
- // if (genOperation.getName().equals(result) &&
- // genOperation.getGenParameters().isEmpty() &&
- // !genOperation.getType(context).equals(getType(context)))
- // {
- // result = result + "_";
- // break;
- // }
- // }
- // }
-
- return result;
- }
-
- /**
- * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them
- * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed.
- * Leading underscores can be ignored or can cause a leading separator to be prepended.
- */
- public static String format(String name, char separator, String prefix, boolean includePrefix,
- boolean includeLeadingSeparator)
- {
- String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null;
- if (leadingSeparators != null)
- {
- name = name.substring(leadingSeparators.length());
- }
-
- List<String> parsedName = new ArrayList<String>();
- if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length()
- && Character.isUpperCase(name.charAt(prefix.length())))
- {
- name = name.substring(prefix.length());
- if (includePrefix)
- {
- parsedName = parseName(prefix, '_');
- }
- }
-
- if (name.length() != 0)
- {
- parsedName.addAll(parseName(name, '_'));
- }
-
- StringBuilder result = new StringBuilder();
-
- for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();)
- {
- String nameComponent = nameIter.next();
- result.append(nameComponent);
-
- if (nameIter.hasNext() && nameComponent.length() > 1)
- {
- result.append(separator);
- }
- }
-
- if (result.length() == 0 && prefix != null)
- {
- result.append(prefix);
- }
-
- return leadingSeparators != null ? "_" + result.toString() : result.toString(); //$NON-NLS-1$
- }
-
- /**
- * This method breaks sourceName into words delimited by separator and/or mixed-case naming.
- */
- public static List<String> parseName(String sourceName, char separator)
- {
- List<String> result = new ArrayList<String>();
- if (sourceName != null)
- {
- StringBuilder currentWord = new StringBuilder();
- boolean lastIsLower = false;
- for (int index = 0, length = sourceName.length(); index < length; ++index)
- {
- char curChar = sourceName.charAt(index);
- if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator)
- {
- if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0)
- {
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- }
-
- lastIsLower = false;
- }
- else
- {
- if (!lastIsLower)
- {
- int currentWordLength = currentWord.length();
- if (currentWordLength > 1)
- {
- char lastChar = currentWord.charAt(--currentWordLength);
- currentWord.setLength(currentWordLength);
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- currentWord.append(lastChar);
- }
- }
-
- lastIsLower = true;
- }
-
- if (curChar != separator)
- {
- currentWord.append(curChar);
- }
- }
-
- result.add(currentWord.toString());
- }
-
- return result;
- }
-
- private static String getLeadingSeparators(String name, char separator)
- {
- int i = 0;
- for (int len = name.length(); i < len && name.charAt(i) == separator; i++)
- {
- // the for loop's condition finds the separator
- }
-
- return i != 0 ? name.substring(0, i) : null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
index d977da09a2..dc171760dd 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
import java.text.MessageFormat;
@@ -58,7 +57,7 @@ public class CDOIDAndBranchImpl implements CDOIDAndBranch
if (obj instanceof CDOIDAndBranch)
{
CDOIDAndBranch that = (CDOIDAndBranch)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && ObjectUtil.equals(id, that.getID());
+ return branch == that.getBranch() && id == that.getID();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
index 5ac777a1cf..afba9fc2bb 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java
@@ -55,7 +55,7 @@ public class CDOIDAndVersionImpl implements CDOIDAndVersion
if (obj instanceof CDOIDAndVersion)
{
CDOIDAndVersion that = (CDOIDAndVersion)obj;
- return id.equals(that.getID()) && version == that.getVersion();
+ return id == that.getID() && version == that.getVersion();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
index f99201743f..8049d4f8c3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java
@@ -18,8 +18,7 @@ import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.net4j.util.collection.MoveableArrayList;
-
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -28,7 +27,7 @@ import java.util.Collection;
/**
* @author Simon McDuff
*/
-public class CDOListImpl extends MoveableArrayList<Object> implements InternalCDOList
+public class CDOListImpl extends BasicEList<Object> implements InternalCDOList
{
public static final CDOListFactory FACTORY = new CDOListFactory()
{
@@ -38,9 +37,13 @@ public class CDOListImpl extends MoveableArrayList<Object> implements InternalCD
}
};
+ private static final byte FROZEN_FLAG = 1;
+
+ private static final byte USE_EQUALS_FLAG = 2;
+
private static final long serialVersionUID = 1L;
- private transient boolean frozen;
+ private transient byte flags = USE_EQUALS_FLAG;
public CDOListImpl(int initialCapacity, int size)
{
@@ -55,7 +58,10 @@ public class CDOListImpl extends MoveableArrayList<Object> implements InternalCD
{
CDOType type = CDOModelUtil.getType(classifier);
int size = size();
+
InternalCDOList list = new CDOListImpl(size, 0);
+ list.setUseEquals(useEquals());
+
for (int j = 0; j < size; j++)
{
Object value = this.get(j);
@@ -99,12 +105,12 @@ public class CDOListImpl extends MoveableArrayList<Object> implements InternalCD
public void freeze()
{
- frozen = true;
+ flags |= FROZEN_FLAG;
}
private void checkFrozen()
{
- if (frozen)
+ if ((flags & FROZEN_FLAG) != 0)
{
throw new IllegalStateException("Cannot modify a frozen list");
}
@@ -184,4 +190,22 @@ public class CDOListImpl extends MoveableArrayList<Object> implements InternalCD
{
super.set(index, element);
}
+
+ @Override
+ public final boolean useEquals()
+ {
+ return (flags & USE_EQUALS_FLAG) != 0;
+ }
+
+ public final void setUseEquals(boolean useEquals)
+ {
+ if (useEquals)
+ {
+ flags |= USE_EQUALS_FLAG;
+ }
+ else
+ {
+ flags &= ~USE_EQUALS_FLAG;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
index 4151f2c33d..fae2d3aea7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
@@ -71,7 +71,10 @@ public class CDOListWithElementProxiesImpl extends CDOListImpl
{
CDOType type = CDOModelUtil.getType(classifier);
int size = size();
+
InternalCDOList list = new CDOListWithElementProxiesImpl(size, 0, 0);
+ list.setUseEquals(useEquals());
+
for (int j = 0; j < size; j++)
{
Object value = this.get(j);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
index 3904bb9d52..81b91760fa 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java
@@ -19,11 +19,8 @@ import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-import org.eclipse.net4j.util.ObjectUtil;
-
import org.eclipse.emf.ecore.EClass;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -31,7 +28,7 @@ import java.util.Map;
*/
public class CDORevisionCacheBranching extends CDORevisionCacheAuditing
{
- private Map<CDOID, TypeAndRefCounter> typeMap = new HashMap<CDOID, TypeAndRefCounter>();
+ private Map<CDOID, TypeAndRefCounter> typeMap = CDOIDUtil.createMap();
public CDORevisionCacheBranching()
{
@@ -90,7 +87,7 @@ public class CDORevisionCacheBranching extends CDORevisionCacheAuditing
@Override
protected boolean isKeyInBranch(Object key, CDOBranch branch)
{
- return ObjectUtil.equals(((CDOIDAndBranch)key).getBranch(), branch);
+ return ((CDOIDAndBranch)key).getBranch() == branch;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
index 5e140270e4..5e73556dfe 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
@@ -35,7 +36,7 @@ import java.util.Map;
*/
public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
{
- private Map<CDOID, Reference<InternalCDORevision>> revisions = new HashMap<CDOID, Reference<InternalCDORevision>>();
+ private Map<CDOID, Reference<InternalCDORevision>> revisions = CDOIDUtil.createMap();
public CDORevisionCacheNonAuditing()
{
@@ -165,9 +166,10 @@ public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
CheckUtil.checkArg(revision, "revision");
if (!revision.isHistorical())
{
+ Reference<InternalCDORevision> reference = createReference(revision);
synchronized (revisions)
{
- revisions.put(revision.getID(), createReference(revision));
+ revisions.put(revision.getID(), reference);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
index 23cbdf5e16..f28daf3846 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java
@@ -52,7 +52,7 @@ public class CDORevisionKeyImpl extends CDOBranchVersionImpl implements CDORevis
if (obj instanceof CDORevisionKey)
{
CDORevisionKey that = (CDORevisionKey)obj;
- return id.equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion();
+ return id == that.getID() && getVersion() == that.getVersion() && getBranch() == that.getBranch();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
index 3116aa35b5..773b4b6a7b 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
@@ -433,7 +433,17 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
return false;
}
- return origin == dirty || origin.equals(dirty);
+ if (origin == dirty)
+ {
+ return true;
+ }
+
+ if (origin instanceof CDOID)
+ {
+ return false;
+ }
+
+ return origin.equals(dirty);
}
private Object convertEObject(Object value)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java
index 73983c3f59..e41dbd2651 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java
@@ -19,8 +19,6 @@ import org.eclipse.emf.cdo.internal.common.branch.CDOBranchManagerImpl;
import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointRangeImpl;
-import org.eclipse.net4j.util.ObjectUtil;
-
import java.util.ArrayList;
import java.util.List;
@@ -88,7 +86,7 @@ public final class CDOBranchUtil
public static boolean isContainedBy(CDOBranchPoint contained, CDOBranchPoint container)
{
CDOBranch containerBranch = container.getBranch();
- if (ObjectUtil.equals(containerBranch, contained.getBranch()))
+ if (containerBranch == contained.getBranch())
{
return CDOCommonUtil.compareTimeStamps(contained.getTimeStamp(), container.getTimeStamp()) <= 0;
}
@@ -121,7 +119,7 @@ public final class CDOBranchUtil
{
for (CDOBranchPoint pathPoint2 : path2)
{
- if (ObjectUtil.equals(pathPoint1.getBranch(), pathPoint2.getBranch()))
+ if (pathPoint1.getBranch() == pathPoint2.getBranch())
{
if (CDOCommonUtil.compareTimeStamps(pathPoint1.getTimeStamp(), pathPoint2.getTimeStamp()) < 0)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java
index 47ad2c8a74..c9a8204f2f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.spi.common.commit;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetDataProvider;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
@@ -20,7 +21,6 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaProvider;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -121,7 +121,7 @@ public class CDOChangeSetDataRevisionProvider implements CDORevisionProvider, CD
private Map<CDOID, CDOIDAndVersion> cacheRevisions()
{
- Map<CDOID, CDOIDAndVersion> cache = new HashMap<CDOID, CDOIDAndVersion>();
+ Map<CDOID, CDOIDAndVersion> cache = CDOIDUtil.createMap();
for (CDOIDAndVersion key : changeSetData.getNewObjects())
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java
index 0576054f65..6c8de3ae9d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java
@@ -14,8 +14,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
-import org.eclipse.net4j.util.ObjectUtil;
-
import java.text.MessageFormat;
import java.util.LinkedList;
@@ -75,7 +73,7 @@ public class CDOChangeSetSegment implements CDOBranchPoint
CDOBranch startBranch = startPoint.getBranch();
CDOBranch endBranch = endPoint.getBranch();
- while (!ObjectUtil.equals(startBranch, endBranch))
+ while (startBranch != endBranch)
{
CDOBranchPoint base = endBranch.getBase();
result.addFirst(new CDOChangeSetSegment(endBranch, base.getTimeStamp(), endPoint.getTimeStamp()));
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java
index 1a38f42049..b206fedeb3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java
@@ -12,12 +12,12 @@ package org.eclipse.emf.cdo.spi.common.commit;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import java.text.MessageFormat;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -30,7 +30,7 @@ public final class CDORevisionAvailabilityInfo implements CDORevisionProvider
{
private CDOBranchPoint branchPoint;
- private Map<CDOID, CDORevisionKey> availableRevisions = new HashMap<CDOID, CDORevisionKey>();
+ private Map<CDOID, CDORevisionKey> availableRevisions = CDOIDUtil.createMap();
public CDORevisionAvailabilityInfo(CDOBranchPoint branchPoint)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
index d4071cbafb..7b03ab29b8 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
@@ -99,7 +99,6 @@ import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -317,7 +316,7 @@ public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating impl
boolean readOnly = readBoolean();
int nLockStates = readInt();
- Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
+ Map<CDOID, LockGrade> locks = CDOIDUtil.createMap();
for (int i = 0; i < nLockStates; i++)
{
CDOID key = readCDOID();
@@ -477,6 +476,11 @@ public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating impl
}
InternalCDOList list = (InternalCDOList)getListFactory().createList(size, size, referenceChunk);
+ if (feature instanceof EReference)
+ {
+ list.setUseEquals(false);
+ }
+
for (int j = 0; j < referenceChunk; j++)
{
if (isFeatureMap)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
index 8a476cd64a..35da8f46b2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
@@ -24,7 +24,6 @@ import org.eclipse.emf.cdo.internal.common.messages.Messages;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -173,7 +172,7 @@ public abstract class AbstractCDORevision implements InternalCDORevision
*/
public void adjustForCommit(CDOBranch branch, long timeStamp)
{
- if (ObjectUtil.equals(branch, getBranch()))
+ if (branch == getBranch())
{
// Same branch, increase version
setVersion(getVersion() + 1);
@@ -205,7 +204,7 @@ public abstract class AbstractCDORevision implements InternalCDORevision
if (obj instanceof CDORevision)
{
CDORevision that = (CDORevision)obj;
- return getID().equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion();
+ return getID() == that.getID() && getVersion() == that.getVersion() && getBranch() == that.getBranch();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
index da4f902f66..34a1e77bad 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
@@ -13,7 +13,6 @@
*/
package org.eclipse.emf.cdo.spi.common.revision;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
@@ -39,6 +38,7 @@ import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.internal.common.messages.Messages;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.om.trace.PerfTracer;
@@ -357,14 +357,14 @@ public abstract class BaseCDORevision extends AbstractCDORevision
/**
* @since 3.0
*/
- public CDOBranch getBranch()
+ public InternalCDOBranch getBranch()
{
if (branchPoint == null)
{
return null;
}
- return branchPoint.getBranch();
+ return (InternalCDOBranch)branchPoint.getBranch();
}
/**
@@ -684,10 +684,14 @@ public abstract class BaseCDORevision extends AbstractCDORevision
public CDOList getList(EStructuralFeature feature, int size)
{
int featureIndex = getFeatureIndex(feature);
- CDOList list = (CDOList)getValue(featureIndex);
+ InternalCDOList list = (InternalCDOList)getValue(featureIndex);
if (list == null && size != -1)
{
- list = CDOListFactory.DEFAULT.createList(size, 0, 0);
+ list = (InternalCDOList)CDOListFactory.DEFAULT.createList(size, 0, 0);
+ if (feature instanceof EReference)
+ {
+ list.setUseEquals(false);
+ }
synchronized (this)
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
index 1a2adc88fd..1889c99b94 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.ecore.EClass;
@@ -72,7 +73,7 @@ public abstract class DelegatingCDORevision implements InternalCDORevision
return getDelegate().getTimeStamp();
}
- public CDOBranch getBranch()
+ public InternalCDOBranch getBranch()
{
return getDelegate().getBranch();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
index bb8d26d26c..eeb0417d1e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java
@@ -48,4 +48,14 @@ public interface InternalCDOList extends CDOList
* @since 4.0
*/
public void setWithoutFrozenCheck(int i, Object value);
+
+ /**
+ * @since 4.2
+ */
+ public boolean useEquals();
+
+ /**
+ * @since 4.2
+ */
+ public void setUseEquals(boolean useEquals);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
index a5c1e427a8..65057dd251 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -45,6 +46,11 @@ public interface InternalCDORevision extends CDORevision, CDORevisionData, CDORe
/**
* @since 4.2
*/
+ public InternalCDOBranch getBranch();
+
+ /**
+ * @since 4.2
+ */
public InternalCDORevision getRevisionForID(CDOID id);
/**
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java
index 0b04f75263..42706eae59 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/RevisionInfo.java
@@ -19,7 +19,6 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
@@ -368,7 +367,7 @@ public abstract class RevisionInfo
public boolean isDirect()
{
- return ObjectUtil.equals(availableBranchVersion.getBranch(), getRequestedBranchPoint().getBranch());
+ return availableBranchVersion.getBranch() == getRequestedBranchPoint().getBranch();
}
@Override
@@ -389,7 +388,7 @@ public abstract class RevisionInfo
throws IOException
{
InternalCDORevision result = getResult();
- if (result != null && ObjectUtil.equals(result.getBranch(), availableBranchVersion.getBranch()))
+ if (result != null && result.getBranch() == availableBranchVersion.getBranch())
{
// Use available
out.writeBoolean(true);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
index b7f27d59ab..432714d699 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/StubCDORevision.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.cdo.spi.common.revision;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
@@ -20,6 +19,7 @@ import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.ecore.EClass;
@@ -196,7 +196,7 @@ public class StubCDORevision extends AbstractCDORevision
throw new UnsupportedOperationException(getExceptionMessage());
}
- public CDOBranch getBranch()
+ public InternalCDOBranch getBranch()
{
throw new UnsupportedOperationException(getExceptionMessage());
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java
index 2687010565..7ef871626a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.ecore.EClass;
@@ -33,7 +34,7 @@ import org.eclipse.emf.ecore.EClass;
* Instances of this marker revision are not supposed to be exposed outside of a revision {@link CDORevisionManager
* manager}. They are mainly used in the communication between a revision manager and its associated revision
* {@link InternalCDORevisionManager.RevisionLoader loader}.
- *
+ *
* @author Eike Stepper
* @since 3.0
*/
@@ -41,13 +42,13 @@ public abstract class SyntheticCDORevision extends StubCDORevision
{
private CDOID id;
- private CDOBranch branch;
+ private InternalCDOBranch branch;
public SyntheticCDORevision(EClass eClass, CDOID id, CDOBranch branch)
{
super(eClass);
this.id = id;
- this.branch = branch;
+ this.branch = (InternalCDOBranch)branch;
}
@Override
@@ -57,7 +58,7 @@ public abstract class SyntheticCDORevision extends StubCDORevision
}
@Override
- public CDOBranch getBranch()
+ public InternalCDOBranch getBranch()
{
return branch;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
index beedd9f3ba..f75006b2f2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
@@ -45,7 +46,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -611,7 +611,7 @@ public class DurableLockingManager extends Lifecycle
stmt.setString(1, durableLockingID);
resultSet = stmt.executeQuery();
- Map<CDOID, LockGrade> lockMap = new HashMap<CDOID, LockGrade>();
+ Map<CDOID, LockGrade> lockMap = CDOIDUtil.createMap();
while (resultSet.next())
{
CDOID id = idHandler.getCDOID(resultSet, 1);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
index 81d4407e1d..7355da320a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
@@ -15,6 +15,7 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOModelConstants;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
@@ -70,7 +71,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
private Map<EModelElement, CDOID> modelElementToMetaID = new HashMap<EModelElement, CDOID>();
- private Map<CDOID, EModelElement> metaIDToModelElement = new HashMap<CDOID, EModelElement>();
+ private Map<CDOID, EModelElement> metaIDToModelElement = CDOIDUtil.createMap();
public MetaDataManager(IDBStore store)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
index ea4b9abd89..7781f72e2e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
@@ -16,6 +16,7 @@
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -54,7 +55,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -77,7 +77,7 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
/**
* The tags mapped to column names
*/
- private HashMap<CDOID, String> tagMap;
+ private Map<CDOID, String> tagMap;
/**
* Column name Set
@@ -142,8 +142,8 @@ public abstract class AbstractFeatureMapTableMapping extends BasicAbstractListTa
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
- tagMap = new HashMap<CDOID, String>();
- typeMappings = new HashMap<CDOID, ITypeMapping>();
+ tagMap = CDOIDUtil.createMap();
+ typeMappings = CDOIDUtil.createMap();
columnNames = new ArrayList<String>();
// create columns for all DBTypes
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
index a4b90ef863..1dd309920e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
@@ -19,6 +19,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -68,7 +69,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -105,7 +105,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
/**
* The tags mapped to column names
*/
- private HashMap<CDOID, String> tagMap;
+ private Map<CDOID, String> tagMap;
/**
* Column name Set
@@ -177,8 +177,8 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
- tagMap = new HashMap<CDOID, String>();
- typeMappings = new HashMap<CDOID, ITypeMapping>();
+ tagMap = CDOIDUtil.createMap();
+ typeMappings = CDOIDUtil.createMap();
columnNames = new ArrayList<String>();
// create columns for all DBTypes
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
index 28e6b147cd..a458aa8160 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -66,7 +67,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -104,7 +104,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
/**
* The tags mapped to column names
*/
- private HashMap<CDOID, String> tagMap;
+ private Map<CDOID, String> tagMap;
/**
* Column name Set
@@ -175,8 +175,8 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
// add field for FeatureMap tag (MetaID for Feature in CDO registry)
IDBField tagField = table.addField(CDODBSchema.FEATUREMAP_TAG, idType, idLength);
- tagMap = new HashMap<CDOID, String>();
- typeMappings = new HashMap<CDOID, ITypeMapping>();
+ tagMap = CDOIDUtil.createMap();
+ typeMappings = CDOIDUtil.createMap();
columnNames = new ArrayList<String>();
// create columns for all DBTypes
diff --git a/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OLockArea.java b/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OLockArea.java
index 8dbbe3e0c5..b49c3317ae 100644
--- a/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OLockArea.java
+++ b/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OLockArea.java
@@ -74,7 +74,7 @@ public class DB4OLockArea
// Reconstruct the lockMap
//
- Map<CDOID, LockGrade> lockMap = new HashMap<CDOID, LockGrade>();
+ Map<CDOID, LockGrade> lockMap = CDOIDUtil.createMap();
for (DB4OLockEntry entry : primitive.getLockEntries())
{
CDOID cdoid = CDOIDUtil.createLong(entry.getCdoID());
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java
index 9f3bd286d8..85557163a3 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateCommitContext.java
@@ -12,24 +12,25 @@
package org.eclipse.emf.cdo.server.internal.hibernate;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-import java.util.HashMap;
+import java.util.Map;
/**
* A HibernateCommitContext contains the commitcontext as well as support for direct (hashmap) based search for a new or
* changed object using the id.
- *
+ *
* @author Martin Taal
*/
public class HibernateCommitContext
{
private InternalCommitContext commitContext;
- private HashMap<CDOID, InternalCDORevision> dirtyObjects;
+ private Map<CDOID, InternalCDORevision> dirtyObjects;
- private HashMap<CDOID, InternalCDORevision> newObjects;
+ private Map<CDOID, InternalCDORevision> newObjects;
private boolean inDoWrite = false;
@@ -53,13 +54,13 @@ public class HibernateCommitContext
return;
}
- dirtyObjects = new HashMap<CDOID, InternalCDORevision>();
+ dirtyObjects = CDOIDUtil.createMap();
for (InternalCDORevision cdoRevision : commitContext.getDirtyObjects())
{
dirtyObjects.put(cdoRevision.getID(), cdoRevision);
}
- newObjects = new HashMap<CDOID, InternalCDORevision>();
+ newObjects = CDOIDUtil.createMap();
for (InternalCDORevision cdoRevision : commitContext.getNewObjects())
{
newObjects.put(cdoRevision.getID(), cdoRevision);
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateRawCommitContext.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateRawCommitContext.java
index 3a0de33f4c..fb7be679f1 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateRawCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateRawCommitContext.java
@@ -35,18 +35,17 @@ import org.eclipse.emf.ecore.EClass;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Used during raw import.
- *
+ *
* @author Martin Taal
*/
public class HibernateRawCommitContext implements InternalCommitContext
{
- private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+ private Map<CDOID, CDOID> idMappings = CDOIDUtil.createMap();
private List<InternalCDORevision> dirtyObjects = new ArrayList<InternalCDORevision>();
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index f74f54de3e..112e01ac0f 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -95,7 +95,6 @@ import java.sql.Clob;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -878,7 +877,7 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
// versions later on. The versions can be updated when inserting new objects
// this will result in a version difference when the object gets merged
// this repair is done just before the merge
- final Map<CDOID, InternalCDORevision> existingRevisions = new HashMap<CDOID, InternalCDORevision>();
+ final Map<CDOID, InternalCDORevision> existingRevisions = CDOIDUtil.createMap();
for (InternalCDORevision revision : context.getDirtyObjects())
{
final String entityName = HibernateUtil.getInstance().getEntityName(revision.getID());
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
index 89ed82d496..9ca210065b 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/WrappedHibernateList.java
@@ -485,4 +485,13 @@ public class WrappedHibernateList implements InternalCDOList
{
getDelegate().set(i, value);
}
+
+ public boolean useEquals()
+ {
+ return true;
+ }
+
+ public void setUseEquals(boolean useEquals)
+ {
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
index 4577f244dc..6b8c34b9bc 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDReference;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
import org.eclipse.emf.cdo.common.model.EMFUtil;
@@ -47,7 +48,6 @@ import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -204,7 +204,7 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori
Map<CDOID, EClass> detachedObjectTypes = null;
if (auditing || ensuringReferentialIntegrity)
{
- detachedObjectTypes = new HashMap<CDOID, EClass>();
+ detachedObjectTypes = CDOIDUtil.createMap();
}
CDOBranchVersion[] detachedObjectVersions = null;
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java
index f91d59e7f5..0565dac9f6 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java
@@ -275,7 +275,7 @@ public class LoadRevisionsIndication extends CDOServerReadIndication
private void prefetchRevisions(int depth, CDORevision[] revisions, List<CDORevision> additionalRevisions)
{
- Map<CDOID, CDORevision> map = new HashMap<CDOID, CDORevision>();
+ Map<CDOID, CDORevision> map = CDOIDUtil.createMap();
for (CDORevision revision : revisions)
{
map.put(revision.getID(), revision);
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
index 9a8e2a4fb2..a1c3d76674 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RefreshSessionIndication.java
@@ -26,8 +26,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.net4j.util.ObjectUtil;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -174,6 +172,6 @@ public class RefreshSessionIndication extends CDOServerReadIndication
private static boolean hasChanged(CDORevisionKey oldKey, CDORevisionKey newKey)
{
- return !ObjectUtil.equals(oldKey.getBranch(), newKey.getBranch()) || oldKey.getVersion() != newKey.getVersion();
+ return oldKey.getBranch() != newKey.getBranch() || oldKey.getVersion() != newKey.getVersion();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
index fcde4b9393..20502827d1 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
@@ -92,7 +93,6 @@ import java.io.OutputStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -120,7 +120,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
boolean zipped = true; // TODO - might make this configurable...
- private HashMap<CDOID, ObjyObject> newObjyObjectsMap = new HashMap<CDOID, ObjyObject>();
+ private Map<CDOID, ObjyObject> newObjyObjectsMap = CDOIDUtil.createMap();
private long readRevisionTime = 0;
@@ -476,7 +476,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
/**
* Called for each revision delta.
- *
+ *
* @param delta
* @param created
* @param branch
@@ -583,7 +583,7 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
/**
* Called for each revision delta.
- *
+ *
* @param delta
* @param created
* @param branch
@@ -1344,8 +1344,8 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
}
/**
- *
- */
+ *
+ */
public InternalCDORevision readRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int listChunk,
CDORevisionCacheAdder cache)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
index d0021718d4..721225080e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
@@ -27,7 +28,6 @@ import org.eclipse.emf.ecore.EClass;
import com.objy.db.app.ooId;
-import java.util.HashMap;
import java.util.Map;
/***
@@ -64,13 +64,13 @@ public class ObjyPlacementManagerLocal
this.objySession = objySession;
this.commitContext = commitContext;
// first put them in a map for easy lookup and processing....
- newObjectsMap = new HashMap<CDOID, InternalCDORevision>();
+ newObjectsMap = CDOIDUtil.createMap();
for (InternalCDORevision revision : commitContext.getNewObjects())
{
newObjectsMap.put(revision.getID(), revision);
}
- idMapper = new HashMap<CDOID, CDOID>();
+ idMapper = CDOIDUtil.createMap();
this.newObjyObjectsMap = newObjyObjectsMap;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
index 366d81e7fd..6295db2775 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
@@ -4,13 +4,14 @@
* 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:
* Ibrahim Sallam - initial API and implementation
*/
package org.eclipse.emf.cdo.server.internal.objectivity.schema;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
@@ -19,7 +20,6 @@ import com.objy.db.app.ooObj;
import com.objy.db.util.ooTreeSetX;
import java.text.MessageFormat;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
@@ -130,7 +130,7 @@ public class ObjyLockArea extends ooObj
{
fetch();
- Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
+ Map<CDOID, LockGrade> locks = CDOIDUtil.createMap();
@SuppressWarnings("rawtypes")
Iterator itr = readLockSet.iterator();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LockingManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LockingManager.java
index 7af45a3607..b8dcdc30eb 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LockingManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/LockingManager.java
@@ -155,7 +155,7 @@ public class LockingManager extends RWOLockManager<Object, IView> implements Int
public synchronized Map<CDOID, LockGrade> getLocks(final IView view)
{
- final Map<CDOID, LockGrade> result = new HashMap<CDOID, LockGrade>();
+ final Map<CDOID, LockGrade> result = CDOIDUtil.createMap();
for (LockState<Object, IView> lockState : getObjectToLocksMap().values())
{
@@ -271,6 +271,7 @@ public class LockingManager extends RWOLockManager<Object, IView> implements Int
{
child = childID;
}
+
contents.add(child);
}
}
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 f4b3dfbc71..ec2d3615fb 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
@@ -1354,14 +1354,7 @@ public class Repository extends Container<Object> implements InternalRepository
private InternalCDORevision getRevisionFromBranch(CDOID id, CDOBranchPoint branchPoint)
{
- InternalCDORevision revision = revisionManager.getRevision(id, branchPoint, CDORevision.UNCHUNKED,
- CDORevision.DEPTH_NONE, true);
- // if (revision == null || !ObjectUtil.equals(revision.getBranch(), branchPoint.getBranch()))
- // {
- // return null;
- // }
-
- return revision;
+ return revisionManager.getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true);
}
public void queryLobs(List<byte[]> ids)
@@ -1441,6 +1434,7 @@ public class Repository extends Container<Object> implements InternalRepository
lockables.add(id);
}
}
+
return lockables;
}
@@ -1455,6 +1449,7 @@ public class Repository extends Container<Object> implements InternalRepository
List<CDORevisionKey> loadedRevs, boolean recursive, long timeout)
{
List<LockState<Object, IView>> newLockStates = null;
+
try
{
newLockStates = getLockingManager().lock2(true, type, view, lockables, recursive, timeout);
@@ -1530,7 +1525,6 @@ public class Repository extends Container<Object> implements InternalRepository
}
// Convert the list to an array, to satisfy the API later
- //
CDORevisionKey[] staleRevisionsArray = new CDORevisionKey[staleRevisions.size()];
staleRevisions.toArray(staleRevisionsArray);
@@ -1679,11 +1673,6 @@ public class Repository extends Container<Object> implements InternalRepository
if (initialPackages != null)
{
- // if (type != Type.MASTER)
- // {
- // throw new IllegalStateException("Only master repositories can have initial packages");
- // }
-
for (EPackage initialPackage : initialPackages)
{
if (!packageRegistry.containsKey(initialPackage.getNsURI()))
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
index 0dc84e5bcc..4f13590180 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
@@ -55,8 +56,9 @@ import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.LifecycleException;
import org.eclipse.net4j.util.lifecycle.LifecycleState;
+import org.eclipse.net4j.util.ref.KeyedReference;
import org.eclipse.net4j.util.ref.ReferenceType;
-import org.eclipse.net4j.util.ref.ReferenceValueMap;
+import org.eclipse.net4j.util.ref.ReferenceValueMap2;
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.emf.common.notify.Adapter;
@@ -72,6 +74,7 @@ import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
+import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.PlatformObject;
@@ -102,8 +105,12 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
this.session = new ServerCDOSession(session);
this.revisionProvider = revisionProvider;
- setViewSet(SessionUtil.prepareResourceSet(new ResourceSetImpl()));
- setObjects(new ReferenceValueMap.Weak<CDOID, InternalCDOObject>());
+ InternalCDOViewSet resourceSet = SessionUtil.prepareResourceSet(new ResourceSetImpl());
+ setViewSet(resourceSet);
+
+ Map<CDOID, KeyedReference<CDOID, InternalCDOObject>> map = CDOIDUtil.createMap();
+ setObjects(new ReferenceValueMap2.Weak<CDOID, InternalCDOObject>(map));
+
activate();
}
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 45c32ad665..42eaeb98b1 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
@@ -516,7 +516,7 @@ public class Session extends Container<IView> implements InternalSession
if (view.options().isLockNotificationEnabled())
{
CDOBranch affectedBranch = lockChangeInfo.getBranch();
- if (view.getBranch().equals(affectedBranch) || affectedBranch == null)
+ if (view.getBranch() == affectedBranch || affectedBranch == null)
{
protocol.sendLockNotification(lockChangeInfo);
break;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index 755285b5dc..b2c16c42c3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -72,7 +72,6 @@ import org.eclipse.emf.cdo.spi.server.InternalSession;
import org.eclipse.emf.cdo.spi.server.InternalTransaction;
import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.IndexedList;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
@@ -99,8 +98,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
/**
* @author Simon McDuff
@@ -158,7 +155,7 @@ public class TransactionCommitContext implements InternalCommitContext
private List<CDOID> lockedTargets;
- private ConcurrentMap<CDOID, CDOID> idMappings = new ConcurrentHashMap<CDOID, CDOID>();
+ private Map<CDOID, CDOID> idMappings = CDOIDUtil.createMap();
private CDOReferenceAdjuster idMapper = new CDOIDMapper(idMappings);
@@ -321,7 +318,7 @@ public class TransactionCommitContext implements InternalCommitContext
private Map<CDOID, InternalCDORevision> cacheRevisions()
{
- Map<CDOID, InternalCDORevision> cache = new HashMap<CDOID, InternalCDORevision>();
+ Map<CDOID, InternalCDORevision> cache = CDOIDUtil.createMap();
if (newObjects != null)
{
for (int i = 0; i < newObjects.length; i++)
@@ -363,10 +360,10 @@ public class TransactionCommitContext implements InternalCommitContext
throw new IllegalStateException("newID=" + newID); //$NON-NLS-1$
}
- CDOID previousMapping = idMappings.putIfAbsent(oldID, newID);
- if (previousMapping != null)
+ CDOID previousMapping = idMappings.put(oldID, newID);
+ if (previousMapping != null && previousMapping != newID)
{
- throw new IllegalStateException("previousMapping != null"); //$NON-NLS-1$
+ throw new IllegalStateException("previousMapping != null && previousMapping != newID"); //$NON-NLS-1$
}
}
@@ -1093,7 +1090,7 @@ public class TransactionCommitContext implements InternalCommitContext
oldRevision = revisionManager.getRevisionByVersion(id, delta, CDORevision.UNCHUNKED, true);
if (oldRevision != null)
{
- if (ObjectUtil.equals(oldRevision.getBranch(), branch) && oldRevision.isHistorical())
+ if (oldRevision.getBranch() == branch && oldRevision.isHistorical())
{
oldRevision = null;
}
@@ -1493,7 +1490,12 @@ public class TransactionCommitContext implements InternalCommitContext
if (obj instanceof DeltaLockWrapper)
{
DeltaLockWrapper wrapper = (DeltaLockWrapper)obj;
- return key.equals(wrapper.getKey());
+ obj = wrapper.getKey();
+ }
+
+ if (key instanceof CDOID)
+ {
+ return key == obj;
}
return key.equals(obj);
@@ -1516,7 +1518,6 @@ public class TransactionCommitContext implements InternalCommitContext
*/
private static final class ForID extends DeltaLockWrapper
{
-
private static final long serialVersionUID = 1L;
public ForID(CDOID key, InternalCDORevisionDelta delta)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
index a738b2eeae..29c506595c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
@@ -238,7 +238,7 @@ public class XRefsQueryHandler implements IQueryHandler
IStore store = repository.getStore();
CDOPackageRegistry packageRegistry = repository.getPackageRegistry();
- targetObjects = new HashMap<CDOID, EClass>();
+ targetObjects = CDOIDUtil.createMap();
StringTokenizer tokenizer = new StringTokenizer(info.getQueryString(), "|");
while (tokenizer.hasMoreTokens())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
index 8e3f997998..63ad367e6d 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
@@ -114,7 +114,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
private List<CommitInfo> commitInfos = new ArrayList<CommitInfo>();
- private Map<CDOID, EClass> objectTypes = new HashMap<CDOID, EClass>();
+ private Map<CDOID, EClass> objectTypes = CDOIDUtil.createMap();
private Map<String, LockArea> lockAreas = new HashMap<String, LockArea>();
@@ -384,7 +384,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
return;
}
- if (!ObjectUtil.equals(revision.getBranch(), segment.getBranch()))
+ if (revision.getBranch() != segment.getBranch())
{
return;
}
@@ -422,7 +422,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
return true;
}
- if (branch != null && !ObjectUtil.equals(revision.getBranch(), branch))
+ if (branch != null && revision.getBranch() != branch)
{
return true;
}
@@ -534,7 +534,13 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
public synchronized void addRevision(InternalCDORevision revision, boolean raw)
{
- Object listKey = getListKey(revision.getID(), revision.getBranch());
+ InternalCDOBranch branch = revision.getBranch();
+ if (branch.getBranchManager().getBranchLoader() != getRepository())
+ {
+ throw new IllegalArgumentException("Branch does not belong to this repository: " + branch);
+ }
+
+ Object listKey = getListKey(revision.getID(), branch);
List<InternalCDORevision> list = revisions.get(listKey);
if (list == null)
{
@@ -647,7 +653,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
for (Entry<Object, List<InternalCDORevision>> entry : revisions.entrySet())
{
CDOBranch branch = getBranch(entry.getKey());
- if (!ObjectUtil.equals(branch, context.getBranch()))
+ if (branch != context.getBranch())
{
continue;
}
@@ -704,7 +710,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
for (Entry<Object, List<InternalCDORevision>> entry : revisions.entrySet())
{
CDOBranch branch = getBranch(entry.getKey());
- if (!ObjectUtil.equals(branch, context.getBranch()))
+ if (branch != context.getBranch())
{
continue;
}
@@ -764,7 +770,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
{
for (CDOID id : targetIDs)
{
- if (id.equals(targetID))
+ if (id == targetID)
{
if (!context.addXRef(targetID, sourceID, sourceReference, index))
{
@@ -1355,7 +1361,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
if (obj instanceof ListKey)
{
ListKey that = (ListKey)obj;
- return ObjectUtil.equals(id, that.getID()) && ObjectUtil.equals(branch, that.getBranch());
+ return id == that.getID() && branch == that.getBranch();
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerBrowser.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerBrowser.java
index 0cd9ec66de..76de357421 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerBrowser.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerBrowser.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.revision.CDOAllRevisionsProvider;
@@ -946,7 +947,7 @@ public class CDOServerBrowser extends Worker
private Map<CDOID, List<CDORevision>> getAllIDs(Map<CDOBranch, List<CDORevision>> allRevisions)
{
- Map<CDOID, List<CDORevision>> ids = new HashMap<CDOID, List<CDORevision>>();
+ Map<CDOID, List<CDORevision>> ids = CDOIDUtil.createMap();
for (List<CDORevision> list : allRevisions.values())
{
for (CDORevision revision : list)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessorBase.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessorBase.java
index a10bb140d9..41a926b00a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessorBase.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessorBase.java
@@ -52,7 +52,6 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -395,7 +394,7 @@ public abstract class StoreAccessorBase extends Lifecycle implements IStoreAcces
*/
private static final class DetachCounter extends CDOFeatureDeltaVisitorImpl
{
- private Map<CDOID, AtomicInteger> counters = new HashMap<CDOID, AtomicInteger>();
+ private Map<CDOID, AtomicInteger> counters = CDOIDUtil.createMap();
private InternalCDORevision oldRevision;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
index 66d0972e78..2e63f5f738 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
import org.eclipse.emf.cdo.common.revision.CDOAllRevisionsProvider;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -30,6 +31,7 @@ import org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper;
import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.tests.AbstractOMTest;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.spi.cdo.FSMUtil;
@@ -66,6 +68,27 @@ public abstract class AbstractCDOTest extends ConfigTest
super.doTearDown();
}
+ public static void assertEquals(Object expected, Object actual)
+ {
+ if (expected instanceof CDOID || expected instanceof CDOBranch)
+ {
+ if (expected != actual)
+ {
+ failNotEquals(null, expected, actual);
+ }
+
+ return;
+ }
+
+ // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
+ if (actual != null && actual.equals(expected))
+ {
+ return;
+ }
+
+ AbstractOMTest.assertEquals(expected, actual);
+ }
+
protected static void assertTransient(EObject eObject)
{
CDOObject object = CDOUtil.getCDOObject(eObject);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
index 2bd224feb7..c28e9fad3e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BranchingTest.java
@@ -294,8 +294,11 @@ public class BranchingTest extends AbstractCDOTest
private void assertAncestor(CDOBranchPoint expected, CDOBranchPoint point1, CDOBranchPoint point2)
{
- assertEquals(expected, CDOBranchUtil.getAncestor(point1, point2));
- assertEquals(expected, CDOBranchUtil.getAncestor(point2, point1));
+ CDOBranchPoint ancestor1 = CDOBranchUtil.getAncestor(point1, point2);
+ assertEquals(expected, ancestor1);
+
+ CDOBranchPoint ancestor2 = CDOBranchUtil.getAncestor(point2, point1);
+ assertEquals(expected, ancestor2);
}
public void testContainment() throws Exception
@@ -1058,4 +1061,19 @@ public class BranchingTest extends AbstractCDOTest
System.out.println();
System.out.println();
}
+
+ public static void assertEquals(Object expected, Object actual)
+ {
+ if (expected instanceof CDOBranch && actual instanceof CDOBranch)
+ {
+ if (((CDOBranch)expected).getID() != ((CDOBranch)actual).getID())
+ {
+ failNotEquals(null, expected, actual);
+ }
+
+ return;
+ }
+
+ AbstractCDOTest.assertEquals(expected, actual);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
index d80e79fc8c..12045edede 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitInfoTest.java
@@ -172,7 +172,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -195,7 +195,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Skips("MongoDB")
@@ -298,7 +298,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -321,7 +321,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(1, infos.size());
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Skips("MongoDB")
@@ -537,7 +537,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -558,7 +558,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@CleanRepositoriesBefore
@@ -647,7 +647,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(2, infos.size()); // Initial root resource commit + 1
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
@@ -667,7 +667,7 @@ public class CommitInfoTest extends AbstractCDOTest
List<CDOCommitInfo> infos = handler.getInfos();
assertEquals(1, infos.size());
- assertEquals(commitInfo.getBranch(), infos.get(0).getBranch());
+ assertEquals(commitInfo.getBranch().getID(), infos.get(0).getBranch().getID());
}
@CleanRepositoriesBefore
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
index e486dad120..9f810d7016 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/IndexReconstructionTest.java
@@ -520,7 +520,7 @@ public class IndexReconstructionTest extends AbstractCDOTest
if (obj instanceof ReconstructedIndex)
{
ReconstructedIndex that = (ReconstructedIndex)obj;
- return id.equals(that.id) && feature.equals(that.feature) && index == that.index;
+ return id == that.id && index == that.index && feature.equals(that.feature);
}
return false;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
index bafb10dad0..0cc850c892 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
@@ -13,7 +13,6 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
@@ -354,8 +353,9 @@ public class LockingNotificationsTest extends AbstractLockingTest
{
if (lockedObject instanceof CDOIDAndBranch)
{
- CDOIDAndBranch idAndBranch = CDOIDUtil.createIDAndBranch(obj.cdoID(), obj.cdoView().getBranch());
- assertEquals(idAndBranch, lockedObject);
+ CDOIDAndBranch idAndBranch = (CDOIDAndBranch)lockedObject;
+ assertEquals(obj.cdoID(), idAndBranch.getID());
+ assertEquals(obj.cdoView().getBranch().getID(), idAndBranch.getBranch().getID());
}
else if (lockedObject instanceof CDOID)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapTest.java
index 4b64dfcc85..70b511863a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MapTest.java
@@ -64,20 +64,20 @@ public class MapTest extends AbstractCDOTest
{
PropertiesMapEntryValue value1 = getModel6Factory().createPropertiesMapEntryValue();
value1.setLabel("value1");
-
+
PropertiesMapEntryValue value2 = getModel6Factory().createPropertiesMapEntryValue();
value2.setLabel("value2");
-
+
PropertiesMap propertiesMap = getModel6Factory().createPropertiesMap();
propertiesMap.setLabel("TransientMap");
propertiesMap.getTransientMap().put("key1", value1);
propertiesMap.getTransientMap().put("key2", value2);
-
+
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
resource.getContents().add(propertiesMap);
-
+
transaction.commit();
assertEquals(false, EMFUtil.isPersistent(getModel6Package().getPropertiesMap_TransientMap()));
}
@@ -422,7 +422,7 @@ public class MapTest extends AbstractCDOTest
CDOID valueID = CDOUtil.getCDOObject((EObject)key).cdoID();
CDOID valueMapID = CDOUtil.getCDOObject((EObject)keyMap).cdoID();
- if (valueID.equals(valueMapID))
+ if (valueID == valueMapID)
{
foundObjectWithSameID = true;
}
@@ -446,7 +446,7 @@ public class MapTest extends AbstractCDOTest
CDOID valueID = CDOUtil.getCDOObject((EObject)map.get(key)).cdoID();
CDOID valueMapID = CDOUtil.getCDOObject((EObject)valueMap).cdoID();
- if (valueID.equals(valueMapID))
+ if (valueID == valueMapID)
{
foundObjectWithSameID = true;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
index c35295d3c4..c9db7977be 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerClientSideTest.java
@@ -10,7 +10,9 @@
*/
package org.eclipse.emf.cdo.tests;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
@@ -39,4 +41,11 @@ public class RevisionManagerClientSideTest extends RevisionManagerTest
BranchingTest.dump("ServerCache", repository.getRevisionManager().getCache().getAllRevisions());
super.dumpCache(branchPoint);
}
+
+ @Override
+ protected InternalCDORevision getRevision(CDOBranch branch, long timeStamp)
+ {
+ branch = session.getBranchManager().getBranch(branch.getID()); // Make sure that the client-side branch is used!
+ return super.getRevision(branch, timeStamp);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerTest.java
index 055b0f755f..92fe554cdf 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionManagerTest.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.internal.common.revision.AbstractCDORevisionCache;
import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
@@ -55,7 +54,7 @@ public class RevisionManagerTest extends AbstractCDOTest
private MEMStore store;
- private InternalCDOSession session;
+ protected InternalCDOSession session;
private InternalSession serverSession;
@@ -116,7 +115,7 @@ public class RevisionManagerTest extends AbstractCDOTest
serverSession = repository.getSessionManager().getSession(session.getSessionID());
StoreThreadLocal.setSession(serverSession);
- branchManager = session.getBranchManager();
+ branchManager = repository.getBranchManager();
branchID = 0;
branch0 = branchManager.getMainBranch();
@@ -234,7 +233,7 @@ public class RevisionManagerTest extends AbstractCDOTest
return timeStamp / 2 + revised / 2;
}
- private InternalCDORevision getRevision(CDOBranch branch, long timeStamp)
+ protected InternalCDORevision getRevision(CDOBranch branch, long timeStamp)
{
CDOBranchPoint branchPoint = branch.getPoint(timeStamp);
dumpCache(branchPoint);
@@ -256,15 +255,15 @@ public class RevisionManagerTest extends AbstractCDOTest
private static void assertRevision(InternalCDORevision expected, InternalCDORevision actual)
{
- if (expected == null)
+ if (expected == null || actual == null)
{
assertEquals(null, actual);
}
else
{
- assertEquals( //
- CDORevisionUtil.copyRevisionKey(expected), //
- CDORevisionUtil.copyRevisionKey(actual));
+ assertEquals(expected.getID(), actual.getID());
+ assertEquals(expected.getBranch().getID(), actual.getBranch().getID());
+ assertEquals(expected.getVersion(), actual.getVersion());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
index ffc6fc9f11..7de8ea236a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_296561_Test.java
@@ -25,13 +25,13 @@ import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import java.lang.reflect.Field;
-import java.util.concurrent.ConcurrentMap;
+import java.util.Map;
/**
* Problems with savepoints and detached elements on complete rollback
* <p>
* See https://bugs.eclipse.org/296561
- *
+ *
* @author Victor Roldan Betancort
*/
public class Bugzilla_296561_Test extends AbstractCDOTest
@@ -83,7 +83,7 @@ public class Bugzilla_296561_Test extends AbstractCDOTest
Object value = ReflectUtil.getValue(field, transaction);
@SuppressWarnings("unchecked")
- ConcurrentMap<CDOID, InternalCDOObject> objects = (ConcurrentMap<CDOID, InternalCDOObject>)value;
+ Map<CDOID, InternalCDOObject> objects = (Map<CDOID, InternalCDOObject>)value;
assertEquals(false, objects.containsKey(id));
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
index df01870bc7..4e653f07ab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_319836_Test.java
@@ -36,7 +36,7 @@ import java.text.MessageFormat;
* Moving nodes in a tree structure (simulate a {@link DragAndDropCommand}) may result in an inconsistent tree.
* <p>
* See bug 319836
- *
+ *
* @author Cyril Jaquier
*/
public class Bugzilla_319836_Test extends AbstractCDOTest
@@ -89,7 +89,7 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
// ___`- n2
// Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new Map<CDOID, CDOObject>()
// {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
if (SHOW_BUG)
{
@@ -180,7 +180,7 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
// `- n3
// Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new Map<CDOID, CDOObject>()
// {...}.put(CDOID, CDOObject) and see how the previous REMOVE is eaten.
if (SHOW_BUG)
{
@@ -269,7 +269,7 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
// ______`- n4
// Something bad will happen during the execution of the next line. Set a breakpoint in
- // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new HashMap<CDOID,CDOObject>()
+ // org.eclipse.emf.internal.cdo.transaction.CDOSavepointImpl.detachedObjects.new Map<CDOID, CDOObject>()
// {...}.put(CDOID, CDOObject) and see how the previous ADD is eaten.
if (SHOW_BUG)
{
@@ -337,7 +337,7 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
/**
* Prints the {@link InternalCDORevisionDelta}s in a more friendly way than {@link #toString()}.
- *
+ *
* @param spacer
* the spacer used to increment the output
* @return {@link String}
@@ -365,7 +365,7 @@ public class Bugzilla_319836_Test extends AbstractCDOTest
/**
* Pretty prints {@link CDOFeatureDelta}, recursing into {@link CDOListFeatureDelta}.
- *
+ *
* @param sb
* {@link StringBuilder} where the output is written
* @param delta
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
index b73ae353ef..5dc4ef53a5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_335772_Test.java
@@ -168,7 +168,7 @@ public class Bugzilla_335772_Test extends AbstractCDOTest
for (Map.Entry<Product1, SalesOrder> entry : orderByProduct.entrySet())
{
- if (CDOUtil.getCDOObject(entry.getKey()).cdoID().equals(product1CDOID))
+ if (CDOUtil.getCDOObject(entry.getKey()).cdoID() == product1CDOID)
{
return entry.getValue().getId();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
index 1d84f3e1dd..17c311ec5f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevision.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.internal.common.branch.CDOBranchImpl;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.StubCDORevision;
@@ -67,9 +68,9 @@ public final class TestRevision extends StubCDORevision
}
@Override
- public CDOBranch getBranch()
+ public InternalCDOBranch getBranch()
{
- return branchPoint.getBranch();
+ return (InternalCDOBranch)branchPoint.getBranch();
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
index 8c4b34780e..a39247c3ec 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
@@ -204,6 +204,7 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
public boolean handleRevision(CDORevision revision)
{
InternalCDORevision rev = (InternalCDORevision)revision;
+ adjustRevisionBranch(rev);
accessor.rawStore(rev, monitor);
long commitTime = revision.getTimeStamp();
@@ -617,6 +618,7 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
accessor.rawDelete(id, localRevision.getVersion(), localBranch, eClass, new Monitor());
localRevision.setVersion(remoteRevision.getVersion());
+ adjustRevisionBranch(localRevision);
accessor.rawStore(localRevision, new Monitor());
}
}
@@ -630,6 +632,17 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
}
}
+ private void adjustRevisionBranch(InternalCDORevision revision)
+ {
+ InternalCDOBranchManager branchManager = localRepository.getBranchManager();
+ InternalCDOBranch branch = revision.getBranch();
+ if (branch.getBranchManager() != branchManager)
+ {
+ branch = branchManager.getBranch(branch.getID());
+ revision.setBranchPoint(branch.getPoint(revision.getTimeStamp()));
+ }
+ }
+
/**
* @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 2ab76cb779..3141e9ebff 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOObjectHistory;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOType;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
@@ -61,7 +62,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -84,7 +84,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
@Override
protected Map<CDOID, CDOLegacyWrapper> initialValue()
{
- return new HashMap<CDOID, CDOLegacyWrapper>();
+ return CDOIDUtil.createMap();
}
};
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
index 0350867dda..cc6cb35e28 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java
@@ -262,7 +262,7 @@ public class CDONotificationBuilder extends CDOFeatureDeltaVisitorImpl
{
for (CDOObject object : detachedObjects)
{
- if (id.equals(object.cdoID()))
+ if (id == object.cdoID())
{
return object;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index acc6d3d7ff..efc2c99cf4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
@@ -87,7 +88,6 @@ import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl;
import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl;
import org.eclipse.emf.internal.cdo.util.DefaultLocksChangedEvent;
-import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.concurrent.IRWLockManager;
@@ -203,7 +203,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
* A map to track for every object that was committed since this session's last refresh, onto what CDOBranchPoint it
* was committed. (Used only for sticky transactions, see bug 290032 - Sticky views.)
*/
- private Map<CDOID, CDOBranchPoint> committedSinceLastRefresh = new HashMap<CDOID, CDOBranchPoint>();
+ private Map<CDOID, CDOBranchPoint> committedSinceLastRefresh = CDOIDUtil.createMap();
static
{
@@ -673,7 +673,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
boolean needNewMap = revisions == null;
if (needNewMap)
{
- revisions = new HashMap<CDOID, InternalCDORevision>();
+ revisions = CDOIDUtil.createMap();
}
view.collectViewedRevisions(revisions);
@@ -945,7 +945,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
revisionManager.addRevision(newRevision);
if (oldRevisions == null)
{
- oldRevisions = new HashMap<CDOID, InternalCDORevision>();
+ oldRevisions = CDOIDUtil.createMap();
}
oldRevisions.put(id, oldRevision);
@@ -954,7 +954,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
else
{
// ... otherwise try to revise old revision if it is in the same branch
- if (ObjectUtil.equals(key.getBranch(), newBranch))
+ if (key.getBranch() == newBranch)
{
revisionManager.reviseVersion(id, key, timeStamp);
}
@@ -1349,7 +1349,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
CDORevision revision = (CDORevision)key;
revisionManager.addRevision(revision);
- if (!ObjectUtil.equals(revision.getBranch(), branch))
+ if (revision.getBranch() != branch)
{
CDOID id = revision.getID();
CDORevision firstRevision = revisionManager.getCache().getRevisionByVersion(id,
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
index 885a1a31e1..0bd734e06b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
@@ -51,12 +51,12 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
{
private final InternalCDOTransaction transaction;
- private Map<CDOID, CDORevision> baseNewObjects = new HashMap<CDOID, CDORevision>();
+ private Map<CDOID, CDORevision> baseNewObjects = CDOIDUtil.createMap();
- private Map<CDOID, CDOObject> newObjects = new HashMap<CDOID, CDOObject>();
+ private Map<CDOID, CDOObject> newObjects = CDOIDUtil.createMap();
// Bug 283985 (Re-attachment)
- private Map<CDOID, CDOObject> reattachedObjects = new HashMap<CDOID, CDOObject>();
+ private Map<CDOID, CDOObject> reattachedObjects = CDOIDUtil.createMap();
private Map<CDOID, CDOObject> detachedObjects = new HashMap<CDOID, CDOObject>()
{
@@ -77,7 +77,7 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
}
};
- private Map<CDOID, CDOObject> dirtyObjects = new HashMap<CDOID, CDOObject>();
+ private Map<CDOID, CDOObject> dirtyObjects = CDOIDUtil.createMap();
private Map<CDOID, CDORevisionDelta> revisionDeltas = new HashMap<CDOID, CDORevisionDelta>()
{
@@ -373,7 +373,7 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
return Collections.unmodifiableMap(getNewObjects());
}
- Map<CDOID, CDOObject> newObjects = new HashMap<CDOID, CDOObject>();
+ Map<CDOID, CDOObject> newObjects = CDOIDUtil.createMap();
for (InternalCDOSavepoint savepoint = getFirstSavePoint(); savepoint != null; savepoint = savepoint
.getNextSavepoint())
{
@@ -423,7 +423,7 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
}
// We need to combined the result for all delta in different Savepoint
- Map<CDOID, CDORevisionDelta> allRevisionDeltas = new HashMap<CDOID, CDORevisionDelta>();
+ Map<CDOID, CDORevisionDelta> allRevisionDeltas = CDOIDUtil.createMap();
for (InternalCDOSavepoint savepoint = getFirstSavePoint(); savepoint != null; savepoint = savepoint
.getNextSavepoint())
{
@@ -470,7 +470,7 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
return Collections.unmodifiableMap(getDetachedObjects());
}
- Map<CDOID, CDOObject> detachedObjects = new HashMap<CDOID, CDOObject>();
+ Map<CDOID, CDOObject> detachedObjects = CDOIDUtil.createMap();
for (InternalCDOSavepoint savepoint = getFirstSavePoint(); savepoint != null; savepoint = savepoint
.getNextSavepoint())
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index 131bb9c909..d69cba7b33 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -622,7 +622,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, boolean keepVersions,
List<CDORevisionKey> result) throws ChangeSetOutdatedException
{
- Map<CDOID, InternalCDORevision> oldRevisions = new HashMap<CDOID, InternalCDORevision>();
+ Map<CDOID, InternalCDORevision> oldRevisions = CDOIDUtil.createMap();
Map<CDOID, CDOObject> detachedObjects = lastSavepoint.getDetachedObjects();
Map<CDOID, CDOObject> dirtyObjects = lastSavepoint.getDirtyObjects();
@@ -2032,7 +2032,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
createIDForNewObject(null);
}
- Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+ Map<CDOID, CDOID> idMappings = CDOIDUtil.createMap();
while (in.readBoolean())
{
if (reconstructSavepoints)
@@ -2705,7 +2705,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return map;
}
- Map<CDOID, T> newMap = new HashMap<CDOID, T>();
+ Map<CDOID, T> newMap = CDOIDUtil.createMap();
for (Entry<CDOID, T> entry : map.entrySet())
{
CDOID id = entry.getKey();
@@ -2891,7 +2891,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
CDOBranch oldBranch = getBranch();
CDOBranch branch = result.getBranch();
- boolean branchChanged = !ObjectUtil.equals(branch, getBranch());
+ boolean branchChanged = branch != getBranch();
if (branchChanged)
{
basicSetBranchPoint(branch.getHead());
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index 8ce98ab55a..2f544e1a38 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -874,12 +874,12 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
return null;
}
- if (rootResource != null && rootResource.cdoID().equals(id))
+ if (rootResource != null && rootResource.cdoID() == id)
{
return rootResource;
}
- if (id.equals(lastLookupID))
+ if (id == lastLookupID)
{
return lastLookupObject;
}
@@ -923,7 +923,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
{
registerObject(localLookupObject);
}
- else if (id.equals(getSession().getRepositoryInfo().getRootResourceID()))
+ else if (id == getSession().getRepositoryInfo().getRootResourceID())
{
setRootResource((CDOResourceImpl)localLookupObject);
}
@@ -998,7 +998,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
return null;
}
- if (id.equals(lastLookupID))
+ if (id == lastLookupID)
{
lastLookupID = null;
lastLookupObject = null;
@@ -1025,7 +1025,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
EClass eClass = revision.getEClass();
InternalCDOObject object;
- if (CDOModelUtil.isResource(eClass) && !id.equals(getSession().getRepositoryInfo().getRootResourceID()))
+ if (CDOModelUtil.isResource(eClass) && id != getSession().getRepositoryInfo().getRootResourceID())
{
object = (InternalCDOObject)newResourceInstance(revision);
// object is PROXY
@@ -1214,7 +1214,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
if (view != null && view.getSession() == getSession())
{
- boolean sameTarget = view.getBranch().equals(getBranch()) && view.getTimeStamp() == getTimeStamp();
+ boolean sameTarget = view.getBranch() == getBranch() && view.getTimeStamp() == getTimeStamp();
if (sameTarget)
{
return object.cdoID();
@@ -1681,7 +1681,7 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
if (eClass == EresourcePackage.Literals.CDO_RESOURCE)
{
- if (rootResourceID.equals(delta.getID()))
+ if (rootResourceID == delta.getID())
{
CDOListFeatureDelta featureDelta = (CDOListFeatureDelta)delta
.getFeatureDelta(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 8483446b59..512920262e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
@@ -74,8 +75,10 @@ import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.options.OptionsEvent;
+import org.eclipse.net4j.util.ref.KeyedReference;
import org.eclipse.net4j.util.ref.ReferenceType;
import org.eclipse.net4j.util.ref.ReferenceValueMap;
+import org.eclipse.net4j.util.ref.ReferenceValueMap2;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.NotificationChain;
@@ -219,7 +222,7 @@ public class CDOViewImpl extends AbstractCDOView
TRACER.format("Changing view target to {0}", branchPoint); //$NON-NLS-1$
}
- Map<CDOID, InternalCDORevision> oldRevisions = new HashMap<CDOID, InternalCDORevision>();
+ Map<CDOID, InternalCDORevision> oldRevisions = CDOIDUtil.createMap();
List<CDORevisionKey> allChangedObjects = new ArrayList<CDORevisionKey>();
List<CDOIDAndVersion> allDetachedObjects = new ArrayList<CDOIDAndVersion>();
@@ -433,7 +436,7 @@ public class CDOViewImpl extends AbstractCDOView
}
// If lockChangeInfo pertains to a different view, do nothing.
- if (!lockChangeInfo.getBranch().equals(getBranch()))
+ if (lockChangeInfo.getBranch() != getBranch())
{
return;
}
@@ -828,7 +831,7 @@ public class CDOViewImpl extends AbstractCDOView
{
try
{
- if (ObjectUtil.equals(branch, getBranch()))
+ if (branch == getBranch())
{
if (clearResourcePathCache)
{
@@ -1323,7 +1326,7 @@ public class CDOViewImpl extends AbstractCDOView
*/
protected final class ChangeSubscriptionManager
{
- private Map<CDOID, SubscribeEntry> subscriptions = new HashMap<CDOID, SubscribeEntry>();
+ private Map<CDOID, SubscribeEntry> subscriptions = CDOIDUtil.createMap();
public ChangeSubscriptionManager()
{
@@ -2037,36 +2040,45 @@ public class CDOViewImpl extends AbstractCDOView
synchronized (CDOViewImpl.this)
{
Map<CDOID, InternalCDOObject> objects = getModifiableObjects();
- ReferenceValueMap<CDOID, InternalCDOObject> newObjects;
+ ReferenceValueMap2<CDOID, InternalCDOObject> newObjects;
switch (referenceType)
{
case STRONG:
- if (objects instanceof ReferenceValueMap.Strong<?, ?>)
+ {
+ if (objects instanceof ReferenceValueMap2.Strong<?, ?>)
{
return false;
}
- newObjects = new ReferenceValueMap.Strong<CDOID, InternalCDOObject>();
+ Map<CDOID, KeyedReference<CDOID, InternalCDOObject>> map = CDOIDUtil.createMap();
+ newObjects = new ReferenceValueMap2.Strong<CDOID, InternalCDOObject>(map);
break;
+ }
case SOFT:
- if (objects instanceof ReferenceValueMap.Soft<?, ?>)
+ {
+ if (objects instanceof ReferenceValueMap2.Soft<?, ?>)
{
return false;
}
- newObjects = new ReferenceValueMap.Soft<CDOID, InternalCDOObject>();
+ Map<CDOID, KeyedReference<CDOID, InternalCDOObject>> map = CDOIDUtil.createMap();
+ newObjects = new ReferenceValueMap2.Soft<CDOID, InternalCDOObject>(map);
break;
+ }
case WEAK:
- if (objects instanceof ReferenceValueMap.Weak<?, ?>)
+ {
+ if (objects instanceof ReferenceValueMap2.Weak<?, ?>)
{
return false;
}
- newObjects = new ReferenceValueMap.Weak<CDOID, InternalCDOObject>();
+ Map<CDOID, KeyedReference<CDOID, InternalCDOObject>> map = CDOIDUtil.createMap();
+ newObjects = new ReferenceValueMap2.Weak<CDOID, InternalCDOObject>(map);
break;
+ }
default:
throw new IllegalArgumentException(Messages.getString("CDOViewImpl.29")); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
index c7d3022a9b..84a6d5176f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOMergingConflictResolver.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -22,7 +23,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.emf.cdo.transaction.CDOMerger;
import org.eclipse.emf.cdo.transaction.CDOMerger.ConflictException;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -109,7 +109,7 @@ public class CDOMergingConflictResolver extends AbstractChangeSetsConflictResolv
private Map<CDOID, CDORevisionDelta> getRemoteDeltas(CDOChangeSet remoteChangeSet)
{
- Map<CDOID, CDORevisionDelta> remoteDeltas = new HashMap<CDOID, CDORevisionDelta>();
+ Map<CDOID, CDORevisionDelta> remoteDeltas = CDOIDUtil.createMap();
for (CDORevisionKey key : remoteChangeSet.getChangedObjects())
{
remoteDeltas.put(key.getID(), (CDORevisionDelta)key);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index bf5c98e9bf..ee0d6a7147 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLob;
import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
@@ -685,7 +686,7 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
private long previousTimeStamp;
- private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+ private Map<CDOID, CDOID> idMappings = CDOIDUtil.createMap();
private CDOReferenceAdjuster referenceAdjuster;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/DefaultCDOMerger.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/DefaultCDOMerger.java
index dd332e4cc3..039d9b423d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/DefaultCDOMerger.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/DefaultCDOMerger.java
@@ -36,7 +36,6 @@ import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.emf.ecore.EStructuralFeature;
import java.text.MessageFormat;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -76,7 +75,7 @@ public class DefaultCDOMerger implements CDOMerger
public synchronized CDOChangeSetData merge(CDOChangeSet target, CDOChangeSet source) throws ConflictException
{
result = new CDOChangeSetDataImpl();
- conflicts = new HashMap<CDOID, Conflict>();
+ conflicts = CDOIDUtil.createMap();
targetMap = createMap(target);
sourceMap = createMap(source);
@@ -237,7 +236,7 @@ public class DefaultCDOMerger implements CDOMerger
private Map<CDOID, Object> createMap(CDOChangeSetData changeSetData)
{
- Map<CDOID, Object> map = new HashMap<CDOID, Object>();
+ Map<CDOID, Object> map = CDOIDUtil.createMap();
for (CDOIDAndVersion data : changeSetData.getNewObjects())
{
map.put(data.getID(), data);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
index c2ddc0e529..5ac511c0a2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
@@ -31,7 +32,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -168,7 +168,7 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
{
private CDOChangeSetData changeSetData = new CDOChangeSetDataImpl();
- private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+ private Map<CDOID, CDOID> idMappings = CDOIDUtil.createMap();
private List<CDOID> adjustedObjects = new ArrayList<CDOID>();
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
index 291eae1865..bd8427a724 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
@@ -482,8 +482,7 @@ public abstract class AbstractOMTest extends TestCase
public static void assertEquals(Object expected, Object actual)
{
- // IMPORTANT: Give possible CDOLegacyWrapper a chance for actual, too
- if (actual != null && actual.equals(expected))
+ if (actual == expected)
{
return;
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableArrayList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableArrayList.java
index 825f796aa2..84f539fd9a 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableArrayList.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/MoveableArrayList.java
@@ -14,7 +14,9 @@ import java.util.ArrayList;
/**
* A list with O(1) effort for random access.
- *
+ * <p>
+ * Whenever possible EMF's BasicEList should be used in favour of this list implementation.
+ *
* @author Eike Stepper
*/
public class MoveableArrayList<E> extends ArrayList<E> implements MoveableList<E>
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java
index 75bff38f4b..0ea271d86a 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap.java
@@ -4,21 +4,13 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.net4j.util.ref;
-import org.eclipse.net4j.util.collection.MapEntry;
-
import java.lang.ref.ReferenceQueue;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -31,17 +23,11 @@ import java.util.concurrent.ConcurrentMap;
* <p>
* <b>Note:</b> This map is not synchronized. If it is to be used by multiple threads concurrently the user is
* responsible for applying proper external synchronization!
- *
+ *
* @author Eike Stepper
*/
-public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
+public abstract class ReferenceValueMap<K, V> extends ReferenceValueMap2<K, V> implements ConcurrentMap<K, V>
{
- private ConcurrentMap<K, KeyedReference<K, V>> map;
-
- private ReferenceQueue<V> queue;
-
- private EntrySet entrySet;
-
public ReferenceValueMap()
{
this(new ConcurrentHashMap<K, KeyedReference<K, V>>());
@@ -49,93 +35,7 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
public ReferenceValueMap(ConcurrentMap<K, KeyedReference<K, V>> map)
{
- if (!map.isEmpty())
- {
- throw new IllegalArgumentException("!map.isEmpty()"); //$NON-NLS-1$
- }
-
- this.map = map;
- queue = createQueue();
- }
-
- @Override
- public int size()
- {
- purgeQueue();
- return map.size();
- }
-
- @Override
- public boolean isEmpty()
- {
- purgeQueue();
- return map.isEmpty();
- }
-
- @Override
- public boolean containsKey(Object key)
- {
- KeyedReference<K, V> ref = map.get(key);
- if (ref != null)
- {
- if (ref.get() == null)
- {
- // ref.enqueue();
- return false;
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean containsValue(Object value)
- {
- if (value == null)
- {
- throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
- }
-
- for (KeyedReference<K, V> ref : map.values())
- {
- V v = ref.get();
- if (v == null)
- {
- // ref.enqueue();
- return false;
- }
-
- if (value.equals(v))
- {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public V get(Object key)
- {
- KeyedReference<K, V> ref = map.get(key);
- return dereference(ref);
- }
-
- @Override
- public V put(K key, V value)
- {
- try
- {
- KeyedReference<K, V> ref = createReference(key, value, queue);
- KeyedReference<K, V> oldRef = map.put(key, ref);
- return dereference(oldRef);
- }
- finally
- {
- purgeQueue();
- }
+ super(map);
}
public V putIfAbsent(K key, V value)
@@ -143,7 +43,7 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
try
{
KeyedReference<K, V> ref = createReference(key, value, queue);
- KeyedReference<K, V> oldRef = map.putIfAbsent(key, ref);
+ KeyedReference<K, V> oldRef = ((ConcurrentMap<K, KeyedReference<K, V>>)map).putIfAbsent(key, ref);
return dereference(oldRef);
}
finally
@@ -157,7 +57,7 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
try
{
KeyedReference<K, V> ref = createReference(key, value, queue);
- KeyedReference<K, V> oldRef = map.replace(key, ref);
+ KeyedReference<K, V> oldRef = ((ConcurrentMap<K, KeyedReference<K, V>>)map).replace(key, ref);
return dereference(oldRef);
}
finally
@@ -173,7 +73,7 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
// TODO Consider a dummy KeyedReference class for oldRef
KeyedReference<K, V> oldRef = createReference(key, oldValue, queue);
KeyedReference<K, V> newRef = createReference(key, newValue, queue);
- return map.replace(key, oldRef, newRef);
+ return ((ConcurrentMap<K, KeyedReference<K, V>>)map).replace(key, oldRef, newRef);
}
finally
{
@@ -181,75 +81,12 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
}
}
- @Override
- public V remove(Object key)
- {
- KeyedReference<K, V> ref = map.remove(key);
- return dereference(ref);
- }
-
public boolean remove(Object key, Object value)
{
// TODO Consider a dummy KeyedReference class for value
- return map.remove(key, value);
- }
-
- @Override
- public void clear()
- {
- purgeQueue();
- map.clear();
- }
-
- @Override
- public Set<Map.Entry<K, V>> entrySet()
- {
- if (entrySet == null)
- {
- purgeQueue();
- entrySet = new EntrySet();
- }
-
- return entrySet;
- }
-
- protected ReferenceQueue<V> createQueue()
- {
- return new ReferenceQueue<V>();
- }
-
- @SuppressWarnings("unchecked")
- protected void purgeQueue()
- {
- if (queue != null)
- {
- KeyedReference<K, V> ref;
- while ((ref = (KeyedReference<K, V>)queue.poll()) != null)
- {
- // Slightly faster than map.get() + map.remove()
- K key = ref.getKey();
- map.remove(key, ref);
- purged(key);
- }
- }
- }
-
- protected void purged(K key)
- {
- }
-
- protected V dereference(KeyedReference<K, V> ref)
- {
- if (ref == null)
- {
- return null;
- }
-
- return ref.get();
+ return ((ConcurrentMap<K, KeyedReference<K, V>>)map).remove(key, value);
}
- protected abstract KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue);
-
/**
* @author Eike Stepper
*/
@@ -318,186 +155,4 @@ public abstract class ReferenceValueMap<K, V> extends AbstractMap<K, V> implemen
return new KeyedWeakReference<K, V>(key, value, queue);
}
}
-
- /**
- * @author Eike Stepper
- */
- private class EntrySet extends AbstractSet<Map.Entry<K, V>>
- {
- public EntrySet()
- {
- }
-
- @Override
- public int size()
- {
- return map.size();
- }
-
- @Override
- public boolean isEmpty()
- {
- return map.isEmpty();
- }
-
- @Override
- public boolean contains(Object object)
- {
- if (object == null)
- {
- throw new IllegalArgumentException("object == null"); //$NON-NLS-1$
- }
-
- if (object instanceof Map.Entry<?, ?>)
- {
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object;
- Object key = entry.getKey();
- Object value = entry.getValue();
- return key != null && value != null && value.equals(get(key));
- }
-
- return false;
- }
-
- @Override
- public Iterator<Map.Entry<K, V>> iterator()
- {
- return new EntrySetIterator();
- }
-
- @Override
- public Object[] toArray()
- {
- Object[] a = new Object[size()];
- int i = 0;
- for (Map.Entry<K, V> entry : this)
- {
- a[i++] = entry;
- }
-
- return a;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T[] toArray(T[] a)
- {
- if (a == null)
- {
- throw new IllegalArgumentException("array == null"); //$NON-NLS-1$
- }
-
- int size = size();
- if (a.length < size)
- {
- a = (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size);
- }
-
- int i = 0;
- for (Map.Entry<K, V> entry : this)
- {
- a[i++] = (T)entry;
- }
-
- if (a.length > size)
- {
- a[size] = null;
- }
-
- return a;
- }
-
- @Override
- public boolean remove(Object object)
- {
- if (object == null)
- {
- throw new IllegalArgumentException("object == null"); //$NON-NLS-1$
- }
-
- if (object instanceof Map.Entry<?, ?>)
- {
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object;
- return map.remove(entry.getKey(), entry.getValue());
- }
-
- return false;
- }
-
- @Override
- public void clear()
- {
- map.clear();
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private class EntrySetIterator implements Iterator<Map.Entry<K, V>>
- {
- private Iterator<Entry<K, KeyedReference<K, V>>> it = map.entrySet().iterator();
-
- private MapEntry<K, V> nextEntry;
-
- private K lastKey;
-
- public EntrySetIterator()
- {
- }
-
- public boolean hasNext()
- {
- if (nextEntry != null)
- {
- return true;
- }
-
- while (it.hasNext())
- {
- Entry<K, KeyedReference<K, V>> entry = it.next();
- lastKey = entry.getKey();
- V value = dereference(entry.getValue());
- if (value != null)
- {
- nextEntry = new MapEntry<K, V>(lastKey, value);
- return true;
- }
- }
-
- return false;
- }
-
- public Entry<K, V> next()
- {
- if (nextEntry == null)
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- }
-
- try
- {
- return nextEntry;
- }
- finally
- {
- nextEntry = null;
- }
- }
-
- public void remove()
- {
- if (lastKey == null)
- {
- throw new IllegalStateException("lastKey == null"); //$NON-NLS-1$
- }
-
- map.remove(lastKey);
- lastKey = null;
- nextEntry = null;
- }
- }
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap2.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap2.java
new file mode 100644
index 0000000000..e759e47d93
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/ref/ReferenceValueMap2.java
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.ref;
+
+import org.eclipse.net4j.util.collection.MapEntry;
+
+import java.lang.ref.ReferenceQueue;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * A {@link Map} implementation that uses {@link KeyedReference} instances ({@link KeyedStrongReference},
+ * {@link KeyedSoftReference}, {@link KeyedWeakReference} or {@link KeyedPhantomReference}) as its values.
+ * <p>
+ * A <code>ReferenceValueMap</code> can be used to cache mappings until the <em>value</em> of the mapping is no longer
+ * reachable from outside of the map
+ * <p>
+ * <b>Note:</b> This map is not synchronized. If it is to be used by multiple threads concurrently the user is
+ * responsible for applying proper external synchronization!
+ *
+ * @author Eike Stepper
+ */
+public abstract class ReferenceValueMap2<K, V> extends AbstractMap<K, V>
+{
+ Map<K, KeyedReference<K, V>> map;
+
+ ReferenceQueue<V> queue;
+
+ private EntrySet entrySet;
+
+ public ReferenceValueMap2()
+ {
+ this(new HashMap<K, KeyedReference<K, V>>());
+ }
+
+ public ReferenceValueMap2(Map<K, KeyedReference<K, V>> map)
+ {
+ if (!map.isEmpty())
+ {
+ throw new IllegalArgumentException("!map.isEmpty()"); //$NON-NLS-1$
+ }
+
+ this.map = map;
+ queue = createQueue();
+ }
+
+ @Override
+ public int size()
+ {
+ purgeQueue();
+ return map.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ purgeQueue();
+ return map.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key)
+ {
+ KeyedReference<K, V> ref = map.get(key);
+ if (ref != null)
+ {
+ if (ref.get() == null)
+ {
+ // ref.enqueue();
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean containsValue(Object value)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("value == null"); //$NON-NLS-1$
+ }
+
+ for (KeyedReference<K, V> ref : map.values())
+ {
+ V v = ref.get();
+ if (v == null)
+ {
+ // ref.enqueue();
+ return false;
+ }
+
+ if (value.equals(v))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public V get(Object key)
+ {
+ KeyedReference<K, V> ref = map.get(key);
+ return dereference(ref);
+ }
+
+ @Override
+ public V put(K key, V value)
+ {
+ try
+ {
+ KeyedReference<K, V> ref = createReference(key, value, queue);
+ KeyedReference<K, V> oldRef = map.put(key, ref);
+ return dereference(oldRef);
+ }
+ finally
+ {
+ purgeQueue();
+ }
+ }
+
+ @Override
+ public V remove(Object key)
+ {
+ KeyedReference<K, V> ref = map.remove(key);
+ return dereference(ref);
+ }
+
+ @Override
+ public void clear()
+ {
+ purgeQueue();
+ map.clear();
+ }
+
+ @Override
+ public Set<Map.Entry<K, V>> entrySet()
+ {
+ if (entrySet == null)
+ {
+ purgeQueue();
+ entrySet = new EntrySet();
+ }
+
+ return entrySet;
+ }
+
+ protected ReferenceQueue<V> createQueue()
+ {
+ return new ReferenceQueue<V>();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void purgeQueue()
+ {
+ if (queue != null)
+ {
+ KeyedReference<K, V> ref;
+ while ((ref = (KeyedReference<K, V>)queue.poll()) != null)
+ {
+ K key = ref.getKey();
+ map.remove(key);
+ purged(key);
+ }
+ }
+ }
+
+ protected void purged(K key)
+ {
+ }
+
+ protected V dereference(KeyedReference<K, V> ref)
+ {
+ if (ref == null)
+ {
+ return null;
+ }
+
+ return ref.get();
+ }
+
+ protected abstract KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue);
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Strong<K, V> extends ReferenceValueMap2<K, V>
+ {
+ public Strong()
+ {
+ }
+
+ public Strong(Map<K, KeyedReference<K, V>> map)
+ {
+ super(map);
+ }
+
+ @Override
+ protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue)
+ {
+ return new KeyedStrongReference<K, V>(key, value);
+ }
+
+ @Override
+ protected ReferenceQueue<V> createQueue()
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Soft<K, V> extends ReferenceValueMap2<K, V>
+ {
+ public Soft()
+ {
+ }
+
+ public Soft(Map<K, KeyedReference<K, V>> map)
+ {
+ super(map);
+ }
+
+ @Override
+ protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue)
+ {
+ return new KeyedSoftReference<K, V>(key, value, queue);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Weak<K, V> extends ReferenceValueMap2<K, V>
+ {
+ public Weak()
+ {
+ }
+
+ public Weak(Map<K, KeyedReference<K, V>> map)
+ {
+ super(map);
+ }
+
+ @Override
+ protected KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue)
+ {
+ return new KeyedWeakReference<K, V>(key, value, queue);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private class EntrySet extends AbstractSet<Map.Entry<K, V>>
+ {
+ public EntrySet()
+ {
+ }
+
+ @Override
+ public int size()
+ {
+ return map.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("object == null"); //$NON-NLS-1$
+ }
+
+ if (object instanceof Map.Entry<?, ?>)
+ {
+ Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object;
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ return key != null && value != null && value.equals(get(key));
+ }
+
+ return false;
+ }
+
+ @Override
+ public Iterator<Map.Entry<K, V>> iterator()
+ {
+ return new EntrySetIterator();
+ }
+
+ @Override
+ public Object[] toArray()
+ {
+ Object[] a = new Object[size()];
+ int i = 0;
+ for (Map.Entry<K, V> entry : this)
+ {
+ a[i++] = entry;
+ }
+
+ return a;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T[] toArray(T[] a)
+ {
+ if (a == null)
+ {
+ throw new IllegalArgumentException("array == null"); //$NON-NLS-1$
+ }
+
+ int size = size();
+ if (a.length < size)
+ {
+ a = (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size);
+ }
+
+ int i = 0;
+ for (Map.Entry<K, V> entry : this)
+ {
+ a[i++] = (T)entry;
+ }
+
+ if (a.length > size)
+ {
+ a[size] = null;
+ }
+
+ return a;
+ }
+
+ @Override
+ public boolean remove(Object object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("object == null"); //$NON-NLS-1$
+ }
+
+ if (object instanceof Map.Entry<?, ?>)
+ {
+ Map.Entry<?, ?> entry = (Map.Entry<?, ?>)object;
+ return map.remove(entry.getKey()) != null;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void clear()
+ {
+ map.clear();
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private class EntrySetIterator implements Iterator<Map.Entry<K, V>>
+ {
+ private Iterator<Entry<K, KeyedReference<K, V>>> it = map.entrySet().iterator();
+
+ private MapEntry<K, V> nextEntry;
+
+ private K lastKey;
+
+ public EntrySetIterator()
+ {
+ }
+
+ public boolean hasNext()
+ {
+ if (nextEntry != null)
+ {
+ return true;
+ }
+
+ while (it.hasNext())
+ {
+ Entry<K, KeyedReference<K, V>> entry = it.next();
+ lastKey = entry.getKey();
+ V value = dereference(entry.getValue());
+ if (value != null)
+ {
+ nextEntry = new MapEntry<K, V>(lastKey, value);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Entry<K, V> next()
+ {
+ if (nextEntry == null)
+ {
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
+ }
+
+ try
+ {
+ return nextEntry;
+ }
+ finally
+ {
+ nextEntry = null;
+ }
+ }
+
+ public void remove()
+ {
+ if (lastKey == null)
+ {
+ throw new IllegalStateException("lastKey == null"); //$NON-NLS-1$
+ }
+
+ map.remove(lastKey);
+ lastKey = null;
+ nextEntry = null;
+ }
+ }
+}

Back to the top