summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-02 02:44:01 (EDT)
committerEike Stepper2007-08-02 02:44:01 (EDT)
commit44f167cfa13a1c4fa795f8e6f25941f2dfffae47 (patch)
treeb379b9038abd58f6139fdd4c1afedc4faa19f1d9
parent0e62d99f714fef2383ec6702cc3fdeb0a62f3bfd (diff)
downloadcdo-44f167cfa13a1c4fa795f8e6f25941f2dfffae47.zip
cdo-44f167cfa13a1c4fa795f8e6f25941f2dfffae47.tar.gz
cdo-44f167cfa13a1c4fa795f8e6f25941f2dfffae47.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java736
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java45
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java749
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java5
8 files changed, 805 insertions, 774 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 c50a975..13bf223 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
@@ -11,95 +11,43 @@
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.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
-import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.model.CDOType;
-import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.WrappedException;
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.Notifier;
-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.impl.BasicEObjectImpl;
-import org.eclipse.emf.ecore.impl.EAttributeImpl;
-import org.eclipse.emf.ecore.impl.EClassImpl;
-import org.eclipse.emf.ecore.impl.EDataTypeImpl;
-import org.eclipse.emf.ecore.impl.EReferenceImpl;
-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
-import org.eclipse.emf.ecore.impl.ETypedElementImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.util.GenUtil;
-import org.eclipse.emf.internal.cdo.util.ModelUtil;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.List;
/**
* @author Eike Stepper
*/
-public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
+public class CDOAdapterImpl extends CDOLegacyImpl implements Adapter.Internal
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOAdapterImpl.class);
- protected CDOViewImpl view;
-
- protected CDOID id;
-
- protected CDOState state;
-
- protected CDOResourceImpl resource;
-
- protected CDORevisionImpl revision;
-
public CDOAdapterImpl()
{
- state = CDOState.TRANSIENT;
}
- @Override
public boolean isAdapterForType(Object type)
{
- return type == CDOAdapterImpl.class || type == CDOCallbackImpl.class;
+ return type == CDOAdapterImpl.class;
}
- @Override
public InternalEObject getTarget()
{
- return (InternalEObject)super.getTarget();
+ return instance;
}
- @Override
public void setTarget(Notifier newTarget)
{
if (newTarget instanceof InternalEObject)
{
- super.setTarget(newTarget);
+ instance = (InternalEObject)newTarget;
}
else
{
@@ -107,12 +55,14 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
}
}
- @Override
public void unsetTarget(Notifier oldTarget)
{
if (oldTarget instanceof InternalEObject)
{
- super.unsetTarget(oldTarget);
+ if (instance == oldTarget)
+ {
+ instance = null;
+ }
}
else
{
@@ -120,7 +70,6 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
}
}
- @Override
public void notifyChanged(Notification msg)
{
switch (msg.getEventType())
@@ -133,685 +82,46 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
case Notification.SET:
case Notification.UNSET:
InternalEObject notifier = (InternalEObject)msg.getNotifier();
- if (notifier == getTarget() && !notifier.eIsProxy())
+ if (notifier == instance && !notifier.eIsProxy())
{
CDOStateMachine.INSTANCE.write(this);
}
}
}
- public CDOID cdoID()
- {
- return id;
- }
-
- public CDOState cdoState()
- {
- return state;
- }
-
- public CDORevisionImpl cdoRevision()
- {
- return revision;
- }
-
- public CDOResourceImpl cdoResource()
- {
- return resource;
- }
-
- public CDOClassImpl cdoClass()
- {
- return CDOObjectImpl.getCDOClass(this);
- }
-
- public CDOViewImpl cdoView()
- {
- if (view == null)
- {
- view = CDOObjectImpl.getCDOView(this);
- }
-
- return view;
- }
-
- public void cdoInternalSetID(CDOID id)
- {
- if (id == null)
- {
- throw new IllegalArgumentException("id == null");
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting ID: {0} for {1}", id, getTarget());
- }
-
- this.id = id;
- }
-
- public void cdoInternalSetState(CDOState state)
+ @Override
+ public CDOState cdoInternalSetState(CDOState state)
{
- if (this.state != state)
+ CDOState oldState = super.cdoInternalSetState(state);
+ if (oldState != state)
{
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting state {0} for {1}", state, this);
- }
-
- this.state = state;
- InternalEObject target = getTarget();
if (state == CDOState.PROXY)
{
- if (!target.eIsProxy())
+ if (!instance.eIsProxy())
{
URI uri = URI.createURI(CDOProtocolConstants.PROTOCOL_NAME + ":proxy#" + id);
- target.eSetProxyURI(uri);
- }
- }
- else
- {
- if (target.eIsProxy())
- {
- target.eSetProxyURI(null);
- }
- }
- }
- else
- {
- // TODO Detect duplicate setstate calls
- }
- }
-
- public void cdoInternalSetRevision(CDORevision revision)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting revision: {0}", revision);
- }
-
- this.revision = (CDORevisionImpl)revision;
- }
-
- public void cdoInternalSetView(CDOView view)
- {
- this.view = (CDOViewImpl)view;
- }
-
- public void cdoInternalSetResource(CDOResource resource)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting resource: {0}", resource);
- }
-
- this.resource = (CDOResourceImpl)resource;
- }
-
- public void cdoInternalPostLoad()
- {
- transferRevisionToTarget();
- cdoInternalSetState(CDOState.CLEAN);
- }
-
- public void cdoInternalPostAttach()
- {
- // Do nothing
- }
-
- public InternalEObject cdoInternalInstance()
- {
- return getTarget();
- }
-
- public void cdoInternalPreCommit()
- {
- transferTargetToRevision();
- }
-
- public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
- {
- // TODO Implement method CDOAdapterImpl.cdoInternalDynamicFeature()
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- @Override
- public String toString()
- {
- if (id == null)
- {
- return eClass().getName() + "?";
- }
-
- return eClass().getName() + "@" + id;
- }
-
- protected void transferTargetToRevision()
- {
- InternalEObject target = getTarget();
- CDOViewImpl view = cdoView();
- if (view == null)
- {
- throw new ImplementationError("view == null");
- }
-
- // Handle containment
- EObject container = target.eContainer();
- if (container != null)
- {
- if (container instanceof CDOResource)
- {
- revision.setResourceID(((CDOResource)container).cdoID());
- revision.setContainerID(CDOID.NULL);
- revision.setContainingFeature(0);
- }
- else
- {
- revision.setResourceID(CDOID.NULL);
- CDOID containerID = view.provideCDOID(container);
- if (containerID.isNull())
- {
- throw new ImplementationError("containerID.isNull()");
- }
-
- int containerFeatureID = target.eContainerFeatureID();// containER???
- revision.setContainerID(containerID);
- revision.setContainingFeature(containerFeatureID);
- }
- }
-
- // Handle values
- CDOClassImpl cdoClass = revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
- for (int i = 0; i < features.length; i++)
- {
- CDOFeatureImpl feature = features[i];
- Object targetValue = getTargetValue(target, feature);
- if (feature.isMany())
- {
- List revisionList = revision.getList(feature); // TODO lazy?
- revisionList.clear();
-
- if (targetValue != null)
- {
- if (targetValue instanceof InternalEList)
+ if (TRACER.isEnabled())
{
- InternalEList targetList = (InternalEList)targetValue;
- if (targetList != null)
- {
- for (Iterator it = targetList.basicIterator(); it.hasNext();)
- {
- Object targetElement = it.next();
- if (targetElement != null && feature.isReference())
- {
- targetElement = view.convertObjectToID(targetElement);
- }
-
- revisionList.add(targetElement);
- }
- }
- }
- else
- {
- throw new ImplementationError("Not an InternalEList: " + targetValue.getClass().getName());
+ TRACER.format("Setting proxyURI {0} for {1}", uri, instance);
}
+
+ instance.eSetProxyURI(uri);
}
}
else
{
- if (targetValue != null && feature.isReference())
+ if (instance.eIsProxy())
{
- targetValue = view.convertObjectToID(targetValue);
- }
-
- revision.setValue(feature, targetValue);
- }
- }
- }
-
- protected void transferRevisionToTarget()
- {
- InternalEObject target = getTarget();
- CDOViewImpl view = cdoView();
- if (view == null)
- {
- throw new ImplementationError("view == null");
- }
-
- // Handle containment
- CDOID containerID = revision.getContainerID();
- if (containerID.isNull())
- {
- CDOID resourceID = revision.getResourceID();
- Resource.Internal resource = (Resource.Internal)view.lookupInstance(resourceID);
- transferResourceToTarget((BasicEObjectImpl)target, resource);
- }
- else
- {
- int containingFeatureID = revision.getContainingFeatureID();
- InternalCDOObject container = view.lookupInstance(containerID);
- ((BasicEObjectImpl)target).eBasicSetContainer(container, containingFeatureID, null);
- }
-
- // Handle values
- CDOClassImpl cdoClass = revision.getCDOClass();
- CDOFeatureImpl[] features = cdoClass.getAllFeatures();
- for (int i = 0; i < features.length; i++)
- {
- CDOFeatureImpl feature = features[i];
- Object value = revision.getValue(feature);
- if (feature.isMany())
- {
- InternalEList targetList = (InternalEList)getTargetValue(target, feature);
- if (targetList != null)
- {
- while (!targetList.isEmpty())
+ if (TRACER.isEnabled())
{
- Object toBeRemoved = targetList.basicGet(0);
- targetList.basicRemove(toBeRemoved, null);
+ TRACER.format("Unsetting proxyURI for {1}", instance);
}
- List revisionList = (List)value;
- for (Object toBeAdded : revisionList)
- {
- if (feature.isReference())
- {
- toBeAdded = view.convertIDToObject(toBeAdded);
- }
-
- targetList.basicAdd(toBeAdded, null);
- }
- }
- }
- else
- {
- if (feature.isReference())
- {
- value = view.convertIDToObject(value);
+ instance.eSetProxyURI(null);
}
-
- setTargetValue(target, feature, value);
}
}
- }
-
- protected void transferResourceToTarget(BasicEObjectImpl target, Resource.Internal resource)
- {
- Method method = ReflectUtil.getMethod(BasicEObjectImpl.class, "eSetDirectResource", Resource.Internal.class);
-
- try
- {
- ReflectUtil.invokeMethod(method, target, resource);
- }
- catch (InvocationTargetException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- protected Object getTargetValue(InternalEObject target, CDOFeatureImpl feature)
- {
- // Class<?> targetClass = target.getClass();
- // String featureName = feature.getName();
- EStructuralFeature eFeature = ModelUtil.getEFeature(feature, cdoView().getSession().getPackageRegistry());
- Object value = target.eGet(eFeature);
- return value;
-
- // // TODO BOOLEAN_OBJECT?
- // String methodName = GenUtil.getFeatureGetterName(featureName,
- // feature.getType() == CDOType.BOOLEAN);
- // Method method = getMethod(targetClass, methodName,
- // ReflectUtil.NO_PARAMETERS);
- //
- // String fieldName = featureName;// XXX safeName()
- // Field field = getField(targetClass, fieldName);
- // if (field == null && feature.getType() == CDOType.BOOLEAN)
- // {
- // if (targetClass.isAssignableFrom(EAttributeImpl.class) ||
- // targetClass.isAssignableFrom(EClassImpl.class)
- // || targetClass.isAssignableFrom(EDataTypeImpl.class) ||
- // targetClass.isAssignableFrom(EReferenceImpl.class)
- // || targetClass.isAssignableFrom(EStructuralFeatureImpl.class)
- // || targetClass.isAssignableFrom(ETypedElementImpl.class))
- // {
- // // *******************************************
- // // ID_EFLAG = 1 << 15;
- // // *******************************************
- // // ABSTRACT_EFLAG = 1 << 8;
- // // INTERFACE_EFLAG = 1 << 9;
- // // *******************************************
- // // SERIALIZABLE_EFLAG = 1 << 8;
- // // *******************************************
- // // CONTAINMENT_EFLAG = 1 << 15;
- // // RESOLVE_PROXIES_EFLAG = 1 << 16;
- // // *******************************************
- // // CHANGEABLE_EFLAG = 1 << 10;
- // // VOLATILE_EFLAG = 1 << 11;
- // // TRANSIENT_EFLAG = 1 << 12;
- // // UNSETTABLE_EFLAG = 1 << 13;
- // // DERIVED_EFLAG = 1 << 14;
- // // *******************************************
- // // ORDERED_EFLAG = 1 << 8;
- // // UNIQUE_EFLAG = 1 << 9;
- // // *******************************************
- //
- // String flagName = GenUtil.getFeatureUpperName(featureName) + "_EFLAG";
- // int flagsMask = getEFlagMask(targetClass, flagName);
- //
- // field = getField(targetClass, "eFlags");
- // int value = (Integer)getFiedValue(target, field);
- // return new Boolean((value & flagsMask) != 0);
- // }
- // }
- //
- // if (field == null)
- // {
- // throw new ImplementationError("Field not found: " + fieldName);
- // }
- //
- // return getFiedValue(target, field);
- }
-
- protected void setTargetValue(InternalEObject target, CDOFeatureImpl feature, Object value)
- {
- Class<?> targetClass = target.getClass();
- String featureName = feature.getName();
- String fieldName = featureName;// XXX safeName()
- Field field = ReflectUtil.getField(targetClass, fieldName);
- if (field == null && feature.getType() == CDOType.BOOLEAN)
- {
- if (targetClass.isAssignableFrom(EAttributeImpl.class) || targetClass.isAssignableFrom(EClassImpl.class)
- || targetClass.isAssignableFrom(EDataTypeImpl.class) || targetClass.isAssignableFrom(EReferenceImpl.class)
- || targetClass.isAssignableFrom(EStructuralFeatureImpl.class)
- || targetClass.isAssignableFrom(ETypedElementImpl.class))
- {
- // *******************************************
- // ID_EFLAG = 1 << 15;
- // *******************************************
- // ABSTRACT_EFLAG = 1 << 8;
- // INTERFACE_EFLAG = 1 << 9;
- // *******************************************
- // SERIALIZABLE_EFLAG = 1 << 8;
- // *******************************************
- // CONTAINMENT_EFLAG = 1 << 15;
- // RESOLVE_PROXIES_EFLAG = 1 << 16;
- // *******************************************
- // CHANGEABLE_EFLAG = 1 << 10;
- // VOLATILE_EFLAG = 1 << 11;
- // TRANSIENT_EFLAG = 1 << 12;
- // UNSETTABLE_EFLAG = 1 << 13;
- // DERIVED_EFLAG = 1 << 14;
- // *******************************************
- // ORDERED_EFLAG = 1 << 8;
- // UNIQUE_EFLAG = 1 << 9;
- // *******************************************
-
- String flagName = GenUtil.getFeatureUpperName(featureName) + "_EFLAG";
- int flagsMask = getEFlagMask(targetClass, flagName);
-
- field = ReflectUtil.getField(targetClass, "eFlags");
- int flags = (Integer)ReflectUtil.getValue(field, target);
- boolean on = (Boolean)value;
- if (on)
- {
- flags |= flagsMask; // Add EFlag
- }
- else
- {
- flags &= ~flagsMask; // Remove EFlag
- }
-
- ReflectUtil.setValue(field, target, flags);
- return;
- }
- }
-
- if (field == null)
- {
- throw new ImplementationError("Field not found: " + fieldName);
- }
-
- ReflectUtil.setValue(field, target, value);
- }
-
- protected static int getEFlagMask(Class<?> targetClass, String flagName)
- {
- Field field = ReflectUtil.getField(targetClass, flagName);
- if (!field.isAccessible())
- {
- field.setAccessible(true);
- }
-
- try
- {
- return (Integer)field.get(null);
- }
- catch (IllegalAccessException ex)
- {
- throw new ImplementationError(ex);
- }
- }
-
- public EList<Adapter> eAdapters()
- {
- return getTarget().eAdapters();
- }
-
- public TreeIterator<EObject> eAllContents()
- {
- return getTarget().eAllContents();
- }
-
- public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
- {
- return getTarget().eBaseStructuralFeatureID(derivedFeatureID, baseClass);
- }
-
- public NotificationChain eBasicRemoveFromContainer(NotificationChain notifications)
- {
- return getTarget().eBasicRemoveFromContainer(notifications);
- }
-
- public NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID,
- NotificationChain notifications)
- {
- return getTarget().eBasicSetContainer(newContainer, newContainerFeatureID, notifications);
- }
-
- public EClass eClass()
- {
- return getTarget().eClass();
- }
-
- public EObject eContainer()
- {
- return getTarget().eContainer();
- }
-
- public int eContainerFeatureID()
- {
- return getTarget().eContainerFeatureID();
- }
-
- public EStructuralFeature eContainingFeature()
- {
- return getTarget().eContainingFeature();
- }
-
- public EReference eContainmentFeature()
- {
- return getTarget().eContainmentFeature();
- }
-
- public EList<EObject> eContents()
- {
- return getTarget().eContents();
- }
-
- public EList<EObject> eCrossReferences()
- {
- return getTarget().eCrossReferences();
- }
-
- public boolean eDeliver()
- {
- return getTarget().eDeliver();
- }
-
- public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
- {
- return getTarget().eDerivedStructuralFeatureID(baseFeatureID, baseClass);
- }
-
- public Resource.Internal eDirectResource()
- {
- return getTarget().eDirectResource();
- }
-
- public Object eGet(EStructuralFeature feature, boolean resolve, boolean coreType)
- {
- return getTarget().eGet(feature, resolve, coreType);
- }
-
- public Object eGet(EStructuralFeature feature, boolean resolve)
- {
- return getTarget().eGet(feature, resolve);
- }
-
- public Object eGet(EStructuralFeature feature)
- {
- return getTarget().eGet(feature);
- }
-
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- return getTarget().eGet(featureID, resolve, coreType);
- }
-
- public InternalEObject eInternalContainer()
- {
- return getTarget().eInternalContainer();
- }
-
- public Resource.Internal eInternalResource()
- {
- return getTarget().eInternalResource();
- }
-
- public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class<?> baseClass,
- NotificationChain notifications)
- {
- return getTarget().eInverseAdd(otherEnd, featureID, baseClass, notifications);
- }
-
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class<?> baseClass,
- NotificationChain notifications)
- {
- return getTarget().eInverseRemove(otherEnd, featureID, baseClass, notifications);
- }
-
- public boolean eIsProxy()
- {
- return getTarget().eIsProxy();
- }
-
- public boolean eIsSet(EStructuralFeature feature)
- {
- return getTarget().eIsSet(feature);
- }
-
- public boolean eIsSet(int featureID)
- {
- return getTarget().eIsSet(featureID);
- }
-
- public boolean eNotificationRequired()
- {
- return getTarget().eNotificationRequired();
- }
-
- public void eNotify(Notification notification)
- {
- getTarget().eNotify(notification);
- }
-
- public EObject eObjectForURIFragmentSegment(String uriFragmentSegment)
- {
- return getTarget().eObjectForURIFragmentSegment(uriFragmentSegment);
- }
-
- public URI eProxyURI()
- {
- return getTarget().eProxyURI();
- }
-
- public EObject eResolveProxy(InternalEObject proxy)
- {
- return getTarget().eResolveProxy(proxy);
- }
-
- public Resource eResource()
- {
- return getTarget().eResource();
- }
-
- public void eSet(EStructuralFeature feature, Object newValue)
- {
- getTarget().eSet(feature, newValue);
- }
-
- public void eSet(int featureID, Object newValue)
- {
- getTarget().eSet(featureID, newValue);
- }
-
- public void eSetClass(EClass class1)
- {
- getTarget().eSetClass(class1);
- }
-
- public void eSetDeliver(boolean deliver)
- {
- getTarget().eSetDeliver(deliver);
- }
-
- public void eSetProxyURI(URI uri)
- {
- getTarget().eSetProxyURI(uri);
- }
-
- public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications)
- {
- return getTarget().eSetResource(resource, notifications);
- }
-
- public void eSetStore(EStore store)
- {
- getTarget().eSetStore(store);
- }
-
- public Setting eSetting(EStructuralFeature feature)
- {
- return getTarget().eSetting(feature);
- }
-
- public EStore eStore()
- {
- return getTarget().eStore();
- }
-
- public void eUnset(EStructuralFeature feature)
- {
- getTarget().eUnset(feature);
- }
-
- public void eUnset(int featureID)
- {
- getTarget().eUnset(featureID);
- }
-
- public String eURIFragmentSegment(EStructuralFeature feature, EObject object)
- {
- return getTarget().eURIFragmentSegment(feature, object);
+ return oldState;
}
}
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 cafc5bf..df55561 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,26 +10,20 @@
**************************************************************************/
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.InternalEObject;
import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
-import org.eclipse.emf.internal.cdo.bundle.OM;
/**
* TODO Check if deriving from CDOAdapterImpl is necessary
*
* @author Eike Stepper
*/
-public class CDOCallbackImpl extends CDOAdapterImpl implements CDOCallback
+public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOCallbackImpl.class);
-
- public CDOCallbackImpl()
+ public CDOCallbackImpl(InternalEObject instance)
{
+ this.instance = instance;
}
public void beforeRead(EObjectImpl instance)
@@ -41,35 +35,4 @@ 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
- }
- }
-
- @Override
- public void cdoInternalPostLoad()
- {
- transferRevisionToTarget();
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
new file mode 100644
index 0000000..8722e1e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
@@ -0,0 +1,749 @@
+/***************************************************************************
+ * 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.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.model.CDOType;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.util.WrappedException;
+
+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.impl.BasicEObjectImpl;
+import org.eclipse.emf.ecore.impl.EAttributeImpl;
+import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.impl.EDataTypeImpl;
+import org.eclipse.emf.ecore.impl.EReferenceImpl;
+import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
+import org.eclipse.emf.ecore.impl.ETypedElementImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.util.GenUtil;
+import org.eclipse.emf.internal.cdo.util.ModelUtil;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class CDOLegacyImpl implements InternalCDOObject
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyImpl.class);
+
+ protected CDOViewImpl view;
+
+ protected CDOID id;
+
+ protected CDOState state;
+
+ protected CDOResourceImpl resource;
+
+ protected CDORevisionImpl revision;
+
+ protected InternalEObject instance;
+
+ public CDOLegacyImpl()
+ {
+ state = CDOState.TRANSIENT;
+ }
+
+ public CDOID cdoID()
+ {
+ return id;
+ }
+
+ public CDOState cdoState()
+ {
+ return state;
+ }
+
+ public CDORevisionImpl cdoRevision()
+ {
+ return revision;
+ }
+
+ public CDOResourceImpl cdoResource()
+ {
+ return resource;
+ }
+
+ public CDOClassImpl cdoClass()
+ {
+ return CDOObjectImpl.getCDOClass(this);
+ }
+
+ public CDOViewImpl cdoView()
+ {
+ if (view == null)
+ {
+ view = CDOObjectImpl.getCDOView(this);
+ }
+
+ return view;
+ }
+
+ public void cdoInternalSetID(CDOID id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("id == null");
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting ID: {0} for {1}", id, instance);
+ }
+
+ this.id = id;
+ }
+
+ public CDOState cdoInternalSetState(CDOState state)
+ {
+ if (this.state != state)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting state {0} for {1}", state, this);
+ }
+
+ try
+ {
+ return this.state;
+ }
+ finally
+ {
+ this.state = state;
+ }
+ }
+ else
+ {
+ // TODO Detect duplicate cdoInternalSetState() calls
+ return null;
+ }
+ }
+
+ public void cdoInternalSetRevision(CDORevision revision)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting revision: {0}", revision);
+ }
+
+ this.revision = (CDORevisionImpl)revision;
+ }
+
+ public void cdoInternalSetView(CDOView view)
+ {
+ this.view = (CDOViewImpl)view;
+ }
+
+ public void cdoInternalSetResource(CDOResource resource)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting resource: {0}", resource);
+ }
+
+ this.resource = (CDOResourceImpl)resource;
+ }
+
+ public InternalEObject cdoInternalInstance()
+ {
+ return instance;
+ }
+
+ public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
+ {
+ // TODO Implement method CDOAdapterImpl.cdoInternalDynamicFeature()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public void cdoInternalPostAttach()
+ {
+ // Do nothing
+ }
+
+ public void cdoInternalPreCommit()
+ {
+ transferInstanceToRevision();
+ }
+
+ public void cdoInternalPostLoad()
+ {
+ transferRevisionToInstance();
+ cdoInternalSetState(CDOState.CLEAN);
+ }
+
+ @Override
+ public String toString()
+ {
+ if (id == null)
+ {
+ return eClass().getName() + "?";
+ }
+
+ return eClass().getName() + "@" + id;
+ }
+
+ protected void transferInstanceToRevision()
+ {
+ CDOViewImpl view = cdoView();
+ if (view == null)
+ {
+ throw new ImplementationError("view == null");
+ }
+
+ // Handle containment
+ EObject container = instance.eContainer();
+ if (container != null)
+ {
+ if (container instanceof CDOResource)
+ {
+ revision.setResourceID(((CDOResource)container).cdoID());
+ revision.setContainerID(CDOID.NULL);
+ revision.setContainingFeature(0);
+ }
+ else
+ {
+ revision.setResourceID(CDOID.NULL);
+ CDOID containerID = view.provideCDOID(container);
+ if (containerID.isNull())
+ {
+ throw new ImplementationError("containerID.isNull()");
+ }
+
+ int containerFeatureID = instance.eContainerFeatureID();// containER???
+ revision.setContainerID(containerID);
+ revision.setContainingFeature(containerFeatureID);
+ }
+ }
+
+ // Handle values
+ CDOClassImpl cdoClass = revision.getCDOClass();
+ CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ for (int i = 0; i < features.length; i++)
+ {
+ CDOFeatureImpl feature = features[i];
+ Object instanceValue = getInstanceValue(instance, feature);
+ if (feature.isMany())
+ {
+ List revisionList = revision.getList(feature); // TODO lazy?
+ revisionList.clear();
+
+ if (instanceValue != null)
+ {
+ if (instanceValue instanceof InternalEList)
+ {
+ InternalEList instanceList = (InternalEList)instanceValue;
+ if (instanceList != null)
+ {
+ for (Iterator it = instanceList.basicIterator(); it.hasNext();)
+ {
+ Object instanceElement = it.next();
+ if (instanceElement != null && feature.isReference())
+ {
+ instanceElement = view.convertObjectToID(instanceElement);
+ }
+
+ revisionList.add(instanceElement);
+ }
+ }
+ }
+ else
+ {
+ throw new ImplementationError("Not an InternalEList: " + instanceValue.getClass().getName());
+ }
+ }
+ }
+ else
+ {
+ if (instanceValue != null && feature.isReference())
+ {
+ instanceValue = view.convertObjectToID(instanceValue);
+ }
+
+ revision.setValue(feature, instanceValue);
+ }
+ }
+ }
+
+ protected void transferRevisionToInstance()
+ {
+ CDOViewImpl view = cdoView();
+ if (view == null)
+ {
+ throw new ImplementationError("view == null");
+ }
+
+ // Handle containment
+ CDOID containerID = revision.getContainerID();
+ if (containerID.isNull())
+ {
+ CDOID resourceID = revision.getResourceID();
+ Resource.Internal resource = (Resource.Internal)view.lookupInstance(resourceID);
+ transferResourceToInstance((BasicEObjectImpl)instance, resource);
+ }
+ else
+ {
+ int containingFeatureID = revision.getContainingFeatureID();
+ InternalCDOObject container = view.lookupInstance(containerID);
+ ((BasicEObjectImpl)instance).eBasicSetContainer(container, containingFeatureID, null);
+ }
+
+ // Handle values
+ CDOClassImpl cdoClass = revision.getCDOClass();
+ CDOFeatureImpl[] features = cdoClass.getAllFeatures();
+ for (int i = 0; i < features.length; i++)
+ {
+ CDOFeatureImpl feature = features[i];
+ Object value = revision.getValue(feature);
+ if (feature.isMany())
+ {
+ InternalEList instanceList = (InternalEList)getInstanceValue(instance, feature);
+ if (instanceList != null)
+ {
+ while (!instanceList.isEmpty())
+ {
+ Object toBeRemoved = instanceList.basicGet(0);
+ instanceList.basicRemove(toBeRemoved, null);
+ }
+
+ List revisionList = (List)value;
+ for (Object toBeAdded : revisionList)
+ {
+ if (feature.isReference())
+ {
+ toBeAdded = view.convertIDToObject(toBeAdded);
+ }
+
+ instanceList.basicAdd(toBeAdded, null);
+ }
+ }
+ }
+ else
+ {
+ if (feature.isReference())
+ {
+ value = view.convertIDToObject(value);
+ }
+
+ setInstanceValue(instance, feature, value);
+ }
+ }
+ }
+
+ protected void transferResourceToInstance(BasicEObjectImpl instance, Resource.Internal resource)
+ {
+ Method method = ReflectUtil.getMethod(BasicEObjectImpl.class, "eSetDirectResource", Resource.Internal.class);
+
+ try
+ {
+ ReflectUtil.invokeMethod(method, instance, resource);
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ protected Object getInstanceValue(InternalEObject instance, CDOFeatureImpl feature)
+ {
+ // Class<?> targetClass = target.getClass();
+ // String featureName = feature.getName();
+ EStructuralFeature eFeature = ModelUtil.getEFeature(feature, cdoView().getSession().getPackageRegistry());
+ Object value = instance.eGet(eFeature);
+ return value;
+
+ // // TODO BOOLEAN_OBJECT?
+ // String methodName = GenUtil.getFeatureGetterName(featureName,
+ // feature.getType() == CDOType.BOOLEAN);
+ // Method method = getMethod(targetClass, methodName,
+ // ReflectUtil.NO_PARAMETERS);
+ //
+ // String fieldName = featureName;// XXX safeName()
+ // Field field = getField(targetClass, fieldName);
+ // if (field == null && feature.getType() == CDOType.BOOLEAN)
+ // {
+ // if (targetClass.isAssignableFrom(EAttributeImpl.class) ||
+ // targetClass.isAssignableFrom(EClassImpl.class)
+ // || targetClass.isAssignableFrom(EDataTypeImpl.class) ||
+ // targetClass.isAssignableFrom(EReferenceImpl.class)
+ // || targetClass.isAssignableFrom(EStructuralFeatureImpl.class)
+ // || targetClass.isAssignableFrom(ETypedElementImpl.class))
+ // {
+ // // *******************************************
+ // // ID_EFLAG = 1 << 15;
+ // // *******************************************
+ // // ABSTRACT_EFLAG = 1 << 8;
+ // // INTERFACE_EFLAG = 1 << 9;
+ // // *******************************************
+ // // SERIALIZABLE_EFLAG = 1 << 8;
+ // // *******************************************
+ // // CONTAINMENT_EFLAG = 1 << 15;
+ // // RESOLVE_PROXIES_EFLAG = 1 << 16;
+ // // *******************************************
+ // // CHANGEABLE_EFLAG = 1 << 10;
+ // // VOLATILE_EFLAG = 1 << 11;
+ // // TRANSIENT_EFLAG = 1 << 12;
+ // // UNSETTABLE_EFLAG = 1 << 13;
+ // // DERIVED_EFLAG = 1 << 14;
+ // // *******************************************
+ // // ORDERED_EFLAG = 1 << 8;
+ // // UNIQUE_EFLAG = 1 << 9;
+ // // *******************************************
+ //
+ // String flagName = GenUtil.getFeatureUpperName(featureName) + "_EFLAG";
+ // int flagsMask = getEFlagMask(targetClass, flagName);
+ //
+ // field = getField(targetClass, "eFlags");
+ // int value = (Integer)getFiedValue(target, field);
+ // return new Boolean((value & flagsMask) != 0);
+ // }
+ // }
+ //
+ // if (field == null)
+ // {
+ // throw new ImplementationError("Field not found: " + fieldName);
+ // }
+ //
+ // return getFiedValue(target, field);
+ }
+
+ protected void setInstanceValue(InternalEObject instance, CDOFeatureImpl feature, Object value)
+ {
+ Class<?> instanceClass = instance.getClass();
+ String featureName = feature.getName();
+ String fieldName = featureName;// XXX safeName()
+ Field field = ReflectUtil.getField(instanceClass, fieldName);
+ if (field == null && feature.getType() == CDOType.BOOLEAN)
+ {
+ if (instanceClass.isAssignableFrom(EAttributeImpl.class) || instanceClass.isAssignableFrom(EClassImpl.class)
+ || instanceClass.isAssignableFrom(EDataTypeImpl.class)
+ || instanceClass.isAssignableFrom(EReferenceImpl.class)
+ || instanceClass.isAssignableFrom(EStructuralFeatureImpl.class)
+ || instanceClass.isAssignableFrom(ETypedElementImpl.class))
+ {
+ // *******************************************
+ // ID_EFLAG = 1 << 15;
+ // *******************************************
+ // ABSTRACT_EFLAG = 1 << 8;
+ // INTERFACE_EFLAG = 1 << 9;
+ // *******************************************
+ // SERIALIZABLE_EFLAG = 1 << 8;
+ // *******************************************
+ // CONTAINMENT_EFLAG = 1 << 15;
+ // RESOLVE_PROXIES_EFLAG = 1 << 16;
+ // *******************************************
+ // CHANGEABLE_EFLAG = 1 << 10;
+ // VOLATILE_EFLAG = 1 << 11;
+ // TRANSIENT_EFLAG = 1 << 12;
+ // UNSETTABLE_EFLAG = 1 << 13;
+ // DERIVED_EFLAG = 1 << 14;
+ // *******************************************
+ // ORDERED_EFLAG = 1 << 8;
+ // UNIQUE_EFLAG = 1 << 9;
+ // *******************************************
+
+ String flagName = GenUtil.getFeatureUpperName(featureName) + "_EFLAG";
+ int flagsMask = getEFlagMask(instanceClass, flagName);
+
+ field = ReflectUtil.getField(instanceClass, "eFlags");
+ int flags = (Integer)ReflectUtil.getValue(field, instance);
+ boolean on = (Boolean)value;
+ if (on)
+ {
+ flags |= flagsMask; // Add EFlag
+ }
+ else
+ {
+ flags &= ~flagsMask; // Remove EFlag
+ }
+
+ ReflectUtil.setValue(field, instance, flags);
+ return;
+ }
+ }
+
+ if (field == null)
+ {
+ throw new ImplementationError("Field not found: " + fieldName);
+ }
+
+ ReflectUtil.setValue(field, instance, value);
+ }
+
+ protected static int getEFlagMask(Class<?> instanceClass, String flagName)
+ {
+ Field field = ReflectUtil.getField(instanceClass, flagName);
+ if (!field.isAccessible())
+ {
+ field.setAccessible(true);
+ }
+
+ try
+ {
+ return (Integer)field.get(null);
+ }
+ catch (IllegalAccessException ex)
+ {
+ throw new ImplementationError(ex);
+ }
+ }
+
+ public EList<Adapter> eAdapters()
+ {
+ return instance.eAdapters();
+ }
+
+ public TreeIterator<EObject> eAllContents()
+ {
+ return instance.eAllContents();
+ }
+
+ public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
+ {
+ return instance.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
+ }
+
+ public NotificationChain eBasicRemoveFromContainer(NotificationChain notifications)
+ {
+ return instance.eBasicRemoveFromContainer(notifications);
+ }
+
+ public NotificationChain eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID,
+ NotificationChain notifications)
+ {
+ return instance.eBasicSetContainer(newContainer, newContainerFeatureID, notifications);
+ }
+
+ public EClass eClass()
+ {
+ return instance.eClass();
+ }
+
+ public EObject eContainer()
+ {
+ return instance.eContainer();
+ }
+
+ public int eContainerFeatureID()
+ {
+ return instance.eContainerFeatureID();
+ }
+
+ public EStructuralFeature eContainingFeature()
+ {
+ return instance.eContainingFeature();
+ }
+
+ public EReference eContainmentFeature()
+ {
+ return instance.eContainmentFeature();
+ }
+
+ public EList<EObject> eContents()
+ {
+ return instance.eContents();
+ }
+
+ public EList<EObject> eCrossReferences()
+ {
+ return instance.eCrossReferences();
+ }
+
+ public boolean eDeliver()
+ {
+ return instance.eDeliver();
+ }
+
+ public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass)
+ {
+ return instance.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
+ }
+
+ public Resource.Internal eDirectResource()
+ {
+ return instance.eDirectResource();
+ }
+
+ public Object eGet(EStructuralFeature feature, boolean resolve, boolean coreType)
+ {
+ return instance.eGet(feature, resolve, coreType);
+ }
+
+ public Object eGet(EStructuralFeature feature, boolean resolve)
+ {
+ return instance.eGet(feature, resolve);
+ }
+
+ public Object eGet(EStructuralFeature feature)
+ {
+ return instance.eGet(feature);
+ }
+
+ public Object eGet(int featureID, boolean resolve, boolean coreType)
+ {
+ return instance.eGet(featureID, resolve, coreType);
+ }
+
+ public InternalEObject eInternalContainer()
+ {
+ return instance.eInternalContainer();
+ }
+
+ public Resource.Internal eInternalResource()
+ {
+ return instance.eInternalResource();
+ }
+
+ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class<?> baseClass,
+ NotificationChain notifications)
+ {
+ return instance.eInverseAdd(otherEnd, featureID, baseClass, notifications);
+ }
+
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class<?> baseClass,
+ NotificationChain notifications)
+ {
+ return instance.eInverseRemove(otherEnd, featureID, baseClass, notifications);
+ }
+
+ public boolean eIsProxy()
+ {
+ return instance.eIsProxy();
+ }
+
+ public boolean eIsSet(EStructuralFeature feature)
+ {
+ return instance.eIsSet(feature);
+ }
+
+ public boolean eIsSet(int featureID)
+ {
+ return instance.eIsSet(featureID);
+ }
+
+ public boolean eNotificationRequired()
+ {
+ return instance.eNotificationRequired();
+ }
+
+ public void eNotify(Notification notification)
+ {
+ instance.eNotify(notification);
+ }
+
+ public EObject eObjectForURIFragmentSegment(String uriFragmentSegment)
+ {
+ return instance.eObjectForURIFragmentSegment(uriFragmentSegment);
+ }
+
+ public URI eProxyURI()
+ {
+ return instance.eProxyURI();
+ }
+
+ public EObject eResolveProxy(InternalEObject proxy)
+ {
+ return instance.eResolveProxy(proxy);
+ }
+
+ public Resource eResource()
+ {
+ return instance.eResource();
+ }
+
+ public void eSet(EStructuralFeature feature, Object newValue)
+ {
+ instance.eSet(feature, newValue);
+ }
+
+ public void eSet(int featureID, Object newValue)
+ {
+ instance.eSet(featureID, newValue);
+ }
+
+ public void eSetClass(EClass class1)
+ {
+ instance.eSetClass(class1);
+ }
+
+ public void eSetDeliver(boolean deliver)
+ {
+ instance.eSetDeliver(deliver);
+ }
+
+ public void eSetProxyURI(URI uri)
+ {
+ instance.eSetProxyURI(uri);
+ }
+
+ public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications)
+ {
+ return instance.eSetResource(resource, notifications);
+ }
+
+ public void eSetStore(EStore store)
+ {
+ instance.eSetStore(store);
+ }
+
+ public Setting eSetting(EStructuralFeature feature)
+ {
+ return instance.eSetting(feature);
+ }
+
+ public EStore eStore()
+ {
+ return instance.eStore();
+ }
+
+ public void eUnset(EStructuralFeature feature)
+ {
+ instance.eUnset(feature);
+ }
+
+ public void eUnset(int featureID)
+ {
+ instance.eUnset(featureID);
+ }
+
+ public String eURIFragmentSegment(EStructuralFeature feature, EObject object)
+ {
+ return instance.eURIFragmentSegment(feature, object);
+ }
+}
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
index 72d536d..299e70a 100644
--- 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
@@ -99,7 +99,7 @@ public class CDOMetaImpl implements InternalCDOObject
this.id = id;
}
- public void cdoInternalSetState(CDOState state)
+ public CDOState cdoInternalSetState(CDOState state)
{
throw new UnsupportedOperationException();
}
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 b13f892..1696fbc 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
@@ -119,7 +119,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
this.id = id;
}
- public void cdoInternalSetState(CDOState state)
+ public CDOState cdoInternalSetState(CDOState state)
{
if (this.state != state)
{
@@ -128,7 +128,19 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
TRACER.format("Setting state {0} for {1}", state, this);
}
- this.state = state;
+ try
+ {
+ return this.state;
+ }
+ finally
+ {
+ this.state = state;
+ }
+ }
+ else
+ {
+ // TODO Detect duplicate cdoInternalSetState() calls
+ return null;
}
}
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 23004ba..33f8ea2 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
@@ -25,21 +25,21 @@ import org.eclipse.emf.ecore.InternalEObject;
*/
public interface InternalCDOObject extends CDOObject, InternalEObject
{
+ public void cdoInternalPostLoad();
+
+ public void cdoInternalPostAttach();
+
+ public void cdoInternalPreCommit();
+
public void cdoInternalSetID(CDOID id);
public void cdoInternalSetResource(CDOResource resource);
public void cdoInternalSetView(CDOView view);
- public void cdoInternalSetState(CDOState state);
-
public void cdoInternalSetRevision(CDORevision revision);
- public void cdoInternalPostLoad();
-
- public void cdoInternalPostAttach();
-
- public void cdoInternalPreCommit();
+ public CDOState cdoInternalSetState(CDOState state);
public InternalEObject cdoInternalInstance();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index 8a6b31d..aaba0d0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -88,17 +88,13 @@ public final class FSMUtil
{
CDOAware aware = (CDOAware)object;
CDOCallback callback = aware.getCDOCallback();
- if (callback != null)
+ if (callback == null)
{
- return (InternalCDOObject)callback;
+ callback = new CDOCallbackImpl((InternalEObject)aware);
+ aware.setCDOCallback(callback);
}
- CDOCallbackImpl callbackAdapter = new CDOCallbackImpl();
- aware.setCDOCallback(callbackAdapter);
-
- EList<Adapter> adapters = ((InternalEObject)object).eAdapters();
- adapters.add(callbackAdapter);
- return callbackAdapter;
+ return (InternalCDOObject)callback;
}
}
catch (Throwable t)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
index 6675ed9..1034dee 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
@@ -51,11 +51,12 @@ final class ProxyResolverResource implements Resource
InternalCDOObject object = view.lookupInstance(id);
if (object instanceof CDOCallbackImpl)
{
- CDOCallbackImpl callbackAdapter = (CDOCallbackImpl)object;
- return callbackAdapter.getTarget();
+ CDOCallbackImpl callback = (CDOCallbackImpl)object;
+ return callback.cdoInternalInstance();
}
else if (object instanceof CDOAdapterImpl)
{
+ // TODO Move this somehow to cdoInternalPostLoad()
CDOAdapterImpl adapter = (CDOAdapterImpl)object;
if (adapter.cdoState() == CDOState.PROXY)
{