Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-10-01 09:23:35 +0000
committerEike Stepper2012-10-01 09:23:35 +0000
commit2f059db9c19fe63f6b551730b664d453ba09b967 (patch)
treef687f395fd4e4d3300ea508789aabfb43e52494b
parent6ed4654283170b6857405a5e2bb894ddff6b543b (diff)
downloadcdo-2f059db9c19fe63f6b551730b664d453ba09b967.tar.gz
cdo-2f059db9c19fe63f6b551730b664d453ba09b967.tar.xz
cdo-2f059db9c19fe63f6b551730b664d453ba09b967.zip
[390804] Support external targets in CDOView.queryXRefs()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=390804
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java67
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java455
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java480
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java1
10 files changed, 652 insertions, 490 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
index a13172dc2f..df69730c63 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
@@ -136,6 +136,38 @@ public class ExternalReferenceManager extends Lifecycle
}
}
+ public long lookupByURI(IDBStoreAccessor accessor, String uri)
+ {
+ IPreparedStatementCache statementCache = accessor.getStatementCache();
+ PreparedStatement stmt = null;
+ ResultSet resultSet = null;
+
+ try
+ {
+ stmt = statementCache.getPreparedStatement(sqlSelectByURI, ReuseProbability.HIGH);
+ stmt.setString(1, uri);
+
+ resultSet = stmt.executeQuery();
+
+ if (resultSet.next())
+ {
+ return resultSet.getLong(1);
+ }
+
+ // Not found ...
+ return NULL;
+ }
+ catch (SQLException e)
+ {
+ throw new DBException(e);
+ }
+ finally
+ {
+ DBUtil.close(resultSet);
+ statementCache.releasePreparedStatement(stmt);
+ }
+ }
+
public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
throws IOException
{
@@ -257,38 +289,6 @@ public class ExternalReferenceManager extends Lifecycle
}
}
- private long lookupByURI(IDBStoreAccessor accessor, String uri)
- {
- IPreparedStatementCache statementCache = accessor.getStatementCache();
- PreparedStatement stmt = null;
- ResultSet resultSet = null;
-
- try
- {
- stmt = statementCache.getPreparedStatement(sqlSelectByURI, ReuseProbability.HIGH);
- stmt.setString(1, uri);
-
- resultSet = stmt.executeQuery();
-
- if (resultSet.next())
- {
- return resultSet.getLong(1);
- }
-
- // Not found ...
- return NULL;
- }
- catch (SQLException e)
- {
- throw new DBException(e);
- }
- finally
- {
- DBUtil.close(resultSet);
- statementCache.releasePreparedStatement(stmt);
- }
- }
-
private static IDBStoreAccessor getAccessor()
{
IStoreAccessor accessor = StoreThreadLocal.getAccessor();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
index 6901988385..d1e363683a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
@@ -150,7 +150,18 @@ public class LongIDHandler extends Lifecycle implements IIDHandler
public void appendCDOID(StringBuilder builder, CDOID id)
{
- long value = value(id);
+ long value;
+ if (id != null && id.isExternal())
+ {
+ IDBStoreAccessor accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor();
+ String uri = CDOIDUtil.getString(id);
+ value = externalReferenceManager.lookupByURI(accessor, uri);
+ }
+ else
+ {
+ value = value(id);
+ }
+
builder.append(value);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
index 53d8fc339c..fac589ad6a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
@@ -239,7 +239,16 @@ public class XRefsQueryHandler implements IQueryHandler
while (tokenizer.hasMoreTokens())
{
String val = tokenizer.nextToken();
- CDOID id = store.createObjectID(val);
+
+ CDOID id;
+ if (val.startsWith("e"))
+ {
+ id = CDOIDUtil.createExternal(val.substring(1));
+ }
+ else
+ {
+ id = store.createObjectID(val.substring(1));
+ }
CDOClassifierRef classifierRef;
if (id instanceof CDOClassifierRef.Provider)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
index d60da05eaa..c0f2c4ef7a 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ExternalReferenceTest.java
@@ -11,6 +11,8 @@
*/
package org.eclipse.emf.cdo.tests;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOObjectReference;
import org.eclipse.emf.cdo.common.id.CDOIDExternal;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
@@ -51,6 +53,7 @@ import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.util.List;
import java.util.Map;
/**
@@ -58,7 +61,7 @@ import java.util.Map;
*/
public class ExternalReferenceTest extends AbstractCDOTest
{
- final static public String REPOSITORY_B_NAME = "repo2";
+ private static final String REPOSITORY_B_NAME = "repo2";
@CleanRepositoriesBefore
public void testExternalWithDynamicEObject() throws Exception
@@ -88,7 +91,6 @@ public class ExternalReferenceTest extends AbstractCDOTest
resA.getContents().add(objectFromResA);
transactionA1.commit();
-
}
public void testExternalWithEClass() throws Exception
@@ -147,6 +149,7 @@ public class ExternalReferenceTest extends AbstractCDOTest
}
clearCache(getRepository().getRevisionManager());
+
{
CDOSession sessionA = openSession();
@@ -488,6 +491,35 @@ public class ExternalReferenceTest extends AbstractCDOTest
}
}
+ @CleanRepositoriesBefore
+ public void testXRefExternalObject() throws Exception
+ {
+ skipStoreWithoutExternalReferences();
+
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Map<String, Object> map = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
+ map.put("xml", new XMLResourceFactoryImpl());
+
+ PurchaseOrder externalObject = getModel1Factory().createPurchaseOrder();
+ Resource externalResource = resourceSet.createResource(URI.createFileURI("/com/foo/bar.xml"));
+ externalResource.getContents().add(externalObject);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction(resourceSet);
+
+ Supplier supplier = getModel1Factory().createSupplier();
+ supplier.getPurchaseOrders().add(externalObject);
+
+ CDOResource resource = transaction.createResource(getResourcePath("/internal"));
+ resource.getContents().add(supplier);
+ transaction.commit();
+
+ CDOObject wrapper = CDOUtil.wrapExternalObject(externalObject, transaction);
+ List<CDOObjectReference> xRefs = transaction.queryXRefs(wrapper);
+ assertEquals(1, xRefs.size());
+ assertEquals(supplier, xRefs.get(0).getSourceObject());
+ }
+
private EPackage createDynamicEPackage()
{
final EcoreFactory eFactory = EcoreFactory.eINSTANCE;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 2e187cb81e..8319c1b802 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -36,6 +36,7 @@ import org.eclipse.emf.internal.cdo.analyzer.CDOFeatureAnalyzerUI;
import org.eclipse.emf.internal.cdo.analyzer.CDOFetchRuleManagerThreadLocal;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.messages.Messages;
+import org.eclipse.emf.internal.cdo.object.CDOExternalObject;
import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl;
import org.eclipse.emf.internal.cdo.object.CDOObjectWrapper;
import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl;
@@ -409,6 +410,14 @@ public final class CDOUtil
}
/**
+ * @since 4.2
+ */
+ public static CDOObject wrapExternalObject(EObject object, CDOView view)
+ {
+ return new CDOExternalObject((InternalEObject)object, (InternalCDOView)view);
+ }
+
+ /**
* @since 2.0
*/
public static EObject getEObject(EObject object)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
index 9ddac0ef4c..50f003e91c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
@@ -288,12 +288,14 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
*
* @param targetObject
* The target object that referencing objects are requested for.
+ * An external target object can be used with the help of {@link CDOUtil#wrapExternalObject(EObject, CDOView) CDOUtil.wrapExternalObject()}.
* @param sourceReferences
* The reference features that referencing objects are requested for, or an empty array if all reference
* features are to be used in the request.
* @since 4.0
* @see CDOView#queryXRefs(Set, EReference...)
* @see CDOView#queryXRefsAsync(Set, EReference...)
+ * @see CDOUtil#wrapExternalObject(EObject, CDOView)
*/
public List<CDOObjectReference> queryXRefs(CDOObject targetObject, EReference... sourceReferences);
@@ -303,12 +305,14 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
*
* @param targetObjects
* The set of target objects that referencing objects are requested for.
+ * External target objects can be used with the help of {@link CDOUtil#wrapExternalObject(EObject, CDOView) CDOUtil.wrapExternalObject()}.
* @param sourceReferences
* The reference features that referencing objects are requested for, or an empty array if all reference
* features are to be used in the request.
* @since 3.0
* @see CDOView#queryXRefs(CDOObject, EReference...)
* @see CDOView#queryXRefsAsync(Set, EReference...)
+ * @see CDOUtil#wrapExternalObject(EObject, CDOView)
*/
public List<CDOObjectReference> queryXRefs(Set<CDOObject> targetObjects, EReference... sourceReferences);
@@ -318,12 +322,14 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
*
* @param targetObjects
* The set of target objects that referencing objects are requested for.
+ * External target objects can be used with the help of {@link CDOUtil#wrapExternalObject(EObject, CDOView) CDOUtil.wrapExternalObject()}.
* @param sourceReferences
* The reference features that referencing objects are requested for, or an empty array if all reference
* features are to be used in the request.
* @since 3.0
* @see CDOView#queryXRefs(CDOObject, EReference...)
* @see CDOView#queryXRefs(Set, EReference...)
+ * @see CDOUtil#wrapExternalObject(EObject, CDOView)
*/
public CloseableIterator<CDOObjectReference> queryXRefsAsync(Set<CDOObject> targetObjects,
EReference... sourceReferences);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java
new file mode 100644
index 0000000000..7d806b4c2f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOExternalObject.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.object;
+
+import org.eclipse.emf.cdo.CDOLock;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOExternalObject extends CDOObjectWrapperBase
+{
+ public CDOExternalObject(InternalEObject instance, InternalCDOView view)
+ {
+ this.instance = instance;
+ this.view = view;
+ id = view.provideCDOID(instance);
+ }
+
+ public CDOState cdoState()
+ {
+ return CDOState.CLEAN;
+ }
+
+ public CDORevision cdoRevision()
+ {
+ return null;
+ }
+
+ public CDOLock cdoReadLock()
+ {
+ return null;
+ }
+
+ public CDOLock cdoWriteLock()
+ {
+ return null;
+ }
+
+ public CDOLock cdoWriteOption()
+ {
+ return null;
+ }
+
+ public CDOLockState cdoLockState()
+ {
+ return null;
+ }
+
+ public void cdoReload()
+ {
+ // Do nothing
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
index bd0b7819c7..f99e4f68a6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
@@ -11,173 +11,24 @@
package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOLock;
-import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
-import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
-import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.net4j.util.ReflectUtil;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.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.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.EOperation;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
/**
* @author Eike Stepper
* @since 2.0
*/
-public abstract class CDOObjectWrapper implements InternalCDOObject
+public abstract class CDOObjectWrapper extends CDOObjectWrapperBase implements InternalCDOObject
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectWrapper.class);
-
- protected CDOID id;
-
- protected InternalCDOView view;
-
- protected InternalEObject instance;
-
public CDOObjectWrapper()
{
}
- public CDOID cdoID()
- {
- return id;
- }
-
- public InternalCDOView cdoView()
- {
- return view;
- }
-
- public CDOResourceImpl cdoResource()
- {
- Resource resource = eResource();
- if (resource instanceof CDOResourceImpl)
- {
- return (CDOResourceImpl)resource;
- }
-
- return null;
- }
-
- /**
- * @since 2.0
- */
- public CDOResourceImpl cdoDirectResource()
- {
- Resource.Internal resource = eDirectResource();
- if (resource instanceof CDOResourceImpl)
- {
- return (CDOResourceImpl)resource;
- }
-
- return null;
- }
-
- public void cdoInternalSetID(CDOID id)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting ID: {0} for {1}", id, instance); //$NON-NLS-1$
- }
-
- this.id = id;
- }
-
- public void cdoInternalSetView(CDOView view)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Setting view: {0} for {1}", view, instance); //$NON-NLS-1$
- }
-
- this.view = (InternalCDOView)view;
- }
-
- public InternalEObject cdoInternalInstance()
- {
- return instance;
- }
-
- /**
- * @since 2.0
- */
- public boolean cdoConflict()
- {
- return FSMUtil.isConflict(this);
- }
-
- /**
- * @since 2.0
- */
- public boolean cdoInvalid()
- {
- return FSMUtil.isInvalid(this);
- }
-
- /**
- * @since 3.0
- */
- public void cdoPrefetch(int depth)
- {
- view.prefetchRevisions(id, depth);
- }
-
- public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
- {
- return eDynamicFeature(dynamicFeatureID);
- }
-
- /**
- * @since 3.0
- */
- protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
- {
- return eClass().getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount());
- }
-
- /**
- * @since 3.0
- */
- protected int eStaticFeatureCount()
- {
- return eStaticClass().getFeatureCount();
- }
-
- /**
- * @since 3.0
- */
- protected final EClass eStaticClass()
- {
- return EcorePackage.eINSTANCE.getEObject();
- }
-
/**
* @since 2.0
*/
@@ -206,308 +57,4 @@ public abstract class CDOObjectWrapper implements InternalCDOObject
{
return CDOObjectImpl.getLockState(this);
}
-
- public Resource.Internal getInstanceResource(InternalEObject instance)
- {
- return instance.eDirectResource();
- }
-
- public InternalEObject getInstanceContainer(InternalEObject instance)
- {
- return instance.eInternalContainer();
- }
-
- public int getInstanceContainerFeatureID(InternalEObject instance)
- {
- return instance.eContainerFeatureID();
- }
-
- public Object getInstanceValue(InternalEObject instance, EStructuralFeature feature)
- {
- return instance.eGet(feature);
- }
-
- public boolean isSetInstanceValue(InternalEObject instance, EStructuralFeature feature)
- {
- // Single-valued features that need special handling
- if (feature == EMFUtil.ETYPED_ELEMENT_EGENERIC_TYPE || feature == EMFUtil.ECLASSIFIER_INSTANCE_TYPE_NAME)
- {
- return getInstanceValue(instance, feature) != null;
- }
-
- // Many-valued features that need special handling
- if (feature == EMFUtil.ECLASS_EGENERIC_SUPER_TYPES || feature == EMFUtil.EOPERATION_EGENERIC_EXCEPTIONS)
- {
- return !((List<?>)getInstanceValue(instance, feature)).isEmpty();
- }
-
- return instance.eIsSet(feature);
- }
-
- public void setInstanceResource(Resource.Internal resource)
- {
- Method method = ReflectUtil.getMethod(instance.getClass(), "eSetDirectResource", Resource.Internal.class); //$NON-NLS-1$
- ReflectUtil.invokeMethod(method, instance, resource);
- }
-
- public void setInstanceContainer(InternalEObject container, int containerFeatureID)
- {
- Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$
- ReflectUtil.invokeMethod(method, instance, container, containerFeatureID);
- }
-
- public void setInstanceValue(InternalEObject instance, EStructuralFeature feature, Object value)
- {
- instance.eSet(feature, value);
- }
-
- 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);
- }
-
- /**
- * @since 3.0
- */
- public int eDerivedOperationID(int baseOperationID, Class<?> baseClass)
- {
- // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
- return instance.eDerivedOperationID(baseOperationID, baseClass);
- }
-
- /**
- * @since 3.0
- */
- public Object eInvoke(EOperation operation, EList<?> arguments) throws InvocationTargetException
- {
- // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
- return instance.eInvoke(operation, arguments);
- }
-
- /**
- * @since 3.0
- */
- public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
- {
- // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
- return instance.eInvoke(operationID, arguments);
- }
-
- 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/object/CDOObjectWrapperBase.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
new file mode 100644
index 0000000000..167d8e8fd1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
@@ -0,0 +1,480 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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.object;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.bundle.OM;
+
+import org.eclipse.net4j.util.ReflectUtil;
+import org.eclipse.net4j.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.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.EOperation;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.spi.cdo.FSMUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public abstract class CDOObjectWrapperBase implements CDOObject, InternalEObject
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectWrapperBase.class);
+
+ protected CDOID id;
+
+ protected InternalCDOView view;
+
+ protected InternalEObject instance;
+
+ public CDOObjectWrapperBase()
+ {
+ }
+
+ public CDOID cdoID()
+ {
+ return id;
+ }
+
+ public InternalCDOView cdoView()
+ {
+ return view;
+ }
+
+ public CDOResourceImpl cdoResource()
+ {
+ Resource resource = eResource();
+ if (resource instanceof CDOResourceImpl)
+ {
+ return (CDOResourceImpl)resource;
+ }
+
+ return null;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public CDOResourceImpl cdoDirectResource()
+ {
+ Resource.Internal resource = eDirectResource();
+ if (resource instanceof CDOResourceImpl)
+ {
+ return (CDOResourceImpl)resource;
+ }
+
+ return null;
+ }
+
+ public void cdoInternalSetID(CDOID id)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting ID: {0} for {1}", id, instance); //$NON-NLS-1$
+ }
+
+ this.id = id;
+ }
+
+ public void cdoInternalSetView(CDOView view)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Setting view: {0} for {1}", view, instance); //$NON-NLS-1$
+ }
+
+ this.view = (InternalCDOView)view;
+ }
+
+ public InternalEObject cdoInternalInstance()
+ {
+ return instance;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public boolean cdoConflict()
+ {
+ return FSMUtil.isConflict(this);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public boolean cdoInvalid()
+ {
+ return FSMUtil.isInvalid(this);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void cdoPrefetch(int depth)
+ {
+ view.prefetchRevisions(id, depth);
+ }
+
+ public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
+ {
+ return eDynamicFeature(dynamicFeatureID);
+ }
+
+ /**
+ * @since 3.0
+ */
+ protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
+ {
+ return eClass().getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount());
+ }
+
+ /**
+ * @since 3.0
+ */
+ protected int eStaticFeatureCount()
+ {
+ return eStaticClass().getFeatureCount();
+ }
+
+ /**
+ * @since 3.0
+ */
+ protected final EClass eStaticClass()
+ {
+ return EcorePackage.eINSTANCE.getEObject();
+ }
+
+ public Resource.Internal getInstanceResource(InternalEObject instance)
+ {
+ return instance.eDirectResource();
+ }
+
+ public InternalEObject getInstanceContainer(InternalEObject instance)
+ {
+ return instance.eInternalContainer();
+ }
+
+ public int getInstanceContainerFeatureID(InternalEObject instance)
+ {
+ return instance.eContainerFeatureID();
+ }
+
+ public Object getInstanceValue(InternalEObject instance, EStructuralFeature feature)
+ {
+ return instance.eGet(feature);
+ }
+
+ public boolean isSetInstanceValue(InternalEObject instance, EStructuralFeature feature)
+ {
+ // Single-valued features that need special handling
+ if (feature == EMFUtil.ETYPED_ELEMENT_EGENERIC_TYPE || feature == EMFUtil.ECLASSIFIER_INSTANCE_TYPE_NAME)
+ {
+ return getInstanceValue(instance, feature) != null;
+ }
+
+ // Many-valued features that need special handling
+ if (feature == EMFUtil.ECLASS_EGENERIC_SUPER_TYPES || feature == EMFUtil.EOPERATION_EGENERIC_EXCEPTIONS)
+ {
+ return !((List<?>)getInstanceValue(instance, feature)).isEmpty();
+ }
+
+ return instance.eIsSet(feature);
+ }
+
+ public void setInstanceResource(Resource.Internal resource)
+ {
+ Method method = ReflectUtil.getMethod(instance.getClass(), "eSetDirectResource", Resource.Internal.class); //$NON-NLS-1$
+ ReflectUtil.invokeMethod(method, instance, resource);
+ }
+
+ public void setInstanceContainer(InternalEObject container, int containerFeatureID)
+ {
+ Method method = ReflectUtil.getMethod(instance.getClass(), "eBasicSetContainer", InternalEObject.class, int.class); //$NON-NLS-1$
+ ReflectUtil.invokeMethod(method, instance, container, containerFeatureID);
+ }
+
+ public void setInstanceValue(InternalEObject instance, EStructuralFeature feature, Object value)
+ {
+ instance.eSet(feature, value);
+ }
+
+ 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);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public int eDerivedOperationID(int baseOperationID, Class<?> baseClass)
+ {
+ // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
+ return instance.eDerivedOperationID(baseOperationID, baseClass);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public Object eInvoke(EOperation operation, EList<?> arguments) throws InvocationTargetException
+ {
+ // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
+ return instance.eInvoke(operation, arguments);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
+ {
+ // Note: This causes a compiler error with EMF < 2.6M4!!! Ignore it or update your target platform.
+ return instance.eInvoke(operationID, arguments);
+ }
+
+ 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/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index d2e9db50c6..72ba4f18f6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -724,6 +724,7 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
builder.append("|");
}
+ builder.append(id.isExternal() ? "e" : "i");
builder.append(id.toURIFragment());
if (!(id instanceof CDOClassifierRef.Provider))

Back to the top