summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-19 05:18:50 (EDT)
committerEike Stepper2007-07-19 05:18:50 (EDT)
commit6e2cfb4daeec4ae676af5e7f7ae1501e89ce1ffb (patch)
tree5baec41bcfbf02a86287ed66211d655599924914
parent619ccf8ff5811ee78b59b0794f3802d586f33af8 (diff)
downloadcdo-6e2cfb4daeec4ae676af5e7f7ae1501e89ce1ffb.zip
cdo-6e2cfb4daeec4ae676af5e7f7ae1501e89ce1ffb.tar.gz
cdo-6e2cfb4daeec4ae676af5e7f7ae1501e89ce1ffb.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java397
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java222
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java9
4 files changed, 528 insertions, 104 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
new file mode 100644
index 0000000..e4ac647
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
@@ -0,0 +1,397 @@
+/***************************************************************************
+ * 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.eresource.impl.CDOResourceImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+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.net4j.internal.util.om.trace.ContextTracer;
+
+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.notify.impl.AdapterImpl;
+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;
+import org.eclipse.emf.internal.cdo.bundle.OM;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectAdapter.class);
+
+ private CDOID id;
+
+ private CDOState state;
+
+ private CDOResourceImpl resource;
+
+ private CDORevisionImpl revision;
+
+ public CDOObjectAdapter()
+ {
+ }
+
+ public CDOID cdoID()
+ {
+ return id;
+ }
+
+ public CDOState cdoState()
+ {
+ return state;
+ }
+
+ public CDORevision cdoRevision()
+ {
+ return revision;
+ }
+
+ public CDOResource cdoResource()
+ {
+ return resource;
+ }
+
+ public CDOClass cdoClass()
+ {
+ return CDOObjectImpl.getCDOClass(this);
+ }
+
+ public CDOView cdoView()
+ {
+ return CDOObjectImpl.getCDOView(this);
+ }
+
+ public boolean cdoTransient()
+ {
+ return CDOObjectImpl.isCDOTransient(this);
+ }
+
+ public void cdoInternalSetID(CDOID id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id == null");
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting ID: {0}", id);
+ }
+
+ this.id = id;
+ }
+
+ public void cdoInternalSetState(CDOState state)
+ {
+ if (this.state != state)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting state {0} for {1}", state, this);
+ }
+
+ this.state = state;
+ }
+ }
+
+ public void cdoInternalSetRevision(CDORevision revision)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting revision: {0}", revision);
+ }
+
+ this.revision = (CDORevisionImpl)revision;
+ revisionToEObject();
+ }
+
+ private void revisionToEObject()
+ {
+ InternalEObject eObject = getEObject();
+
+ // TODO Implement method CDOObjectAdapter.revisionToEObject()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void cdoInternalSetView(CDOView view)
+ {
+ // Do nothing since getEObject() will never deliver a CDOResource
+ }
+
+ public void cdoInternalSetResource(CDOResource resource)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting resource: {0}", resource);
+ }
+
+ this.resource = (CDOResourceImpl)resource;
+ }
+
+ public void cdoInternalFinalizeRevision()
+ {
+ CDOObjectImpl.finalizeCDORevision(this, null, 0, null);
+
+ // TODO Implement method CDOObjectAdapter.cdoInternalFinalizeRevision()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
+ {
+ // TODO Implement method CDOObjectAdapter.cdoInternalDynamicFeature()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public InternalEObject getEObject()
+ {
+ return (InternalEObject)target;
+ }
+
+ public EList<Adapter> eAdapters()
+ {
+ return getEObject().eAdapters();
+ }
+
+ public TreeIterator<EObject> eAllContents()
+ {
+ return getEObject().eAllContents();
+ }
+
+ public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
+ {
+ return getEObject().eBaseStructuralFeatureID(derivedFeatureID, baseClass);
+ }
+
+ public NotificationChain eBasicRemoveFromContainer(NotificationChain notifications)
+ {
+ return getEObject().eBasicRemoveFromContainer(notifications);
+ }
+
+ public NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID,
+ NotificationChain notifications)
+ {
+ return getEObject().eBasicSetContainer(newContainer, newContainerFeatureID, notifications);
+ }
+
+ public EClass eClass()
+ {
+ return getEObject().eClass();
+ }
+
+ public EObject eContainer()
+ {
+ return getEObject().eContainer();
+ }
+
+ public int eContainerFeatureID()
+ {
+ return getEObject().eContainerFeatureID();
+ }
+
+ public EStructuralFeature eContainingFeature()
+ {
+ return getEObject().eContainingFeature();
+ }
+
+ public EReference eContainmentFeature()
+ {
+ return getEObject().eContainmentFeature();
+ }
+
+ public EList<EObject> eContents()
+ {
+ return getEObject().eContents();
+ }
+
+ public EList<EObject> eCrossReferences()
+ {
+ return getEObject().eCrossReferences();
+ }
+
+ public boolean eDeliver()
+ {
+ return getEObject().eDeliver();
+ }
+
+ public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
+ {
+ return getEObject().eDerivedStructuralFeatureID(baseFeatureID, baseClass);
+ }
+
+ public Resource.Internal eDirectResource()
+ {
+ return getEObject().eDirectResource();
+ }
+
+ public Object eGet(EStructuralFeature feature, boolean resolve, boolean coreType)
+ {
+ return getEObject().eGet(feature, resolve, coreType);
+ }
+
+ public Object eGet(EStructuralFeature feature, boolean resolve)
+ {
+ return getEObject().eGet(feature, resolve);
+ }
+
+ public Object eGet(EStructuralFeature feature)
+ {
+ return getEObject().eGet(feature);
+ }
+
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ return getEObject().eGet(featureID, resolve, coreType);
+ }
+
+ public InternalEObject eInternalContainer()
+ {
+ return getEObject().eInternalContainer();
+ }
+
+ public Resource.Internal eInternalResource()
+ {
+ return getEObject().eInternalResource();
+ }
+
+ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class<?> baseClass,
+ NotificationChain notifications)
+ {
+ return getEObject().eInverseAdd(otherEnd, featureID, baseClass, notifications);
+ }
+
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class<?> baseClass,
+ NotificationChain notifications)
+ {
+ return getEObject().eInverseRemove(otherEnd, featureID, baseClass, notifications);
+ }
+
+ public boolean eIsProxy()
+ {
+ return getEObject().eIsProxy();
+ }
+
+ public boolean eIsSet(EStructuralFeature feature)
+ {
+ return getEObject().eIsSet(feature);
+ }
+
+ public boolean eIsSet(int featureID)
+ {
+ return getEObject().eIsSet(featureID);
+ }
+
+ public boolean eNotificationRequired()
+ {
+ return getEObject().eNotificationRequired();
+ }
+
+ public void eNotify(Notification notification)
+ {
+ getEObject().eNotify(notification);
+ }
+
+ public EObject eObjectForURIFragmentSegment(String uriFragmentSegment)
+ {
+ return getEObject().eObjectForURIFragmentSegment(uriFragmentSegment);
+ }
+
+ public URI eProxyURI()
+ {
+ return getEObject().eProxyURI();
+ }
+
+ public EObject eResolveProxy(InternalEObject proxy)
+ {
+ return getEObject().eResolveProxy(proxy);
+ }
+
+ public Resource eResource()
+ {
+ return getEObject().eResource();
+ }
+
+ public void eSet(EStructuralFeature feature, Object newValue)
+ {
+ getEObject().eSet(feature, newValue);
+ }
+
+ public void eSet(int featureID, Object newValue)
+ {
+ getEObject().eSet(featureID, newValue);
+ }
+
+ public void eSetClass(EClass class1)
+ {
+ getEObject().eSetClass(class1);
+ }
+
+ public void eSetDeliver(boolean deliver)
+ {
+ getEObject().eSetDeliver(deliver);
+ }
+
+ public void eSetProxyURI(URI uri)
+ {
+ getEObject().eSetProxyURI(uri);
+ }
+
+ public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications)
+ {
+ return getEObject().eSetResource(resource, notifications);
+ }
+
+ public void eSetStore(EStore store)
+ {
+ getEObject().eSetStore(store);
+ }
+
+ public Setting eSetting(EStructuralFeature feature)
+ {
+ return getEObject().eSetting(feature);
+ }
+
+ public EStore eStore()
+ {
+ return getEObject().eStore();
+ }
+
+ public void eUnset(EStructuralFeature feature)
+ {
+ getEObject().eUnset(feature);
+ }
+
+ public void eUnset(int featureID)
+ {
+ getEObject().eUnset(featureID);
+ }
+
+ public String eURIFragmentSegment(EStructuralFeature feature, EObject object)
+ {
+ return getEObject().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 f8dc7f0..37b9023 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
@@ -25,6 +25,8 @@ import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.emf.common.util.EList;
+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;
@@ -56,18 +58,6 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
eContainer = null;
}
- public CDOClassImpl cdoClass()
- {
- CDOViewImpl view = cdoView();
- if (view == null)
- {
- System.out.println(eClass());
- }
-
- CDOSessionPackageManager packageManager = view.getSession().getPackageManager();
- return ModelUtil.getCDOClass(eClass(), packageManager);
- }
-
public CDOID cdoID()
{
return id;
@@ -78,9 +68,19 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return state;
}
+ public CDORevisionImpl cdoRevision()
+ {
+ return revision;
+ }
+
+ public CDOClassImpl cdoClass()
+ {
+ return getCDOClass(this);
+ }
+
public CDOViewImpl cdoView()
{
- return resource != null ? resource.cdoView() : null;
+ return getCDOView(this);
}
public CDOResourceImpl cdoResource()
@@ -93,15 +93,9 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return resource;
}
- public CDORevisionImpl cdoRevision()
- {
- return revision;
- }
-
public boolean cdoTransient()
{
- final CDOState cdoState = cdoState();
- return cdoState == CDOState.TRANSIENT || cdoState == CDOState.PREPARED_ATTACH;
+ return isCDOTransient(this);
}
public void cdoInternalSetID(CDOID id)
@@ -132,6 +126,16 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
}
+ public void cdoInternalSetRevision(CDORevision revision)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting revision: {0}", revision);
+ }
+
+ this.revision = (CDORevisionImpl)revision;
+ }
+
public void cdoInternalSetView(CDOView view)
{
if (this instanceof CDOResourceImpl)
@@ -155,16 +159,17 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
this.resource = (CDOResourceImpl)resource;
}
- public void cdoInternalSetRevision(CDORevision revision)
+ public void cdoInternalFinalizeRevision()
{
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting revision: {0}", revision);
- }
+ finalizeCDORevision(this, eContainer, eContainerFeatureID, eSettings);
+ }
- this.revision = (CDORevisionImpl)revision;
+ public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
+ {
+ return eDynamicFeature(dynamicFeatureID);
}
+ @Deprecated
void initializeContainer(InternalEObject container, EStructuralFeature eContainingFeature)
{
eContainer = container;
@@ -205,80 +210,6 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
}
- public void cdoInternalFinalizeRevision()
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Finalizing revision for {0}", this);
- }
-
- CDOViewImpl view = cdoView();
- revision.setVersion(1);
- revision.setContainerID(eContainer == null ? CDOID.NULL : ((CDOObjectImpl)eContainer).cdoID());
- revision.setContainingFeature(eContainerFeatureID);
-
- if (eSettings != null)
- {
- for (int i = 0; i < eClass().getFeatureCount(); i++)
- {
- Object setting = eSettings[i];
- if (setting != null)
- {
- EStructuralFeature eFeature = eDynamicFeature(i);
- if (!eFeature.isTransient())
- {
- finalizeRevisionFeature(view, revision, i, setting, eFeature);
- }
- }
- }
- }
- }
-
- private void finalizeRevisionFeature(CDOViewImpl view, CDORevisionImpl revision, int i, Object setting,
- EStructuralFeature eFeature)
- {
- CDOFeatureImpl cdoFeature = ModelUtil.getCDOFeature(eFeature, cdoView().getSession().getPackageManager());
- if (TRACER.isEnabled())
- {
- TRACER.format("Finalizing feature {0}", cdoFeature);
- }
-
- boolean isReference = cdoFeature.isReference();
- if (cdoFeature.isMany())
- {
- int index = 0;
- EList<Object> list = (EList<Object>)setting;
- for (Object value : list)
- {
- if (isReference)
- {
- value = CDOStore.convertToID(view, value);
- }
-
- revision.add(cdoFeature, index++, value);
- }
- }
- else
- {
- if (isReference)
- {
- setting = CDOStore.convertToID(view, setting);
- }
-
- revision.set(cdoFeature, 0, setting);
- }
-
- if (eSettings != null)
- {
- eSettings[i] = null;
- }
- }
-
- public CDORevisionImpl cdoInternalCopyRevision()
- {
- return revision = new CDORevisionImpl(revision);
- }
-
@Override
protected void eInitializeContainer()
{
@@ -440,4 +371,95 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return eClass().getName() + "@" + id;
}
+
+ static CDOClassImpl getCDOClass(InternalCDOObject cdoObject)
+ {
+ CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
+ CDOSessionPackageManager packageManager = view.getSession().getPackageManager();
+ return ModelUtil.getCDOClass(cdoObject.eClass(), packageManager);
+ }
+
+ static CDOViewImpl getCDOView(InternalCDOObject cdoObject)
+ {
+ CDOResource resource = cdoObject.cdoResource();
+ return resource != null ? (CDOViewImpl)cdoObject.cdoResource().cdoView() : null;
+ }
+
+ static boolean isCDOTransient(InternalCDOObject cdoObject)
+ {
+ final CDOState cdoState = cdoObject.cdoState();
+ return cdoState == CDOState.TRANSIENT || cdoState == CDOState.PREPARED_ATTACH;
+ }
+
+ static void finalizeCDORevision(InternalCDOObject cdoObject, EObject eContainer, int eContainerFeatureID,
+ Object[] eSettings)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Finalizing revision for {0}", cdoObject);
+ }
+
+ CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
+ CDORevisionImpl revision = (CDORevisionImpl)cdoObject.cdoRevision();
+ revision.setVersion(1);
+ revision.setContainerID(eContainer == null ? CDOID.NULL : ((CDOObjectImpl)eContainer).cdoID());
+ revision.setContainingFeature(eContainerFeatureID);
+
+ if (eSettings != null)
+ {
+ EClass eClass = cdoObject.eClass();
+ for (int i = 0; i < eClass.getFeatureCount(); i++)
+ {
+ Object setting = eSettings[i];
+ if (setting != null)
+ {
+ EStructuralFeature eFeature = cdoObject.cdoInternalDynamicFeature(i);
+ if (!eFeature.isTransient())
+ {
+ finalizeRevisionFeature(view, revision, i, setting, eFeature, eSettings);
+ }
+ }
+ }
+ }
+ }
+
+ private static void finalizeRevisionFeature(CDOViewImpl view, CDORevisionImpl revision, int i, Object setting,
+ EStructuralFeature eFeature, Object[] eSettings)
+ {
+ CDOFeatureImpl cdoFeature = ModelUtil.getCDOFeature(eFeature, view.getSession().getPackageManager());
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Finalizing feature {0}", cdoFeature);
+ }
+
+ boolean isReference = cdoFeature.isReference();
+ if (cdoFeature.isMany())
+ {
+ int index = 0;
+ EList<Object> list = (EList<Object>)setting;
+ for (Object value : list)
+ {
+ if (isReference)
+ {
+ value = CDOStore.convertToID(view, value);
+ }
+
+ revision.add(cdoFeature, index++, value);
+ }
+ }
+ else
+ {
+ if (isReference)
+ {
+ setting = CDOStore.convertToID(view, setting);
+ }
+
+ revision.set(cdoFeature, 0, setting);
+ }
+
+ if (eSettings != null)
+ {
+ eSettings[i] = null;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index b45194d..09e29d8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -413,7 +413,9 @@ public final class CDOStateMachine
@Override
protected void doExecute(InternalCDOObject object, Event event, Object data1, Object data2)
{
- CDORevisionImpl revision = (CDORevisionImpl)object.cdoInternalCopyRevision();
+ // Copy revision
+ CDORevisionImpl revision = new CDORevisionImpl((CDORevisionImpl)object.cdoRevision());
+ object.cdoInternalSetRevision(revision);
revision.increaseVersion();
CDOViewImpl view = (CDOViewImpl)object.cdoView();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java
index 41b6f9b..6ff9ee3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java
@@ -17,10 +17,13 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+
/**
* @author Eike Stepper
*/
-public interface InternalCDOObject extends CDOObject
+public interface InternalCDOObject extends CDOObject, InternalEObject
{
public void cdoInternalSetID(CDOID id);
@@ -32,7 +35,7 @@ public interface InternalCDOObject extends CDOObject
public void cdoInternalSetRevision(CDORevision revision);
- public CDORevision cdoInternalCopyRevision();
-
public void cdoInternalFinalizeRevision();
+
+ public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID);
}