You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2011/03/17 00:01:41 UTC

svn commit: r1082337 - /pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java

Author: smartini
Date: Wed Mar 16 23:01:41 2011
New Revision: 1082337

URL: http://svn.apache.org/viewvc?rev=1082337&view=rev
Log:
fix for PIVOT-687 and for PIVOT-717

Modified:
    pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java

Modified: pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1082337&r1=1082336&r2=1082337&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Wed Mar 16 23:01:41 2011
@@ -242,6 +242,8 @@ public class BXMLSerializer implements S
     private String language = null;
     private int nextID = 0;
 
+    private ClassLoader classLoader = null;
+
     private LinkedList<Attribute> namespaceBindingAttributes = new LinkedList<Attribute>();
 
     private static HashMap<String, String> fileExtensions = new HashMap<String, String>();
@@ -390,6 +392,11 @@ public class BXMLSerializer implements S
         });
     }
 
+    public BXMLSerializer(final ClassLoader classLoader) {
+        this();
+        this.classLoader = classLoader;
+    }
+
     /**
      * Deserializes an object hierarchy from a BXML resource.
      * <p>
@@ -734,7 +741,11 @@ public class BXMLSerializer implements S
 
                     String propertyClassName = namespaceURI + "." + localName.substring(0, i);
                     try {
-                        propertyClass = Class.forName(propertyClassName);
+                        if (classLoader == null) {
+                            propertyClass = Class.forName(propertyClassName);
+                        } else {
+                            propertyClass = Class.forName(propertyClassName, true, classLoader);
+                        }
                     } catch (ClassNotFoundException exception) {
                         throw new SerializationException(exception);
                     }
@@ -751,7 +762,13 @@ public class BXMLSerializer implements S
                     String className = namespaceURI + "." + localName.replace('.', '$');
 
                     try {
-                        Class<?> type = Class.forName(className);
+                        Class<?> type;
+                        if (classLoader == null) {
+                            type = Class.forName(className);
+                        } else {
+                            type = Class.forName(className, true, classLoader);
+                        }
+
                         value = newTypedObject(type);
                     } catch (ClassNotFoundException exception) {
                         throw new SerializationException(exception);
@@ -978,13 +995,17 @@ public class BXMLSerializer implements S
                         name = localName.substring(j + 1);
 
                         String namespaceURI = xmlStreamReader.getAttributeNamespace(i);
-                        if (namespaceURI == null) {
+                        if (namespaceURI == null || namespaceURI.isEmpty()) {
                             namespaceURI = xmlStreamReader.getNamespaceURI("");
                         }
 
                         String propertyClassName = namespaceURI + "." + localName.substring(0, j);
                         try {
-                            propertyClass = Class.forName(propertyClassName);
+                            if (classLoader == null) {
+                                propertyClass = Class.forName(propertyClassName);
+                            } else {
+                                propertyClass = Class.forName(propertyClassName, true, classLoader);
+                            }
                         } catch (ClassNotFoundException exception) {
                             throw new SerializationException(exception);
                         }