summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2012-10-30 10:04:56 (EDT)
committer Eike Stepper2012-10-30 13:12:54 (EDT)
commit0f758fa57b41a202f7336e0658c8f6b7e85527f8 (patch)
tree06eac351684c0f8e128070297ff7178653a2b888
parent6b6d28260f12b40eff4bb93d829d339c0c3fd0cb (diff)
downloadcdo-0f758fa57b41a202f7336e0658c8f6b7e85527f8.zip
cdo-0f758fa57b41a202f7336e0658c8f6b7e85527f8.tar.gz
cdo-0f758fa57b41a202f7336e0658c8f6b7e85527f8.tar.bz2
Support isLoading() in CDOResource for legacy models.
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java29
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOResource.java33
3 files changed, 77 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index ce3ee68..db04fb2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Simon McDuff - maintenance
+ * Christian W. Damus (CEA) - isLoading() support for CDOResource
*/
package org.eclipse.emf.cdo.eresource.impl;
@@ -65,6 +66,7 @@ import org.eclipse.emf.ecore.xmi.impl.XMIHelperImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDOResource;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
@@ -80,6 +82,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>CDO Resource</b></em>'.
@@ -103,7 +106,7 @@ import java.util.concurrent.Callable;
*
* @generated
*/
-public class CDOResourceImpl extends CDOResourceLeafImpl implements CDOResource, Resource.Internal
+public class CDOResourceImpl extends CDOResourceLeafImpl implements InternalCDOResource, Resource.Internal
{
private static final EReference CDO_RESOURCE_CONTENTS = EresourcePackage.eINSTANCE.getCDOResource_Contents();
@@ -168,6 +171,8 @@ public class CDOResourceImpl extends CDOResourceLeafImpl implements CDOResource,
*/
private transient Map<String, EObject> intrinsicIDToEObjectMap;
+ private transient AtomicInteger loadingCounter = new AtomicInteger();
+
/**
* @ADDED
* @since 2.0
@@ -1520,6 +1525,28 @@ public class CDOResourceImpl extends CDOResourceLeafImpl implements CDOResource,
}
/**
+ * @since 4.2
+ */
+ public void cdoInternalLoading(EObject object)
+ {
+ if (loadingCounter.incrementAndGet() == 1)
+ {
+ loading = true;
+ }
+ }
+
+ /**
+ * @since 4.2
+ */
+ public void cdoInternalDoneLoading(EObject object)
+ {
+ if (loadingCounter.decrementAndGet() == 0)
+ {
+ loading = false;
+ }
+ }
+
+ /**
* @ADDED
*/
public boolean isExisting()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 556cfa8..31df488 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Martin Fluegge - bug 247226: Transparently support legacy models
+ * Christian W. Damus (CEA) - isLoading() support for CDOResource
*/
package org.eclipse.emf.internal.cdo.object;
@@ -52,6 +53,7 @@ import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.spi.cdo.CDOStore;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDOResource;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.lang.reflect.Field;
@@ -392,12 +394,21 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
Counter counter = recursionCounter.get();
+ Resource resource = null;
+
try
{
registerWrapper(this);
counter.increment();
view.registerObject(this);
+ revisionToInstanceResource();
+ resource = instance.eDirectResource();
+ if (resource instanceof InternalCDOResource)
+ {
+ ((InternalCDOResource)resource).cdoInternalLoading(instance);
+ }
+
revisionToInstanceContainer();
EClass eClass = revision.getEClass();
@@ -406,8 +417,6 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
{
revisionToInstanceFeature(feature);
}
-
- revisionToInstanceResource();
}
catch (RuntimeException ex)
{
@@ -421,6 +430,11 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
}
finally
{
+ if (resource instanceof InternalCDOResource)
+ {
+ ((InternalCDOResource)resource).cdoInternalDoneLoading(instance);
+ }
+
if (deliver)
{
instance.eSetDeliver(true);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOResource.java
new file mode 100644
index 0000000..1d996be
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOResource.java
@@ -0,0 +1,33 @@
+/*
+ * 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:
+ * Christian W. Damus (CEA) - initial API and implementation
+ */
+package org.eclipse.emf.spi.cdo;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Internal protocol for the {@link CDOResource}.
+ *
+ * @since 4.2
+ */
+public interface InternalCDOResource extends CDOResource
+{
+ /**
+ * Informs the resource that an {@code object} contained within it is being loaded.
+ */
+ void cdoInternalLoading(EObject object);
+
+ /**
+ * Informs the resource that an {@code object} contained within it has finished being loaded.
+ */
+ void cdoInternalDoneLoading(EObject object);
+}