cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r714245 - in /cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/collection/ test/java/org/apache/cxf/aegis/type/java5/
Date Sat, 15 Nov 2008 12:58:25 GMT
Author: bimargulies
Date: Sat Nov 15 04:58:24 2008
New Revision: 714245

URL: http://svn.apache.org/viewvc?rev=714245&view=rev
Log:
Fix CXF-1906 and some related issues involving collection subtypes. We still have java.util
namespace bugs 
lurking, but I'm not chasing them today.

Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.aegis.xml
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest$CollectionService.aegis.xml
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java?rev=714245&r1=714244&r2=714245&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
Sat Nov 15 04:58:24 2008
@@ -22,9 +22,11 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 import java.util.SortedSet;
+import java.util.Stack;
 import java.util.TreeSet;
 import java.util.Vector;
 
@@ -57,23 +59,34 @@
     @SuppressWarnings("unchecked")
     protected Collection<Object> createCollection() {
         Collection values = null;
-
-        if (getTypeClass().isAssignableFrom(List.class)) {
+        
+        /*
+         * getTypeClass returns the type of the object. These ifs asked if the proposed
+         * type can be assigned to the object, not the other way around. Thus List before
+         * Vector and Set before SortedSet.
+         */
+        
+        Class userTypeClass = getTypeClass();
+        if (userTypeClass.isAssignableFrom(List.class)) {
             values = new ArrayList();
-        } else if (getTypeClass().isAssignableFrom(SortedSet.class)) {
-            values = new TreeSet();
-        } else if (getTypeClass().isAssignableFrom(Set.class)) {
+        } else if (userTypeClass.isAssignableFrom(LinkedList.class)) {
+            values = new LinkedList();
+        } else if (userTypeClass.isAssignableFrom(Set.class)) {
             values = new HashSet();
-        } else if (getTypeClass().isAssignableFrom(Vector.class)) {
+        } else if (userTypeClass.isAssignableFrom(SortedSet.class)) {
+            values = new TreeSet();
+        } else if (userTypeClass.isAssignableFrom(Vector.class)) {
             values = new Vector();
-        } else if (getTypeClass().isInterface()) {
+        } else if (userTypeClass.isAssignableFrom(Stack.class)) {
+            values = new Stack();
+        } else if (userTypeClass.isInterface()) {
             values = new ArrayList();
         } else {
             try {
-                values = (Collection<Object>)getTypeClass().newInstance();
+                values = (Collection<Object>)userTypeClass.newInstance();
             } catch (Exception e) {
                 throw new DatabindingException("Could not create map implementation: "
-                                               + getTypeClass().getName(), e);
+                                               + userTypeClass.getName(), e);
             }
         }
 

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.aegis.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.aegis.xml?rev=714245&r1=714244&r2=714245&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.aegis.xml
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.aegis.xml
Sat Nov 15 04:58:24 2008
@@ -9,5 +9,14 @@
         <method name="takeSortedStrings">
         	<parameter index="0" mappedName="strings"/>
         </method>
+        <method name="takeUnsortedSet">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
+        <method name="takeStack">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
+        <method name="takeArrayList">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
 	</mapping>
 </mappings>
\ No newline at end of file

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java?rev=714245&r1=714244&r2=714245&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
Sat Nov 15 04:58:24 2008
@@ -18,12 +18,12 @@
  */
 package org.apache.cxf.aegis.type.java5;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.SortedSet;
-
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
+import java.util.Stack;
 
 public interface CollectionServiceInterface {
 
@@ -37,8 +37,13 @@
 
     void takeDoubleList(List<Double> doublesList);
 
-    String takeSortedStrings(@WebParam(name = "strings")SortedSet<String> strings);
+    String takeSortedStrings(SortedSet<String> strings);
+    
+    //CHECKSTYLE:OFF
+    String takeUnsortedSet(HashSet<String> strings);
+    String takeStack(Stack<String> strings);
+    String takeArrayList(ArrayList<String> strings);
+    //CHECKSTYLE:ON
     
-    @WebMethod
-    void method1(@WebParam(name = "headers1") List<String> headers1);
+    void method1(List<String> headers1);
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest$CollectionService.aegis.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest%24CollectionService.aegis.xml?rev=714245&r1=714244&r2=714245&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest$CollectionService.aegis.xml
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest$CollectionService.aegis.xml
Sat Nov 15 04:58:24 2008
@@ -9,5 +9,14 @@
         <method name="takeSortedStrings">
         	<parameter index="0" mappedName="strings"/>
         </method>
+        <method name="takeUnsortedSet">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
+        <method name="takeStack">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
+        <method name="takeArrayList">
+        	<parameter index="0" mappedName="strings"/>
+        </method>
 	</mapping>
 </mappings>
\ No newline at end of file

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java?rev=714245&r1=714244&r2=714245&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
Sat Nov 15 04:58:24 2008
@@ -21,10 +21,13 @@
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.SortedSet;
+import java.util.Stack;
 import java.util.TreeSet;
 
 import javax.xml.namespace.QName;
@@ -226,7 +229,7 @@
     }
     
     @Test
-    public void testSortedSet() throws Exception {
+    public void testListTypes() throws Exception {
         createService(CollectionService.class, new CollectionService(), null);
         
         ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
@@ -243,6 +246,13 @@
         strings.add("Baker");
         String first = csi.takeSortedStrings(strings);
         assertEquals("Able", first);
+        
+        //CHECKSTYLE:OFF
+        HashSet<String> hashedSet = new HashSet<String>();
+        hashedSet.addAll(strings);
+        String countString = csi.takeUnsortedSet(hashedSet);
+        assertEquals("2", countString);
+        //CHECKSTYLE:ON
     }
 
     public class CollectionService implements CollectionServiceInterface {
@@ -278,5 +288,20 @@
         public void method1(List<String> headers1) {
             // do nothing, this is purely for schema issues.
         }
+
+        public String takeStack(Stack<String> strings) {
+            return strings.firstElement();
+        }
+
+        //CHECKSTYLE:OFF
+        public String takeUnsortedSet(HashSet<String> strings) {
+            return new Integer(strings.size()).toString();
+        }
+
+        public String takeArrayList(ArrayList<String> strings) {
+            return strings.get(0);
+        }
+        //CHECKSTYLE:ON
+
     }
 }



Mime
View raw message