harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r533961 - in /harmony/enhanced/classlib/trunk/modules/beans: .classpath src/main/java/java/beans/VetoableChangeSupport.java src/test/resources/serialization/java/beans/VetoableChangeSupport.ser
Date Tue, 01 May 2007 08:18:15 GMT
Author: tellison
Date: Tue May  1 01:18:14 2007
New Revision: 533961

URL: http://svn.apache.org/viewvc?view=rev&rev=533961
Log:
Apply patch HARMONY-3761 ([classlib][beans]java.beans.VetoableChangeSupport is not compatible
with RI in serialization)

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/.classpath
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/serialization/java/beans/VetoableChangeSupport.ser

Modified: harmony/enhanced/classlib/trunk/modules/beans/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/.classpath?view=diff&rev=533961&r1=533960&r2=533961
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/.classpath (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/.classpath Tue May  1 01:18:14 2007
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry path="src/main/java" kind="src" output="bin/main"/>
-	<classpathentry path="src/test/support/java" kind="src" output="bin/test_support"/>
-	<classpathentry path="src/test/java" kind="src" output="bin/test"/>
-	<classpathentry path="src/test/java-internal" kind="src" output="bin/test-internal"/>
-	<classpathentry path="org.eclipse.pde.core.requiredPlugins" kind="con"/>
-	<classpathentry path="JUNIT_HOME/junit.jar" kind="var" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
-	<classpathentry path="bin/main" kind="output"/>
+	<classpathentry kind="src" output="bin/main" path="src/main/java"/>
+	<classpathentry kind="src" output="bin/test_support" path="src/test/support/java"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/java"/>
+	<classpathentry kind="src" output="bin/test-internal" path="src/test/java-internal"/>
+	<classpathentry kind="src" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
+	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java?view=diff&rev=533961&r1=533960&r2=533961
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/VetoableChangeSupport.java
Tue May  1 01:18:14 2007
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Map.Entry;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -32,14 +33,14 @@
 
     private static final long serialVersionUID = -5090210921595982017l;
 
-    private transient Object sourceBean;
-
     private transient List<VetoableChangeListener> allVetoableChangeListeners = new
ArrayList<VetoableChangeListener>();
 
     private transient Map<String, List<VetoableChangeListener>> selectedVetoableChangeListeners
= new HashMap<String, List<VetoableChangeListener>>();
 
     // fields for serialization compatibility
-    private Hashtable<String, List<VetoableChangeListener>> children;
+    private Hashtable<String, VetoableChangeSupport> children;
+    
+    private transient Object sourceBean;
 
     private int vetoableChangeSupportSerializedDataVersion = 1;
 
@@ -79,7 +80,6 @@
                 listeners = new ArrayList<VetoableChangeListener>();
                 selectedVetoableChangeListeners.put(propertyName, listeners);
             }
-
             listeners.add(listener);
         }
     }
@@ -91,10 +91,8 @@
         if (propertyName != null) {
             listeners = selectedVetoableChangeListeners.get(propertyName);
         }
-
         return (listeners == null) ? new VetoableChangeListener[] {}
                 : getAsVetoableChangeListenerArray(listeners);
-
     }
 
     public void fireVetoableChange(String propertyName, boolean oldValue,
@@ -161,72 +159,60 @@
                     result.add(new VetoableChangeListenerProxy(propertyName,
                             listener));
                 }
-
             }
-
         }
-
         return getAsVetoableChangeListenerArray(result);
     }
 
     private void writeObject(ObjectOutputStream oos) throws IOException {
-        List<VetoableChangeListener> allSerializedVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
-        for (VetoableChangeListener vcl : allVetoableChangeListeners) {
-            if (vcl instanceof Serializable) {
-                allSerializedVetoableChangeListeners.add(vcl);
-            }
-        }
-
-        Map<String, List<VetoableChangeListener>> selectedSerializedVetoableChangeListeners
= new HashMap<String, List<VetoableChangeListener>>();
-        for (String propertyName : selectedVetoableChangeListeners.keySet()) {
-            List<VetoableChangeListener> keyValues = selectedVetoableChangeListeners
-                    .get(propertyName);
-            if (keyValues != null) {
-                List<VetoableChangeListener> serializedVetoableChangeListeners = new
ArrayList<VetoableChangeListener>();
-                for (VetoableChangeListener pcl : keyValues) {
-                    if (pcl instanceof Serializable) {
-                        serializedVetoableChangeListeners.add(pcl);
-                    }
-                }
-
-                if (!serializedVetoableChangeListeners.isEmpty()) {
-                    selectedSerializedVetoableChangeListeners.put(propertyName,
-                            serializedVetoableChangeListeners);
+        children = new Hashtable<String, VetoableChangeSupport>();
+        for (Entry<String, List<VetoableChangeListener>> entry : selectedVetoableChangeListeners
+                .entrySet()) {
+            List<VetoableChangeListener> list = entry.getValue();
+            VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport(
+                    sourceBean);
+            for (VetoableChangeListener vetoableChangeListener : list) {
+                if (vetoableChangeListener instanceof Serializable) {
+                    vetoableChangeSupport
+                            .addVetoableChangeListener(vetoableChangeListener);
                 }
-
             }
+            children.put(entry.getKey(), vetoableChangeSupport);
         }
+        oos.defaultWriteObject();
 
-        children = new Hashtable<String, List<VetoableChangeListener>>(
-                selectedSerializedVetoableChangeListeners);
-        children.put("", allSerializedVetoableChangeListeners); //$NON-NLS-1$
-        oos.writeObject(children);
-
-        Object source = null;
-        if (sourceBean instanceof Serializable) {
-            source = sourceBean;
+        for (VetoableChangeListener vetoableChangeListener : allVetoableChangeListeners)
{
+            if (vetoableChangeListener instanceof Serializable) {
+                oos.writeObject(vetoableChangeListener);
+            }
         }
-        oos.writeObject(source);
-
-        oos.writeInt(vetoableChangeSupportSerializedDataVersion);
+        oos.writeObject(null);
     }
 
-    @SuppressWarnings("unchecked")
+    
     private void readObject(ObjectInputStream ois) throws IOException,
             ClassNotFoundException {
+        ois.defaultReadObject();
+        selectedVetoableChangeListeners = new HashMap<String, List<VetoableChangeListener>>();
+        if (children != null) {
+            for (Entry<String, VetoableChangeSupport> entry : children
+                    .entrySet()) {
+                List<VetoableChangeListener> list = new ArrayList<VetoableChangeListener>();
+                for (VetoableChangeListener vetoableChangeListener : entry
+                        .getValue().allVetoableChangeListeners) {
+                    list.add(vetoableChangeListener);
+                }
+                selectedVetoableChangeListeners.put(entry.getKey(), list);
+            }
 
-        children = (Hashtable<String, List<VetoableChangeListener>>) ois
-                .readObject();
-
-        selectedVetoableChangeListeners = new HashMap<String, List<VetoableChangeListener>>(
-                children);
-        allVetoableChangeListeners = selectedVetoableChangeListeners.remove(""); //$NON-NLS-1$
-        if (allVetoableChangeListeners == null) {
-            allVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
         }
+        allVetoableChangeListeners = new ArrayList<VetoableChangeListener>();
 
-        sourceBean = ois.readObject();
-        vetoableChangeSupportSerializedDataVersion = ois.readInt();
+        VetoableChangeListener vetoableChangeListener;
+        while (null != (vetoableChangeListener = (VetoableChangeListener) ois
+                .readObject())) {
+            allVetoableChangeListeners.add(vetoableChangeListener);
+        }
     }
 
     public void fireVetoableChange(PropertyChangeEvent event)

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/serialization/java/beans/VetoableChangeSupport.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/serialization/java/beans/VetoableChangeSupport.ser?view=diff&rev=533961&r1=533960&r2=533961
==============================================================================
Binary files - no diff available.



Mime
View raw message