summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-02 01:07:32 (EDT)
committerEike Stepper2007-08-02 01:07:32 (EDT)
commit6dac02aeda03be98a84674393dbeaee6d2ea4786 (patch)
treef82efa9068a4ab1bfda360cb356f64cc041de52a
parent829ad174fdc7dca644629edf9d6f6b8fabc9338a (diff)
downloadcdo-6dac02aeda03be98a84674393dbeaee6d2ea4786.zip
cdo-6dac02aeda03be98a84674393dbeaee6d2ea4786.tar.gz
cdo-6dac02aeda03be98a84674393dbeaee6d2ea4786.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java33
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java32
3 files changed, 67 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
index cf48952..2ebd565 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
@@ -67,15 +67,15 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOAdapterImpl.class);
- private CDOViewImpl view;
+ protected CDOViewImpl view;
- private CDOID id;
+ protected CDOID id;
- private CDOState state;
+ protected CDOState state;
- private CDOResourceImpl resource;
+ protected CDOResourceImpl resource;
- private CDORevisionImpl revision;
+ protected CDORevisionImpl revision;
public CDOAdapterImpl()
{
@@ -217,6 +217,10 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
}
}
}
+ else
+ {
+ // TODO Detect duplicate setstate calls
+ }
}
public void cdoInternalSetRevision(CDORevision revision)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
index 0737270..2efae3a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
@@ -10,14 +10,22 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDOState;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
+import org.eclipse.emf.internal.cdo.bundle.OM;
/**
* @author Eike Stepper
*/
public class CDOCallbackImpl extends CDOAdapterImpl implements CDOCallback
{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOCallbackImpl.class);
+
public CDOCallbackImpl()
{
}
@@ -31,4 +39,29 @@ public class CDOCallbackImpl extends CDOAdapterImpl implements CDOCallback
{
CDOStateMachine.INSTANCE.write(this);
}
+
+ @Override
+ public void notifyChanged(Notification msg)
+ {
+ // Do nothing
+ }
+
+ @Override
+ public void cdoInternalSetState(CDOState state)
+ {
+ // TODO Move common logic to CDOObjectImpl (see CDOAdapterImpl)
+ if (this.state != state)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting state {0} for {1}", state, this);
+ }
+
+ this.state = state;
+ }
+ else
+ {
+ // TODO Detect duplicate setstate calls
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 2d9569d..87f2d61 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -283,16 +283,28 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public void registerEPackage(EPackage ePackage, CDOIDRange metaIDRange)
{
- // TODO Check range is not temp
- registerMetaInstance((InternalEObject)ePackage, metaIDRange.getLowerBound().getValue());
- // TODO Check count matches range
+ if (metaIDRange.isTemporary())
+ {
+ throw new IllegalArgumentException("metaIDRange.isTemporary()");
+ }
+
+ if (!metaIDRange.isMeta())
+ {
+ throw new IllegalArgumentException("!metaIDRange.isMeta()");
+ }
+
+ long count = registerMetaInstance((InternalEObject)ePackage, metaIDRange.getLowerBound().getValue());
+ if (count != metaIDRange.getCount())
+ {
+ throw new IllegalStateException("count != metaIDRange.getCount()");
+ }
}
public CDOIDRange registerEPackage(EPackage ePackage)
{
long count = registerMetaInstance((InternalEObject)ePackage, nextTemporaryID);
- long newTempID = nextTemporaryID - 2 * count;
- CDOIDRange range = CDOIDRangeImpl.create(nextTemporaryID, newTempID + 2);
+ long newTempID = nextTemporaryID - 2L * count;
+ CDOIDRange range = CDOIDRangeImpl.create(nextTemporaryID, newTempID + 2L);
nextTemporaryID = newTempID;
return range;
}
@@ -311,10 +323,11 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
idToMetaInstanceMap.put(id, metaInstance);
metaInstanceToIDMap.put(metaInstance, id);
- long count = 1;
+ long step = id.isTemporary() ? -2L : 2L;
+ long count = 1L;
for (EObject content : metaInstance.eContents())
{
- count += registerMetaInstance((InternalEObject)content, idValue + 2 * count);
+ count += registerMetaInstance((InternalEObject)content, idValue + step * count);
}
return count;
@@ -323,6 +336,11 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public void remapMetaInstance(CDOID oldID, CDOID newID)
{
InternalEObject metaInstance = idToMetaInstanceMap.remove(oldID);
+ if (metaInstance == null)
+ {
+ throw new IllegalArgumentException("Unknown meta instance id: " + oldID);
+ }
+
if (TRACER.isEnabled())
{
TRACER.format("Remapping meta instance: {0} --> {1} <-> {2}", oldID, newID, metaInstance);