diff options
author | Eike Stepper | 2007-07-21 04:11:00 -0400 |
---|---|---|
committer | Eike Stepper | 2007-07-21 04:11:00 -0400 |
commit | 006d349110cfa130fc1b371313c41907bab0c859 (patch) | |
tree | 890821f1b91544f3e1a11bd31e312f7f120ef716 | |
parent | ba42970d6857c37e747a5ddbb5ace387dda19b55 (diff) | |
download | cdo-006d349110cfa130fc1b371313c41907bab0c859.zip cdo-006d349110cfa130fc1b371313c41907bab0c859.tar.gz cdo-006d349110cfa130fc1b371313c41907bab0c859.tar.xz |
*** empty log message ***
8 files changed, 456 insertions, 94 deletions
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 39c411f..76bcdce 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 @@ -24,7 +24,7 @@ import java.util.UUID; */ public class Repository extends Lifecycle implements IRepository { - private static final long INITIAL_OID_VALUE = 1; + private static final long INITIAL_OID_VALUE = 2; private String name; @@ -90,6 +90,9 @@ public class Repository extends Lifecycle implements IRepository public CDOID getNextCDOID() { - return CDOIDImpl.create(nextOIDValue++); + CDOID id = CDOIDImpl.create(nextOIDValue); + ++nextOIDValue; + ++nextOIDValue; + return id; } } 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 d255cc6..37fa940 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 @@ -266,7 +266,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject Object targetElement = data[j]; if (targetElement != null && feature.isReference()) { - targetElement = view.getCDOID_IfPossible(targetElement); + targetElement = view.convertObjectToID(targetElement); } revisionList.add(targetElement); @@ -278,7 +278,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject { if (targetValue != null && feature.isReference()) { - targetValue = view.getCDOID_IfPossible(targetValue); + targetValue = view.convertObjectToID(targetValue); } revisionList.add(targetValue); @@ -288,7 +288,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject { if (targetValue != null && feature.isReference()) { - targetValue = view.getCDOID_IfPossible(targetValue); + targetValue = view.convertObjectToID(targetValue); } revision.setValue(feature, targetValue); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java new file mode 100644 index 0000000..8facd26 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java @@ -0,0 +1,367 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.CDOView; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.model.CDOClass; +import org.eclipse.emf.cdo.protocol.revision.CDORevision; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.resource.Resource; + +/** + * @author Eike Stepper + */ +public class CDOMetaImpl implements InternalCDOObject +{ + private CDOViewImpl view; + + private InternalEObject metaInstance; + + private CDOID id; + + public CDOMetaImpl(CDOViewImpl view, InternalEObject metaInstance, CDOID id) + { + this.view = view; + this.metaInstance = metaInstance; + this.id = id; + } + + public CDOViewImpl getView() + { + return view; + } + + public InternalEObject getMetaInstance() + { + return metaInstance; + } + + public CDOID cdoID() + { + return id; + } + + public CDOState cdoState() + { + return CDOState.CLEAN; + } + + public CDORevision cdoRevision() + { + throw new UnsupportedOperationException(); + } + + public CDOResource cdoResource() + { + throw new UnsupportedOperationException(); + } + + public CDOClass cdoClass() + { + // TODO Implement method CDOMetaImpl.cdoClass() + throw new UnsupportedOperationException("Not yet implemented"); + } + + public CDOViewImpl cdoView() + { + return view; + } + + public boolean cdoTransient() + { + return false; + } + + public void cdoInternalSetID(CDOID id) + { + throw new UnsupportedOperationException(); + } + + public void cdoInternalSetState(CDOState state) + { + throw new UnsupportedOperationException(); + } + + public void cdoInternalSetRevision(CDORevision revision) + { + throw new UnsupportedOperationException(); + } + + public void cdoInternalSetView(CDOView view) + { + throw new UnsupportedOperationException(); + } + + public void cdoInternalSetResource(CDOResource resource) + { + throw new UnsupportedOperationException(); + } + + public void cdoInternalFinalizeRevision() + { + throw new UnsupportedOperationException(); + } + + public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID) + { + // TODO Implement method CDOMetaImpl.enclosing_method() + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public String toString() + { + if (cdoID() == null) + { + return metaInstance.eClass().getName() + "?"; + } + + return metaInstance.eClass().getName() + "@" + cdoID(); + } + + public EList<Adapter> eAdapters() + { + return metaInstance.eAdapters(); + } + + public TreeIterator<EObject> eAllContents() + { + return metaInstance.eAllContents(); + } + + public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) + { + return metaInstance.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + public NotificationChain eBasicRemoveFromContainer(NotificationChain notifications) + { + return metaInstance.eBasicRemoveFromContainer(notifications); + } + + public NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID, + NotificationChain notifications) + { + return metaInstance.eBasicSetContainer(newContainer, newContainerFeatureID, notifications); + } + + public EClass eClass() + { + return metaInstance.eClass(); + } + + public EObject eContainer() + { + return metaInstance.eContainer(); + } + + public int eContainerFeatureID() + { + return metaInstance.eContainerFeatureID(); + } + + public EStructuralFeature eContainingFeature() + { + return metaInstance.eContainingFeature(); + } + + public EReference eContainmentFeature() + { + return metaInstance.eContainmentFeature(); + } + + public EList<EObject> eContents() + { + return metaInstance.eContents(); + } + + public EList<EObject> eCrossReferences() + { + return metaInstance.eCrossReferences(); + } + + public boolean eDeliver() + { + return metaInstance.eDeliver(); + } + + public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) + { + return metaInstance.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + public Resource.Internal eDirectResource() + { + return metaInstance.eDirectResource(); + } + + public Object eGet(EStructuralFeature feature, boolean resolve, boolean coreType) + { + return metaInstance.eGet(feature, resolve, coreType); + } + + public Object eGet(EStructuralFeature feature, boolean resolve) + { + return metaInstance.eGet(feature, resolve); + } + + public Object eGet(EStructuralFeature feature) + { + return metaInstance.eGet(feature); + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + return metaInstance.eGet(featureID, resolve, coreType); + } + + public InternalEObject eInternalContainer() + { + return metaInstance.eInternalContainer(); + } + + public Resource.Internal eInternalResource() + { + return metaInstance.eInternalResource(); + } + + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class<?> baseClass, + NotificationChain notifications) + { + return metaInstance.eInverseAdd(otherEnd, featureID, baseClass, notifications); + } + + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class<?> baseClass, + NotificationChain notifications) + { + return metaInstance.eInverseRemove(otherEnd, featureID, baseClass, notifications); + } + + public boolean eIsProxy() + { + return metaInstance.eIsProxy(); + } + + public boolean eIsSet(EStructuralFeature feature) + { + return metaInstance.eIsSet(feature); + } + + public boolean eIsSet(int featureID) + { + return metaInstance.eIsSet(featureID); + } + + public boolean eNotificationRequired() + { + return metaInstance.eNotificationRequired(); + } + + public void eNotify(Notification notification) + { + metaInstance.eNotify(notification); + } + + public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) + { + return metaInstance.eObjectForURIFragmentSegment(uriFragmentSegment); + } + + public URI eProxyURI() + { + return metaInstance.eProxyURI(); + } + + public EObject eResolveProxy(InternalEObject proxy) + { + return metaInstance.eResolveProxy(proxy); + } + + public Resource eResource() + { + return metaInstance.eResource(); + } + + public void eSet(EStructuralFeature feature, Object newValue) + { + metaInstance.eSet(feature, newValue); + } + + public void eSet(int featureID, Object newValue) + { + metaInstance.eSet(featureID, newValue); + } + + public void eSetClass(EClass class1) + { + metaInstance.eSetClass(class1); + } + + public void eSetDeliver(boolean deliver) + { + metaInstance.eSetDeliver(deliver); + } + + public void eSetProxyURI(URI uri) + { + metaInstance.eSetProxyURI(uri); + } + + public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications) + { + return metaInstance.eSetResource(resource, notifications); + } + + public void eSetStore(EStore store) + { + metaInstance.eSetStore(store); + } + + public Setting eSetting(EStructuralFeature feature) + { + return metaInstance.eSetting(feature); + } + + public EStore eStore() + { + return metaInstance.eStore(); + } + + public void eUnset(EStructuralFeature feature) + { + metaInstance.eUnset(feature); + } + + public void eUnset(int featureID) + { + metaInstance.eUnset(featureID); + } + + public String eURIFragmentSegment(EStructuralFeature feature, EObject object) + { + return metaInstance.eURIFragmentSegment(feature, object); + } +} 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 95df8d8..742ed7c 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.getCDOID_IfPossible(value); + value = view.convertObjectToID(value); } revision.add(cdoFeature, index++, value); @@ -456,7 +456,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec { if (isReference) { - setting = view.getCDOID_IfPossible(setting); + setting = view.convertObjectToID(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 4f73f82..889ee5f 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 @@ -272,6 +272,11 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession private void registerMetaInstance(InternalEObject metaInstance) { CDOID id = CDOIDImpl.create(nextTemporaryID); + if (TRACER.isEnabled()) + { + TRACER.format("Registering meta instance: {0} <-> {1}", id, metaInstance); + } + idToMetaInstanceMap.put(id, metaInstance); metaInstanceToIDMap.put(metaInstance, id); --nextTemporaryID; 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 1505e00..af15ab0 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()).getCDOObject_IfPossible(id); + return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(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()).getCDOID_IfPossible(newContainer); + CDOID containerID = (CDOID)((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(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()).getCDOObject_IfPossible(result); + result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result); } return result; @@ -153,7 +153,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value); + value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value); } CDORevisionImpl revision = getRevisionForReading(cdoObject); @@ -171,7 +171,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value); + value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value); } CDORevisionImpl revision = getRevisionForReading(cdoObject); @@ -189,7 +189,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value); + value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(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()).getCDOObject_IfPossible(result[i]); + result[i] = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result[i]); } } @@ -253,14 +253,14 @@ public final class CDOStore implements EStore handleContainmentAdd(cdoObject, cdoFeature, value); } - value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value); + value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value); } CDORevisionImpl revision = getRevisionForWriting(cdoObject); Object result = revision.set(cdoFeature, index, value); if (cdoFeature.isReference()) { - result = ((CDOViewImpl)cdoObject.cdoView()).getCDOObject_IfPossible(result); + result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result); } return result; @@ -295,7 +295,7 @@ public final class CDOStore implements EStore handleContainmentAdd(cdoObject, cdoFeature, value); } - value = ((CDOViewImpl)cdoObject.cdoView()).getCDOID_IfPossible(value); + value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(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()).getCDOObject_IfPossible(result); + result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(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()).getCDOObject_IfPossible(result); + result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(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 d0f5b7b..794d5c8 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 @@ -20,7 +20,7 @@ import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.eresource.EresourceFactory; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl; -import org.eclipse.emf.cdo.internal.protocol.revision.CDOReferenceConverter; +import org.eclipse.emf.cdo.internal.protocol.revision.CDOIDProvider; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; import org.eclipse.emf.cdo.protocol.CDOID; import org.eclipse.emf.cdo.protocol.model.CDOClass; @@ -37,6 +37,7 @@ 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; @@ -54,8 +55,8 @@ import java.util.Set; /** * @author Eike Stepper */ -public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier implements CDOView, - CDOReferenceConverter, Adapter.Internal +public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier implements CDOView, CDOIDProvider, + Adapter.Internal { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_VIEW, CDOViewImpl.class); @@ -231,29 +232,55 @@ 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); - // CDOAdapterImpl adapter = CDOAdapterImpl.getOrCreate(metaObject); - // adapter.cdoInternalSetID(id); - // adapter.cdoInternalSetState(CDOState.CLEAN); - // adapter.cdoInternalSetView(this); - // lastLookupObject = adapter; - // } - // else + lastLookupObject = createInstance(id); + registerObject(lastLookupObject); + } + + return lastLookupObject; + } + + private InternalCDOObject createInstance(CDOID id) + { + if (TRACER.isEnabled()) + { + TRACER.format("Creating view instance: ID={0}", id); + } + + if (id.isMeta()) + { + InternalEObject metaInstance = session.lookupMetaInstance(id); + if (metaInstance == null) { - lastLookupObject = createObject(id); + throw new IllegalArgumentException("No meta instance for " + id); } - registerObject(lastLookupObject); + return new CDOMetaImpl(this, metaInstance, id); } - return lastLookupObject; + CDORevisionImpl revision = lookupRevision(id); + CDOClassImpl cdoClass = revision.getCDOClass(); + CDOID resourceID = revision.getResourceID(); + + InternalCDOObject object = newInstance(cdoClass); + if (object instanceof CDOResourceImpl) + { + object.cdoInternalSetResource((CDOResourceImpl)object); + } + else + { + CDOResourceImpl resource = getResource(resourceID); + object.cdoInternalSetResource(resource); + } + + object.cdoInternalSetRevision(revision); + object.cdoInternalSetID(revision.getID()); + object.cdoInternalSetState(CDOState.CLEAN); + return object; } - public CDOID convertReference(Object idOrObject) + public CDOID provideCDOID(Object idOrObject) { - Object shouldBeCDOID = getCDOID_IfPossible(idOrObject); + Object shouldBeCDOID = convertObjectToID(idOrObject); if (shouldBeCDOID instanceof CDOID) { CDOID id = (CDOID)shouldBeCDOID; @@ -268,41 +295,29 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier throw new ImplementationError("Not a CDOID: " + shouldBeCDOID); } - public Object getCDOID_IfPossible(Object potentialObject) + public Object convertObjectToID(Object potentialObject) { if (potentialObject == null) { throw new ImplementationError(); } - // if (!(potentialObject instanceof InternalCDOObject)) - // { - // if (potentialObject instanceof InternalEObject) - // { - // InternalEObject eObject = (InternalEObject)potentialObject; - // CDOAdapterImpl adapter = CDOAdapterImpl.get(eObject); - // if (adapter == null) - // { - // eObject = (InternalEObject)EcoreUtil.resolve(eObject, resourceSet); - // CDOID id = session.lookupMetaInstanceID(eObject); - // if (id != null) - // { - // adapter = (CDOAdapterImpl)lookupInstance(id); - // } - // } - // - // if (adapter != null) - // { - // potentialObject = adapter; - // } - // } - // } + if (potentialObject instanceof InternalEObject && !(potentialObject instanceof InternalCDOObject)) + { + InternalEObject eObject = (InternalEObject)potentialObject; + CDOAdapterImpl adapter = CDOAdapterImpl.get(eObject); + if (adapter == null) + { + throw new ImplementationError("No adapter for " + eObject); + } + + potentialObject = adapter; + } if (potentialObject instanceof InternalCDOObject) { InternalCDOObject object = (InternalCDOObject)potentialObject; - CDOView view = object.cdoView(); - if (view == this) + if (object.cdoView() == this) { return object.cdoID(); } @@ -316,7 +331,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier return potentialObject; } - public Object getCDOObject_IfPossible(Object potentialID) + public Object convertIDToObject(Object potentialID) { if (potentialID instanceof CDOID) { @@ -630,34 +645,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier fireEvent(new ResourcesEvent(cdoResource.getPath(), ResourcesEvent.Kind.REMOVED)); } - private InternalCDOObject createObject(CDOID id) - { - if (TRACER.isEnabled()) - { - TRACER.format("Creating object from view: ID={0}", id); - } - - CDORevisionImpl revision = lookupRevision(id); - CDOClassImpl cdoClass = revision.getCDOClass(); - CDOID resourceID = revision.getResourceID(); - - InternalCDOObject object = newInstance(cdoClass); - if (object instanceof CDOResourceImpl) - { - object.cdoInternalSetResource((CDOResourceImpl)object); - } - else - { - CDOResourceImpl resource = getResource(resourceID); - object.cdoInternalSetResource(resource); - } - - object.cdoInternalSetRevision(revision); - object.cdoInternalSetID(revision.getID()); - object.cdoInternalSetState(CDOState.CLEAN); - return object; - } - private void checkWritable() { if (isReadOnly()) 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 6538972..500bcfe 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 @@ -13,7 +13,7 @@ package org.eclipse.emf.internal.cdo.protocol; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl; -import org.eclipse.emf.cdo.internal.protocol.revision.CDOReferenceConverter; +import org.eclipse.emf.cdo.internal.protocol.revision.CDOIDProvider; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; import org.eclipse.emf.cdo.protocol.CDOID; import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; @@ -108,13 +108,13 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction private void writeRevisions(ExtendedDataOutputStream out, Collection objects) throws IOException { - CDOReferenceConverter converter = transaction.getView(); + CDOIDProvider idProvider = transaction.getView(); out.writeInt(objects.size()); for (Iterator it = objects.iterator(); it.hasNext();) { InternalCDOObject object = (InternalCDOObject)it.next(); CDORevisionImpl revision = (CDORevisionImpl)object.cdoRevision(); - revision.write(out, converter); + revision.write(out, idProvider); } } |