summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-20 15:26:37 (EDT)
committerEike Stepper2007-07-20 15:26:37 (EDT)
commite6dbaf2b910f7d4581df13efce5b9be54412bf29 (patch)
tree0b164518744b9364e52a90159950c9facdc78474
parente761b11da54144b11ea1883de0f0b5a0f8252a04 (diff)
downloadcdo-e6dbaf2b910f7d4581df13efce5b9be54412bf29.zip
cdo-e6dbaf2b910f7d4581df13efce5b9be54412bf29.tar.gz
cdo-e6dbaf2b910f7d4581df13efce5b9be54412bf29.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java24
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java271
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java2
6 files changed, 194 insertions, 116 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
index ce78965..0623d0f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
@@ -266,7 +266,7 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
Object targetElement = data[j];
if (targetElement != null && feature.isReference())
{
- targetElement = view.convertToID(targetElement);
+ targetElement = view.getCDOID_IfPossible(targetElement);
}
revisionList.add(targetElement);
@@ -278,7 +278,7 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
{
if (targetValue != null && feature.isReference())
{
- targetValue = view.convertToID(targetValue);
+ targetValue = view.getCDOID_IfPossible(targetValue);
}
revisionList.add(targetValue);
@@ -288,7 +288,7 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
{
if (targetValue != null && feature.isReference())
{
- targetValue = view.convertToID(targetValue);
+ targetValue = view.getCDOID_IfPossible(targetValue);
}
revision.setValue(feature, targetValue);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 05fe66c..95df8d8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -446,7 +446,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
if (isReference)
{
- value = view.convertToID(value);
+ value = view.getCDOID_IfPossible(value);
}
revision.add(cdoFeature, index++, value);
@@ -456,7 +456,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
if (isReference)
{
- setting = view.convertToID(setting);
+ setting = view.getCDOID_IfPossible(setting);
}
revision.set(cdoFeature, 0, setting);
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 c725e05..4f73f82 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
@@ -276,9 +276,6 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
metaInstanceToIDMap.put(metaInstance, id);
--nextTemporaryID;
--nextTemporaryID;
-
- CDOObjectAdapter adapter = CDOObjectAdapter.getOrCreate(metaInstance);
- adapter.cdoInternalSetID(id);
}
public void notifyInvalidation(long timeStamp, Set<CDOID> dirtyOIDs, CDOViewImpl excludedView)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index 4ef8c76..5c5c92b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -49,7 +49,7 @@ public final class CDOStore implements EStore
CDORevisionImpl revision = getRevisionForReading(cdoObject);
CDOID id = revision.getContainerID();
- return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).convertToObject(id);
+ return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(id);
}
public int getContainingFeatureID(InternalEObject eObject)
@@ -72,7 +72,7 @@ public final class CDOStore implements EStore
TRACER.format("setContainer({0}, {1}, {2})", cdoObject, newContainer, newContainerFeatureID);
}
- CDOID containerID = (CDOID)((CDOViewImpl)cdoObject.cdoView()).convertToID(newContainer);
+ CDOID containerID = (CDOID)((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(newContainer);
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
revision.setContainerID(containerID);
@@ -97,7 +97,7 @@ public final class CDOStore implements EStore
Object result = revision.get(cdoFeature, index);
if (cdoFeature.isReference())
{
- result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result);
}
return result;
@@ -153,7 +153,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -171,7 +171,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -189,7 +189,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -224,7 +224,7 @@ public final class CDOStore implements EStore
{
for (int i = 0; i < result.length; i++)
{
- result[i] = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result[i]);
+ result[i] = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result[i]);
}
}
@@ -253,14 +253,14 @@ public final class CDOStore implements EStore
handleContainmentAdd(cdoObject, cdoFeature, value);
}
- value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value);
}
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
Object result = revision.set(cdoFeature, index, value);
if (cdoFeature.isReference())
{
- result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result);
}
return result;
@@ -295,7 +295,7 @@ public final class CDOStore implements EStore
handleContainmentAdd(cdoObject, cdoFeature, value);
}
- value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value);
}
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
@@ -315,7 +315,7 @@ public final class CDOStore implements EStore
Object result = revision.remove(cdoFeature, index);
if (cdoFeature.isReference())
{
- result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result);
}
return result;
@@ -347,7 +347,7 @@ public final class CDOStore implements EStore
Object result = revision.move(cdoFeature, target, source);
if (cdoFeature.isReference())
{
- result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result);
}
return result;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index b4fb174..1d33a10 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
-import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewCommittedEvent;
@@ -38,7 +37,6 @@ import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -56,7 +54,8 @@ import java.util.Set;
/**
* @author Eike Stepper
*/
-public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier implements CDOView, Adapter.Internal
+public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier implements CDOView,
+ CDOReferenceConverter, Adapter.Internal
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_VIEW, CDOViewImpl.class);
@@ -76,8 +75,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
private InternalCDOObject lastLookupObject;
- private CDOReferenceConverter referenceConverter;
-
public CDOViewImpl(int id, CDOSessionImpl session, boolean readOnly)
{
this.id = id;
@@ -87,20 +84,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
transaction = new CDOTransactionImpl(this);
}
-
- referenceConverter = new CDOReferenceConverter()
- {
- public CDOID convertToID(Object object)
- {
- CDOID id = (CDOID)CDOViewImpl.this.convertToID(object);
- if (TRACER.isEnabled())
- {
- TRACER.format("Converted dangling reference: {0} --> {1}", object, id);
- }
-
- return id;
- }
- };
}
public CDOViewImpl(int id, CDOSessionImpl session, long timeStamp)
@@ -248,16 +231,16 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
lastLookupObject = objects.get(id);
if (lastLookupObject == null)
{
- if (id.isMeta())
- {
- InternalEObject metaObject = session.lookupMetaInstance(id);
- CDOObjectAdapter adapter = CDOObjectAdapter.getOrCreate(metaObject);
- adapter.cdoInternalSetID(id);
- adapter.cdoInternalSetState(CDOState.CLEAN);
- adapter.cdoInternalSetView(this);
- lastLookupObject = adapter;
- }
- else
+ // if (id.isMeta())
+ // {
+ // InternalEObject metaObject = session.lookupMetaInstance(id);
+ // CDOObjectAdapter adapter = CDOObjectAdapter.getOrCreate(metaObject);
+ // adapter.cdoInternalSetID(id);
+ // adapter.cdoInternalSetState(CDOState.CLEAN);
+ // adapter.cdoInternalSetView(this);
+ // lastLookupObject = adapter;
+ // }
+ // else
{
lastLookupObject = createObject(id);
}
@@ -268,89 +251,116 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return lastLookupObject;
}
- public void registerObject(InternalCDOObject object)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Registering object {0}", object);
- }
-
- InternalCDOObject old = objects.put(object.cdoID(), object);
- if (old != null)
- {
- throw new IllegalStateException("Duplicate ID: " + object);
- }
- }
+ // public final class HistoryEntryImpl implements HistoryEntry, Comparable
+ // {
+ // private String resourcePath;
+ //
+ // private HistoryEntryImpl(String resourcePath)
+ // {
+ // this.resourcePath = resourcePath;
+ // }
+ //
+ // public CDOView getView()
+ // {
+ // return CDOViewImpl.this;
+ // }
+ //
+ // public String getResourcePath()
+ // {
+ // return resourcePath;
+ // }
+ //
+ // public int compareTo(Object o)
+ // {
+ // HistoryEntry that = (HistoryEntry)o;
+ // return resourcePath.compareTo(that.getResourcePath());
+ // }
+ //
+ // @Override
+ // public String toString()
+ // {
+ // return resourcePath;
+ // }
+ // }
- public void deregisterObject(InternalCDOObject object)
+ public CDOID convertReference(Object idOrObject)
{
+ CDOID id = (CDOID)getCDOID_IfPossible(idOrObject);
if (TRACER.isEnabled())
{
- TRACER.format("Deregistering object {0}", object);
+ TRACER.format("Converted dangling reference: {0} --> {1}", idOrObject, id);
}
- InternalCDOObject old = objects.remove(object.cdoID());
- if (old == null)
- {
- throw new IllegalStateException("Unknown ID: " + object);
- }
- }
-
- public void remapObject(CDOID oldID)
- {
- InternalCDOObject object = objects.remove(oldID);
- CDOID newID = object.cdoID();
- objects.put(newID, object);
- if (TRACER.isEnabled())
- {
- TRACER.format("Remapping object: {0} --> {1}", oldID, newID);
- }
+ return id;
}
- public CDOReferenceConverter getReferenceConverter()
- {
- return referenceConverter;
- }
+ // public final class HistoryEntryImpl implements HistoryEntry, Comparable
+ // {
+ // private String resourcePath;
+ //
+ // private HistoryEntryImpl(String resourcePath)
+ // {
+ // this.resourcePath = resourcePath;
+ // }
+ //
+ // public CDOView getView()
+ // {
+ // return CDOViewImpl.this;
+ // }
+ //
+ // public String getResourcePath()
+ // {
+ // return resourcePath;
+ // }
+ //
+ // public int compareTo(Object o)
+ // {
+ // HistoryEntry that = (HistoryEntry)o;
+ // return resourcePath.compareTo(that.getResourcePath());
+ // }
+ //
+ // @Override
+ // public String toString()
+ // {
+ // return resourcePath;
+ // }
+ // }
- public Object convertToID(Object potentialObject)
+ public Object getCDOID_IfPossible(Object potentialObject)
{
if (potentialObject == null)
{
throw new ImplementationError();
}
- if (!(potentialObject instanceof InternalCDOObject))
- {
- if (potentialObject instanceof InternalEObject)
- {
- InternalEObject eObject = (InternalEObject)potentialObject;
- CDOObjectAdapter adapter = CDOObjectAdapter.get(eObject);
- if (adapter == null)
- {
- eObject = (InternalEObject)EcoreUtil.resolve(eObject, resourceSet);
- CDOID id = session.lookupMetaInstanceID(eObject);
- if (id != null)
- {
- if (id.getValue() == -777)
- {
- System.out.println(id);
- }
-
- adapter = (CDOObjectAdapter)lookupInstance(id);
- }
- }
-
- if (adapter != null)
- {
- potentialObject = adapter;
- }
- }
- }
+ // if (!(potentialObject instanceof InternalCDOObject))
+ // {
+ // if (potentialObject instanceof InternalEObject)
+ // {
+ // InternalEObject eObject = (InternalEObject)potentialObject;
+ // CDOObjectAdapter adapter = CDOObjectAdapter.get(eObject);
+ // if (adapter == null)
+ // {
+ // eObject = (InternalEObject)EcoreUtil.resolve(eObject, resourceSet);
+ // CDOID id = session.lookupMetaInstanceID(eObject);
+ // if (id != null)
+ // {
+ // adapter = (CDOObjectAdapter)lookupInstance(id);
+ // }
+ // }
+ //
+ // if (adapter != null)
+ // {
+ // potentialObject = adapter;
+ // }
+ // }
+ // }
if (potentialObject instanceof InternalCDOObject)
{
InternalCDOObject object = (InternalCDOObject)potentialObject;
- if (object.cdoView() == this)
+ CDOView view = object.cdoView();
+ if (view == this)
{
return object.cdoID();
}
@@ -364,7 +374,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return potentialObject;
}
- public Object convertToObject(Object potentialID)
+ public Object getCDOObject_IfPossible(Object potentialID)
{
if (potentialID instanceof CDOID)
{
@@ -374,7 +384,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
CDOID id = (CDOID)potentialID;
- CDOObject result = lookupInstance(id);
+ InternalCDOObject result = lookupInstance(id);
if (result == null)
{
throw new ImplementationError("ID not registered: " + id);
@@ -386,6 +396,77 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return potentialID;
}
+ public void registerObject(InternalCDOObject object)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Registering object {0}", object);
+ }
+
+ InternalCDOObject old = objects.put(object.cdoID(), object);
+ if (old != null)
+ {
+ throw new IllegalStateException("Duplicate ID: " + object);
+ }
+ }
+
+ public void deregisterObject(InternalCDOObject object)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Deregistering object {0}", object);
+ }
+
+ InternalCDOObject old = objects.remove(object.cdoID());
+ if (old == null)
+ {
+ throw new IllegalStateException("Unknown ID: " + object);
+ }
+ }
+
+ public void remapObject(CDOID oldID)
+ {
+ InternalCDOObject object = objects.remove(oldID);
+ CDOID newID = object.cdoID();
+ objects.put(newID, object);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Remapping object: {0} --> {1}", oldID, newID);
+ }
+ }
+
+ // public final class HistoryEntryImpl implements HistoryEntry, Comparable
+ // {
+ // private String resourcePath;
+ //
+ // private HistoryEntryImpl(String resourcePath)
+ // {
+ // this.resourcePath = resourcePath;
+ // }
+ //
+ // public CDOView getView()
+ // {
+ // return CDOViewImpl.this;
+ // }
+ //
+ // public String getResourcePath()
+ // {
+ // return resourcePath;
+ // }
+ //
+ // public int compareTo(Object o)
+ // {
+ // HistoryEntry that = (HistoryEntry)o;
+ // return resourcePath.compareTo(that.getResourcePath());
+ // }
+ //
+ // @Override
+ // public String toString()
+ // {
+ // return resourcePath;
+ // }
+ // }
+
/**
* Turns registered objects into proxies and synchronously delivers
* invalidation events to registered event listeners.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 7e3ac4d..6538972 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -108,7 +108,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
private void writeRevisions(ExtendedDataOutputStream out, Collection objects) throws IOException
{
- CDOReferenceConverter converter = transaction.getView().getReferenceConverter();
+ CDOReferenceConverter converter = transaction.getView();
out.writeInt(objects.size());
for (Iterator it = objects.iterator(); it.hasNext();)
{