diff options
author | Eike Stepper | 2008-09-14 08:54:01 +0000 |
---|---|---|
committer | Eike Stepper | 2008-09-14 08:54:01 +0000 |
commit | a9cc66560b66f8ad34e02d420d5da50600e3a0cf (patch) | |
tree | 94ec8752cdfc20a1ca2cf93e455ba3e623b87c65 | |
parent | aa99f9da75d255f23a6ab39ef7a391c96b5ea0ce (diff) | |
download | cdo-a9cc66560b66f8ad34e02d420d5da50600e3a0cf.tar.gz cdo-a9cc66560b66f8ad34e02d420d5da50600e3a0cf.tar.xz cdo-a9cc66560b66f8ad34e02d420d5da50600e3a0cf.zip |
[247141] Create a lazy self-adaptable adapter for CDOObject
https://bugs.eclipse.org/bugs/show_bug.cgi?id=247141
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java | 59 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java | 4 |
2 files changed, 63 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java index 8b948f0d7c..782f32ddc6 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InvalidationTest.java @@ -27,11 +27,16 @@ import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.net4j.util.event.IEvent; import org.eclipse.net4j.util.event.IListener; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -658,6 +663,7 @@ public class InvalidationTest extends AbstractCDOTest msg("Attaching viewB"); final CDOView viewB = sessionB.openTransaction(); + viewB.setInvalidationNotificationsEnabled(true); msg("Loading resource"); final CDOResource resourceB = viewB.getResource("/test1"); @@ -665,6 +671,8 @@ public class InvalidationTest extends AbstractCDOTest EList<EObject> contents = resourceB.getContents(); final Category categoryB = (Category)contents.get(0); + final TestAdapter testAdapter = new TestAdapter(); + categoryB.eAdapters().add(testAdapter); // ************************************************************* // @@ -678,13 +686,64 @@ public class InvalidationTest extends AbstractCDOTest } }; + ITimeOuter timeOuterNotification = new PollingTimeOuter(20, 100) + { + @Override + protected boolean successful() + { + return testAdapter.getNotifications().size() == 1; + } + }; + msg("Checking before commit"); assertEquals(true, timeOuter.timedOut()); + assertEquals(0, testAdapter.getNotifications().size()); msg("Committing"); transaction.commit(); msg("Checking after commit"); assertEquals(false, timeOuter.timedOut()); + assertEquals(false, timeOuterNotification.timedOut()); + + } + + /** + * @author Simon McDuff + */ + private static class TestAdapter implements Adapter + { + private List<Notification> notifications = new ArrayList<Notification>(); + + private Notifier notifier; + + public TestAdapter() + { + } + + public Notifier getTarget() + { + return notifier; + } + + public List<Notification> getNotifications() + { + return notifications; + } + + public boolean isAdapterForType(Object type) + { + return false; + } + + public void notifyChanged(Notification notification) + { + notifications.add(notification); + } + + public void setTarget(Notifier newTarget) + { + notifier = newTarget; + } } } 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 cb024dbb5e..1720de7c9b 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 @@ -791,6 +791,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement if (cdoObject != null) { CDOStateMachine.INSTANCE.invalidate(cdoObject, true, timeStamp); + if (dirtyObjects != null && cdoObject.eNotificationRequired()) + { + dirtyObjects.add(cdoObject); + } } } |