cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r556706 - in /incubator/cxf/trunk: common/xjc/ts-test/ common/xjc/ts/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/
Date Mon, 16 Jul 2007 19:33:44 GMT
Author: dkulp
Date: Mon Jul 16 12:33:42 2007
New Revision: 556706

URL: http://svn.apache.org/viewvc?view=rev&rev=556706
Log:
Fix problem in runtime with generated wrapper types in java first cases that use lists generated
getters and setters, but getter returns null unlike JAXB generated wrappers.

Modified:
    incubator/cxf/trunk/common/xjc/ts/   (props changed)
    incubator/cxf/trunk/common/xjc/ts-test/   (props changed)
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelperCompiler.java

Propchange: incubator/cxf/trunk/common/xjc/ts/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jul 16 12:33:42 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+

Propchange: incubator/cxf/trunk/common/xjc/ts-test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jul 16 12:33:42 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+

Propchange: incubator/cxf/trunk/common/xjc/ts-test/
------------------------------------------------------------------------------
--- svn:ignores (added)
+++ svn:ignores Mon Jul 16 12:33:42 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java?view=diff&rev=556706&r1=556705&r2=556706
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelper.java
Mon Jul 16 12:33:42 2007
@@ -111,11 +111,11 @@
                 && "return".equals(partName)) {
                 //RI generated code uses this
                 try {
-                    getMethod = wrapperType.getClass().getMethod("get_return", NO_PARAMS);
+                    getMethod = wrapperType.getMethod("get_return", NO_PARAMS);
                 } catch (NoSuchMethodException ex) {
                     try {
-                        getMethod = wrapperType.getClass().getMethod("is_return",
-                                                                  new Class[0]);
+                        getMethod = wrapperType.getMethod("is_return",
+                                                          new Class[0]);
                     } catch (NoSuchMethodException ex2) {
                         //ignore for now
                     } 
@@ -261,7 +261,7 @@
             
             try {
                 Object ret = wrapperType.newInstance();
-                
+
                 for (int x = 0; x < setMethods.length; x++) {
                     Object o = lst.get(x);
                     if (jaxbObjectMethods[x] != null) {
@@ -269,8 +269,17 @@
                     }
                     if (o instanceof List) {
                         List<Object> col = CastUtils.cast((List)getMethods[x].invoke(ret));
-                        List<Object> olst = CastUtils.cast((List)o);
-                        col.addAll(olst);
+                        if (col == null) {
+                            //broken generated java wrappers
+                            if (setMethods[x] != null) {
+                                setMethods[x].invoke(ret, o);
+                            } else {
+                                fields[x].set(ret, lst.get(x));
+                            }
+                        } else {
+                            List<Object> olst = CastUtils.cast((List)o);
+                            col.addAll(olst);
+                        }
                     } else if (setMethods[x] != null) {
                         setMethods[x].invoke(ret, o);
                     } else {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelperCompiler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelperCompiler.java?view=diff&rev=556706&r1=556705&r2=556706
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelperCompiler.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperHelperCompiler.java
Mon Jul 16 12:33:42 2007
@@ -154,6 +154,7 @@
         mv.visitMaxs(0, 0);
         mv.visitEnd();
     }
+    
     private static boolean addCreateWrapperObject(String newClassName,
                                                Class<?> wrapperClass,
                                                Method[] setMethods,
@@ -183,26 +184,58 @@
                 return false;
             }
             Class<?> tp = getMethods[x].getReturnType();
-            mv.visitVarInsn(Opcodes.ALOAD, 2);
-            
+            mv.visitVarInsn(Opcodes.ALOAD, 2);            
             
             if (Collection.class.isAssignableFrom(tp)) {
-                // call getFoo().addAll(lst)
-    
+                //List aVal = obj.getA();
+                //List newA = (List)lst.get(99);
+                //if (aVal == null) {
+                //    obj.setA(newA);
+                //} else {
+                //    aVal.addAll(newA);
+                //}
+                
                 mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
                                    periodToSlashes(wrapperClass.getName()),
                                    getMethods[x].getName(),
                                    getMethodSignature(getMethods[x]));
-    
+                mv.visitVarInsn(Opcodes.ASTORE, 3);
                 mv.visitVarInsn(Opcodes.ALOAD, 1);
                 mv.visitIntInsn(Opcodes.BIPUSH, x);
-                mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;");
+                mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List",
+                                   "get", "(I)Ljava/lang/Object;");
                 mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/List");
                 mv.visitTypeInsn(Opcodes.CHECKCAST, "java/util/List");
-                mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", 
-                                   "addAll", "(Ljava/util/Collection;)Z");
+                mv.visitVarInsn(Opcodes.ASTORE, 4);
+                mv.visitVarInsn(Opcodes.ALOAD, 3);
+                Label nonNullLabel = new Label();
+                mv.visitJumpInsn(Opcodes.IFNONNULL, nonNullLabel);
+
+                if (setMethods[x] == null) {
+                    mv.visitTypeInsn(Opcodes.NEW, "java/lang/RuntimeException");
+                    mv.visitInsn(Opcodes.DUP);
+                    mv.visitLdcInsn(getMethods[x].getName() + " returned null and there isn't
a set method.");
+                    mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
+                                       "java/lang/RuntimeException",
+                                       "<init>", "(Ljava/lang/String;)V");
+                    mv.visitInsn(Opcodes.ATHROW);
+                } else {
+                    mv.visitVarInsn(Opcodes.ALOAD, 2);
+                    mv.visitVarInsn(Opcodes.ALOAD, 4);
+                    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
+                                       periodToSlashes(wrapperClass.getName()),
+                                       setMethods[x].getName(),
+                                       getMethodSignature(setMethods[x]));
+                }
+                Label jumpOverLabel = new Label();
+                mv.visitJumpInsn(Opcodes.GOTO, jumpOverLabel);
+                mv.visitLabel(nonNullLabel);
+                mv.visitVarInsn(Opcodes.ALOAD, 3);
+                mv.visitVarInsn(Opcodes.ALOAD, 4);
+                mv.visitMethodInsn(Opcodes.INVOKEINTERFACE,
+                                   "java/util/List", "addAll", "(Ljava/util/Collection;)Z");
                 mv.visitInsn(Opcodes.POP);
-    
+                mv.visitLabel(jumpOverLabel);
             } else { 
                 if (JAXBElement.class.isAssignableFrom(tp)) {
                     mv.visitVarInsn(Opcodes.ALOAD, 0);



Mime
View raw message