summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-02 14:11:50 (EDT)
committerEike Stepper2007-09-02 14:11:50 (EDT)
commit5368723bff0dab3646e52200b739a3d7a622cb55 (patch)
tree6a5b4e43470c7534b1fde0b5fb856888361bbe4f
parent309091f31d3b97192d71bdeebaab71b31492069b (diff)
downloadcdo-5368723bff0dab3646e52200b739a3d7a622cb55.zip
cdo-5368723bff0dab3646e52200b739a3d7a622cb55.tar.gz
cdo-5368723bff0dab3646e52200b739a3d7a622cb55.tar.bz2
[201997] Support EMF notification for invalidation of objects
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201997
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOInvalidationNotification.java22
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOInvalidationNotificationImpl.java178
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java36
4 files changed, 240 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOInvalidationNotification.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOInvalidationNotification.java
new file mode 100644
index 0000000..e2ff82f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOInvalidationNotification.java
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ **************************************************************************/
+package org.eclipse.emf.cdo;
+
+import org.eclipse.emf.common.notify.Notification;
+
+/**
+ * @author Simon McDuff
+ */
+public interface CDOInvalidationNotification extends Notification
+{
+ public static final int INVALIDATE = EVENT_TYPE_COUNT + 1;
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index e0e08a2..0c0f5d0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Simon McDuff - EMF invalidation notifications
**************************************************************************/
package org.eclipse.emf.cdo;
@@ -36,6 +37,10 @@ public interface CDOView extends INotifier
public boolean isDirty();
+ public boolean isEnableInvalidationNotifications();
+
+ public void setEnableInvalidationNotifications(boolean on);
+
/**
* @see ResourceSet#getResource(URI, boolean)
*/
@@ -45,6 +50,8 @@ public interface CDOView extends INotifier
public CDORevision getRevision(CDOID id);
+ public boolean isObjectRegistered(CDOID id);
+
public void close();
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOInvalidationNotificationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOInvalidationNotificationImpl.java
new file mode 100644
index 0000000..e13e84c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOInvalidationNotificationImpl.java
@@ -0,0 +1,178 @@
+/***************************************************************************
+ * 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ **************************************************************************/
+package org.eclipse.emf.internal.cdo;
+
+import org.eclipse.emf.cdo.CDOInvalidationNotification;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOInvalidationNotificationImpl implements CDOInvalidationNotification
+{
+ private EObject eObject;
+
+ public CDOInvalidationNotificationImpl(EObject eObject)
+ {
+ this.eObject = eObject;
+ }
+
+ public Object getNotifier()
+ {
+ return eObject;
+ }
+
+ public int getEventType()
+ {
+ return INVALIDATE;
+ }
+
+ public Object getFeature()
+ {
+ return null;
+ }
+
+ public int getFeatureID(Class<?> expectedClass)
+ {
+ return NO_FEATURE_ID;
+ }
+
+ public int getPosition()
+ {
+ return NO_INDEX;
+ }
+
+ public boolean wasSet()
+ {
+ // TODO Clarify return value or throw UOE
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isReset()
+ {
+ // TODO Clarify return value or throw UOE
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isTouch()
+ {
+ // TODO Clarify return value or throw UOE
+ return false;
+ }
+
+ public boolean merge(Notification notification)
+ {
+ // TODO Clarify return value or throw UOE
+ return false;
+ }
+
+ public boolean getNewBooleanValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getNewByteValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public char getNewCharValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getNewDoubleValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public float getNewFloatValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNewIntValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getNewLongValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public short getNewShortValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNewStringValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getNewValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getOldBooleanValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getOldByteValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public char getOldCharValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getOldDoubleValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public float getOldFloatValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getOldIntValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getOldLongValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public short getOldShortValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getOldStringValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getOldValue()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
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 619a036..8ef8291 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Simon McDuff - EMF invalidation notifications
**************************************************************************/
package org.eclipse.emf.internal.cdo;
@@ -50,7 +51,9 @@ import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,6 +71,8 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
private ResourceSet resourceSet;
+ private boolean enableInvalidationNotifications;
+
private Map<CDOID, InternalCDOObject> objects = new HashMap<CDOID, InternalCDOObject>();
private CDOStore store = new CDOStore(this);
@@ -112,6 +117,16 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return false;
}
+ public boolean isEnableInvalidationNotifications()
+ {
+ return enableInvalidationNotifications;
+ }
+
+ public void setEnableInvalidationNotifications(boolean on)
+ {
+ this.enableInvalidationNotifications = on;
+ }
+
public CDOTransactionImpl toTransaction()
{
if (this instanceof CDOTransactionImpl)
@@ -512,12 +527,27 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
*/
public void notifyInvalidation(long timeStamp, Set<CDOID> dirtyOIDs)
{
+ List<InternalCDOObject> dirtyObjects = enableInvalidationNotifications ? new ArrayList<InternalCDOObject>() : null;
for (CDOID dirtyOID : dirtyOIDs)
{
- InternalCDOObject object = objects.get(dirtyOID);
- if (object != null)
+ InternalCDOObject dirtyObject = objects.get(dirtyOID);
+ if (dirtyObject != null)
+ {
+ CDOStateMachine.INSTANCE.invalidate(dirtyObject, timeStamp);
+
+ if (dirtyObjects != null && dirtyObject.eNotificationRequired())
+ {
+ dirtyObjects.add(dirtyObject);
+ }
+ }
+ }
+
+ if (dirtyObjects != null)
+ {
+ for (InternalCDOObject dirtyObject : dirtyObjects)
{
- CDOStateMachine.INSTANCE.invalidate(object, timeStamp);
+ CDOInvalidationNotificationImpl notification = new CDOInvalidationNotificationImpl(dirtyObject);
+ dirtyObject.eNotify(notification);
}
}
}