r6975 - in dumbhippo/trunk/server/src/com/dumbhippo/dm: . schema
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r6975 - in dumbhippo/trunk/server/src/com/dumbhippo/dm: . schema
- Date: Wed, 5 Dec 2007 15:26:23 -0600 (CST)
Author: otaylor
Date: 2007-12-05 15:26:23 -0600 (Wed, 05 Dec 2007)
New Revision: 6975
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotification.java
dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotificationSet.java
dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMPropertyHolder.java
Log:
Revert cleanup in earlier patch that broke the serializability of ChangeNotificationSet
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotification.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotification.java 2007-12-05 21:24:52 UTC (rev 6974)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotification.java 2007-12-05 21:26:23 UTC (rev 6975)
@@ -12,6 +12,10 @@
/**
* ChangeNotification represents pending notifications for a single resource.
*
+ * Note that this class must be serializable, because we send it over JMS when
+ * broadcasting changes. That's why we store Class<T> rather than DMClassHolder<K,T>,
+ * even though it means we have to look up the DMClassHolder each time.
+ *
* @param <K>
* @param <T>
*/
@@ -20,20 +24,20 @@
private static Logger logger = GlobalSetup.getLogger(ChangeNotification.class);
- private DMClassHolder<K, T> classHolder;
+ private Class<T> clazz;
private K key;
private long propertyMask; // bitset
private ClientMatcher matcher;
+
+ private long[] feedTimestamps;
- private long feedTimestamps[];
-
- public ChangeNotification(DMClassHolder<K,T> classHolder, K key) {
- this.classHolder = classHolder;
+ public ChangeNotification(Class<T> clazz, K key) {
+ this.clazz = clazz;
this.key = key;
}
- public ChangeNotification(DMClassHolder<K,T> classHolder, K key, ClientMatcher matcher) {
- this.classHolder = classHolder;
+ public ChangeNotification(Class<T> clazz, K key, ClientMatcher matcher) {
+ this.clazz = clazz;
this.key = key;
this.matcher = matcher;
}
@@ -42,7 +46,10 @@
this.propertyMask |= 1 << propertyIndex;
}
- public void addProperty(String propertyName) {
+ public void addProperty(DataModel model, String propertyName) {
+ @SuppressWarnings("unchecked")
+ DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
+
int propertyIndex = classHolder.getPropertyIndex(propertyName);
if (propertyIndex < 0)
throw new RuntimeException("Class " + classHolder.getBaseClass().getName() + " has no property " + propertyName);
@@ -54,7 +61,10 @@
addProperty(propertyIndex);
}
- public void addFeedProperty(String propertyName, long itemTimestamp) {
+ public void addFeedProperty(DataModel model, String propertyName, long itemTimestamp) {
+ @SuppressWarnings("unchecked")
+ DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
+
int propertyIndex = classHolder.getPropertyIndex(propertyName);
if (propertyIndex < 0)
throw new RuntimeException("Class " + classHolder.getBaseClass().getName() + " has no property " + propertyName);
@@ -78,6 +88,9 @@
}
public void invalidate(DataModel model, long timestamp) {
+ @SuppressWarnings("unchecked")
+ DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
+
long v = propertyMask;
int propertyIndex = 0;
while (v != 0) {
@@ -102,6 +115,9 @@
}
public void resolveNotifications(DataModel model, ClientNotificationSet result) {
+ @SuppressWarnings("unchecked")
+ DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
+
model.getStore().resolveNotifications(classHolder, key, propertyMask, result, matcher);
}
@@ -112,16 +128,16 @@
ChangeNotification<?,?> other = (ChangeNotification<?,?>)o;
- return classHolder == other.classHolder && key.equals(other.key);
+ return clazz == other.clazz && key.equals(other.key);
}
@Override
public int hashCode() {
- return 11 * classHolder.hashCode() + 17 * key.hashCode();
+ return 11 * clazz.hashCode() + 17 * key.hashCode();
}
@Override
public String toString() {
- return classHolder.getBaseClass().getSimpleName() + "#" + key.toString();
+ return clazz.getSimpleName() + "#" + key.toString();
}
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotificationSet.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotificationSet.java 2007-12-05 21:24:52 UTC (rev 6974)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/ChangeNotificationSet.java 2007-12-05 21:26:23 UTC (rev 6975)
@@ -9,7 +9,6 @@
import org.slf4j.Logger;
import com.dumbhippo.GlobalSetup;
-import com.dumbhippo.dm.schema.DMClassHolder;
/**
* A ChangeNotificationSet stores information about all changes to the data model that
@@ -33,7 +32,7 @@
public ChangeNotificationSet(DataModel model) {
}
- private <K, T extends DMObject<K>> ChangeNotification<K,T> getNotification(DMClassHolder<K,T> classHolder, K key, ClientMatcher matcher) {
+ private <K, T extends DMObject<K>> ChangeNotification<K,T> getNotification(Class<T> clazz, K key, ClientMatcher matcher) {
if (key instanceof DMKey) {
@SuppressWarnings("unchecked")
K clonedKey = (K)((DMKey)key).clone();
@@ -44,14 +43,14 @@
if (matchedNotifications == null)
matchedNotifications = new ArrayList<ChangeNotification<?,?>>();
- ChangeNotification<K,T> notification = new ChangeNotification<K,T>(classHolder, key, matcher);
+ ChangeNotification<K,T> notification = new ChangeNotification<K,T>(clazz, key, matcher);
matchedNotifications.add(notification);
return notification;
} else {
if (notifications == null)
notifications = new HashMap<ChangeNotification<?,?>, ChangeNotification<?,?>>();
- ChangeNotification<K,T> notification = new ChangeNotification<K,T>(classHolder, key);
+ ChangeNotification<K,T> notification = new ChangeNotification<K,T>(clazz, key);
@SuppressWarnings("unchecked")
ChangeNotification<K,T> oldNotification = (ChangeNotification<K,T>)notifications.get(notification);
if (oldNotification != null) {
@@ -65,19 +64,13 @@
}
public <K, T extends DMObject<K>> void changed(DataModel model, Class<T> clazz, K key, String propertyName, ClientMatcher matcher) {
- @SuppressWarnings("unchecked")
- DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
-
- ChangeNotification<K,T> notification = getNotification(classHolder, key, matcher);
- notification.addProperty(propertyName);
+ ChangeNotification<K,T> notification = getNotification(clazz, key, matcher);
+ notification.addProperty(model, propertyName);
}
public <K, T extends DMObject<K>> void feedChanged(DataModel model, Class<T> clazz, K key, String propertyName, long itemTimestamp) {
- @SuppressWarnings("unchecked")
- DMClassHolder<K,T> classHolder = (DMClassHolder<K,T>)model.getClassHolder(clazz);
-
- ChangeNotification<K,T> notification = getNotification(classHolder, key, null);
- notification.addFeedProperty(propertyName, itemTimestamp);
+ ChangeNotification<K,T> notification = getNotification(clazz, key, null);
+ notification.addFeedProperty(model, propertyName, itemTimestamp);
}
public void setTimestamp(long timestamp) {
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMPropertyHolder.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMPropertyHolder.java 2007-12-05 21:24:52 UTC (rev 6974)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMPropertyHolder.java 2007-12-05 21:26:23 UTC (rev 6975)
@@ -357,7 +357,7 @@
throw new RuntimeException("@DMFilter annotation must be on a @DMProperty");
}
if (viewerDependent != null) {
- throw new RuntimeException("@DMFilter annotation must be on a @DMProperty");
+ throw new RuntimeException("@Viewpoint annotation must be on a @DMProperty");
}
return null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]