summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-21 06:04:00 (EDT)
committerEike Stepper2007-07-21 06:04:00 (EDT)
commitfaca69994df1ace5c58695a861d50e6db0d09069 (patch)
tree569866062447e3b68617110b5346bbab23941a59
parent006d349110cfa130fc1b371313c41907bab0c859 (diff)
downloadcdo-faca69994df1ace5c58695a861d50e6db0d09069.zip
cdo-faca69994df1ace5c58695a861d50e6db0d09069.tar.gz
cdo-faca69994df1ace5c58695a861d50e6db0d09069.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java39
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java56
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java41
5 files changed, 84 insertions, 76 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 37fa940..5eb6d18 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
@@ -663,17 +663,4 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
EList<Adapter> adapters = eObject.eAdapters();
return (CDOAdapterImpl)EcoreUtil.getAdapter(adapters, CDOAdapterImpl.class);
}
-
- public static CDOAdapterImpl getOrCreate(InternalEObject eObject)
- {
- EList<Adapter> adapters = eObject.eAdapters();
- CDOAdapterImpl adapter = (CDOAdapterImpl)EcoreUtil.getAdapter(adapters, CDOAdapterImpl.class);
- if (adapter == null)
- {
- adapter = new CDOAdapterImpl();
- adapters.add(adapter);
- }
-
- return adapter;
- }
}
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 8facd26..e07984e 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
@@ -42,11 +42,9 @@ public class CDOMetaImpl implements InternalCDOObject
private CDOID id;
- public CDOMetaImpl(CDOViewImpl view, InternalEObject metaInstance, CDOID id)
+ public CDOMetaImpl(InternalEObject metaInstance)
{
- this.view = view;
this.metaInstance = metaInstance;
- this.id = id;
}
public CDOViewImpl getView()
@@ -81,8 +79,7 @@ public class CDOMetaImpl implements InternalCDOObject
public CDOClass cdoClass()
{
- // TODO Implement method CDOMetaImpl.cdoClass()
- throw new UnsupportedOperationException("Not yet implemented");
+ throw new UnsupportedOperationException();
}
public CDOViewImpl cdoView()
@@ -97,7 +94,7 @@ public class CDOMetaImpl implements InternalCDOObject
public void cdoInternalSetID(CDOID id)
{
- throw new UnsupportedOperationException();
+ this.id = id;
}
public void cdoInternalSetState(CDOState state)
@@ -112,7 +109,7 @@ public class CDOMetaImpl implements InternalCDOObject
public void cdoInternalSetView(CDOView view)
{
- throw new UnsupportedOperationException();
+ this.view = (CDOViewImpl)view;
}
public void cdoInternalSetResource(CDOResource resource)
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 ebb226e..46d6c32 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
@@ -6,13 +6,20 @@ 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.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.ServerException;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest;
@@ -224,6 +231,34 @@ public final class CDOStateMachine
transition.execute(object, event, data1, data2);
}
+ public static InternalCDOObject adapt(Object object)
+ {
+ if (object instanceof InternalCDOObject)
+ {
+ return (InternalCDOObject)object;
+ }
+
+ if (object instanceof EModelElement || object instanceof EGenericType)
+ {
+ return new CDOMetaImpl((InternalEObject)object);
+ }
+
+ if (object instanceof InternalEObject)
+ {
+ EList<Adapter> adapters = ((InternalEObject)object).eAdapters();
+ CDOAdapterImpl adapter = (CDOAdapterImpl)EcoreUtil.getAdapter(adapters, CDOAdapterImpl.class);
+ if (adapter == null)
+ {
+ adapter = new CDOAdapterImpl();
+ adapters.add(adapter);
+ }
+
+ return adapter;
+ }
+
+ throw new ImplementationError("Neither InternalCDOObject nor InternalEObject: " + object.getClass().getName());
+ }
+
private static CDOTransactionImpl getTransaction(CDOViewImpl view)
{
CDOTransactionImpl transaction = view.getTransaction();
@@ -328,7 +363,7 @@ public final class CDOStateMachine
// Prepare content tree
for (EObject content : object.eContents())
{
- InternalCDOObject objectOrAdapter = CDOStore.getCDOObject(content);
+ InternalCDOObject objectOrAdapter = adapt(content);
INSTANCE.processEvent(objectOrAdapter, Event.ATTACH, resource, view);
}
}
@@ -348,7 +383,7 @@ public final class CDOStateMachine
// Prepare content tree
for (EObject content : object.eContents())
{
- InternalCDOObject objectOrAdapter = CDOStore.getCDOObject(content);
+ InternalCDOObject objectOrAdapter = adapt(content);
INSTANCE.processEvent(objectOrAdapter, Event.FINALIZE_ATTACH, null, null);
}
}
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 af15ab0..b01aaaf 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
@@ -13,7 +13,6 @@ package org.eclipse.emf.internal.cdo;
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.util.ImplementationError;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -41,7 +40,7 @@ public final class CDOStore implements EStore
public InternalEObject getContainer(InternalEObject eObject)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
if (TRACER.isEnabled())
{
TRACER.format("getContainer({0})", cdoObject);
@@ -54,7 +53,7 @@ public final class CDOStore implements EStore
public int getContainingFeatureID(InternalEObject eObject)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
if (TRACER.isEnabled())
{
TRACER.format("getContainingFeatureID({0})", cdoObject);
@@ -66,7 +65,7 @@ public final class CDOStore implements EStore
public void setContainer(InternalEObject eObject, InternalEObject newContainer, int newContainerFeatureID)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
if (TRACER.isEnabled())
{
TRACER.format("setContainer({0}, {1}, {2})", cdoObject, newContainer, newContainerFeatureID);
@@ -86,7 +85,7 @@ public final class CDOStore implements EStore
public Object get(InternalEObject eObject, EStructuralFeature eFeature, int index)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -105,7 +104,7 @@ public final class CDOStore implements EStore
public boolean isSet(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -118,7 +117,7 @@ public final class CDOStore implements EStore
public int size(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -131,7 +130,7 @@ public final class CDOStore implements EStore
public boolean isEmpty(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -144,7 +143,7 @@ public final class CDOStore implements EStore
public boolean contains(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -162,7 +161,7 @@ public final class CDOStore implements EStore
public int indexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -180,7 +179,7 @@ public final class CDOStore implements EStore
public int lastIndexOf(InternalEObject eObject, EStructuralFeature eFeature, Object value)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -198,7 +197,7 @@ public final class CDOStore implements EStore
public int hashCode(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -211,7 +210,7 @@ public final class CDOStore implements EStore
public Object[] toArray(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -239,7 +238,7 @@ public final class CDOStore implements EStore
public Object set(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -268,7 +267,7 @@ public final class CDOStore implements EStore
public void unset(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -281,7 +280,7 @@ public final class CDOStore implements EStore
public void add(InternalEObject eObject, EStructuralFeature eFeature, int index, Object value)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -304,7 +303,7 @@ public final class CDOStore implements EStore
public Object remove(InternalEObject eObject, EStructuralFeature eFeature, int index)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -323,7 +322,7 @@ public final class CDOStore implements EStore
public void clear(InternalEObject eObject, EStructuralFeature eFeature)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -336,7 +335,7 @@ public final class CDOStore implements EStore
public Object move(InternalEObject eObject, EStructuralFeature eFeature, int target, int source)
{
- InternalCDOObject cdoObject = getCDOObject(eObject);
+ InternalCDOObject cdoObject = CDOStateMachine.adapt(eObject);
CDOFeatureImpl cdoFeature = getCDOFeature(cdoObject, eFeature);
if (TRACER.isEnabled())
{
@@ -364,22 +363,7 @@ public final class CDOStore implements EStore
return "PersistentStore";
}
- public static InternalCDOObject getCDOObject(Object object)
- {
- if (object instanceof InternalCDOObject)
- {
- return (InternalCDOObject)object;
- }
-
- if (object instanceof InternalEObject)
- {
- return CDOAdapterImpl.getOrCreate((InternalEObject)object);
- }
-
- throw new ImplementationError("Neither InternalCDOObject nor InternalEObject: " + object.getClass().getName());
- }
-
- public static CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
+ private static CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
{
CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
if (view == null)
@@ -417,7 +401,7 @@ public final class CDOStore implements EStore
private static void handleContainmentAdd(InternalCDOObject cdoObject, CDOFeatureImpl cdoFeature, Object value)
{
InternalCDOObject container = cdoObject;
- InternalCDOObject contained = getCDOObject(value);
+ InternalCDOObject contained = CDOStateMachine.adapt(value);
CDOViewImpl containerView = (CDOViewImpl)container.cdoView();
CDOViewImpl containedView = (CDOViewImpl)contained.cdoView();
if (containedView != containerView)
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 794d5c8..769e525 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
@@ -232,29 +232,33 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
lastLookupObject = objects.get(id);
if (lastLookupObject == null)
{
- lastLookupObject = createInstance(id);
+ lastLookupObject = createObject(id);
registerObject(lastLookupObject);
}
return lastLookupObject;
}
- private InternalCDOObject createInstance(CDOID id)
+ private InternalCDOObject createObject(CDOID id)
{
- if (TRACER.isEnabled())
- {
- TRACER.format("Creating view instance: ID={0}", id);
- }
+ // if (id.isMeta())
+ // {
+ // if (TRACER.isEnabled())
+ // {
+ // TRACER.format("Creating meta: ID={0}", id);
+ // }
+ //
+ // InternalEObject metaInstance = session.lookupMetaInstance(id);
+ // if (metaInstance == null)
+ // {
+ // throw new IllegalArgumentException("No meta instance for " + id);
+ // }
+ //
+ // }
- if (id.isMeta())
+ if (TRACER.isEnabled())
{
- InternalEObject metaInstance = session.lookupMetaInstance(id);
- if (metaInstance == null)
- {
- throw new IllegalArgumentException("No meta instance for " + id);
- }
-
- return new CDOMetaImpl(this, metaInstance, id);
+ TRACER.format("Creating object: ID={0}", id);
}
CDORevisionImpl revision = lookupRevision(id);
@@ -292,7 +296,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return id;
}
- throw new ImplementationError("Not a CDOID: " + shouldBeCDOID);
+ throw new ImplementationError("Not a CDOID: " + shouldBeCDOID.getClass().getName());
}
public Object convertObjectToID(Object potentialObject)
@@ -305,12 +309,13 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
if (potentialObject instanceof InternalEObject && !(potentialObject instanceof InternalCDOObject))
{
InternalEObject eObject = (InternalEObject)potentialObject;
- CDOAdapterImpl adapter = CDOAdapterImpl.get(eObject);
- if (adapter == null)
+ CDOID id = session.lookupMetaInstanceID(eObject);
+ if (id != null)
{
- throw new ImplementationError("No adapter for " + eObject);
+ return id;
}
+ InternalCDOObject adapter = CDOStateMachine.adapt(eObject);
potentialObject = adapter;
}