cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r802892 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/jaxb/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/ sys...
Date Mon, 10 Aug 2009 18:45:42 GMT
Author: dkulp
Date: Mon Aug 10 18:45:42 2009
New Revision: 802892

URL: http://svn.apache.org/viewvc?rev=802892&view=rev
Log:
Make more stuff work if asm isn't available.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Mon Aug 10 18:45:42
2009
@@ -568,7 +568,9 @@
             typeRefs.add(ref);
             List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
             clses.add(refClass.getField("type").get(ref).getClass());
-            clses.add(refcls);
+            if (!refcls.isInterface()) {
+                clses.add(refcls);
+            }
             
             Object ctx = null;
             for (Method m : cls.getDeclaredMethods()) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
Mon Aug 10 18:45:42 2009
@@ -193,9 +193,7 @@
     
             }
     
-            if (parameters.size() > 0) {
-                message.setContent(List.class, parameters);
-            }
+            message.setContent(List.class, parameters);
         } catch (Fault f) {
             if (!isRequestor(message)) {
                 f.setFaultCode(Fault.FAULT_CODE_CLIENT);

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedOutInterceptor.java
Mon Aug 10 18:45:42 2009
@@ -71,7 +71,8 @@
                 }
                 if (pfx == null) {
                     int x = 1;
-                    while (xmlWriter.getNamespaceContext().getNamespaceURI("ns" + x) != null)
{
+                    while (!StringUtils.isEmpty(xmlWriter.getNamespaceContext()
+                                                     .getNamespaceURI("ns" + x))) {
                         x++;
                     }
                     pfx = "ns" + x;

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Mon Aug 10 18:45:42 2009
@@ -34,6 +34,7 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.logging.Logger;
@@ -509,7 +510,9 @@
                                                    createList(part));
                 Object o = ret;
                 if (!isList(part)) {
-                    if (clazz.getComponentType().isPrimitive()) {
+                    if (isSet(part)) {
+                        o = createSet(part, ret);
+                    } else if (clazz.getComponentType().isPrimitive()) {
                         o = java.lang.reflect.Array.newInstance(clazz.getComponentType(),
ret.size());
                         for (int x = 0; x < ret.size(); x++) {
                             Array.set(o, x, ret.get(x));
@@ -536,6 +539,39 @@
         return o;
     }
 
+    private static Object createSet(MessagePartInfo part, List<Object> ret) {
+        Type genericType = (Type)part.getProperty("generic.type");
+        Class tp2 = (Class)((ParameterizedType)genericType).getRawType();
+        if (tp2.isInterface()) {
+            return new HashSet<Object>(ret);
+        }
+        Collection<Object> c;
+        try {
+            c = CastUtils.cast((Collection<?>)tp2.newInstance());
+        } catch (Exception e) {
+            c = new HashSet<Object>();
+        }
+        c.addAll(ret);
+        return c;
+    }
+
+    private static boolean isSet(MessagePartInfo part) {
+        if (part.getTypeClass().isArray() && !part.getTypeClass().getComponentType().isPrimitive())
{
+            // && Collection.class.isAssignableFrom(part.getTypeClass())) {
+            // it's List Para
+            //
+            Type genericType = (Type)part.getProperty("generic.type");
+
+            if (genericType instanceof ParameterizedType) {
+                Type tp2 = ((ParameterizedType)genericType).getRawType();
+                if (tp2 instanceof Class) {
+                    return Set.class.isAssignableFrom((Class<?>)tp2);
+                }
+            }
+        }
+        return false;
+    }
+
     private static List<Object> createList(MessagePartInfo part) {
         Type genericType = (Type)part.getProperty("generic.type");
         return createList(genericType); 
@@ -573,7 +609,7 @@
             if (genericType instanceof ParameterizedType) {
                 Type tp2 = ((ParameterizedType)genericType).getRawType();
                 if (tp2 instanceof Class) {
-                    return Collection.class.isAssignableFrom((Class<?>)tp2);
+                    return List.class.isAssignableFrom((Class<?>)tp2);
                 }
             }
         }

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Mon Aug 10 18:45:42 2009
@@ -96,19 +96,22 @@
         if (part != null && part.getProperty("honor.jaxb.annotations") != null) {
             honorJaxbAnnotation = (Boolean)part.getProperty("honor.jaxb.annotations");
         }
-        Annotation[] anns = getJAXBAnnotation(part);
-        if (honorJaxbAnnotation && anns.length > 0) {
-            //RpcLit will use the JAXB Bridge to unmarshall part message when it is 
-            //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
-            //TODO:Cache the JAXBRIContext
-            QName qname = new QName(null, part.getConcreteName().getLocalPart());
-
-            return JAXBEncoderDecoder.unmarshalWithBridge(qname,
-                                                          part.getTypeClass(),
-                                                          anns, 
-                                                          databinding.getContextClasses(),
-                                                          reader,
-                                                          getAttachmentUnmarshaller());
+        Annotation[] anns = null;
+        if (honorJaxbAnnotation) {
+            anns = getJAXBAnnotation(part);
+            if (anns.length > 0) {
+                //RpcLit will use the JAXB Bridge to unmarshall part message when it is 
+                //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
+                //TODO:Cache the JAXBRIContext
+                QName qname = new QName(null, part.getConcreteName().getLocalPart());
+    
+                return JAXBEncoderDecoder.unmarshalWithBridge(qname,
+                                                              part.getTypeClass(),
+                                                              anns, 
+                                                              databinding.getContextClasses(),
+                                                              reader,
+                                                              getAttachmentUnmarshaller());
+            }
         }
         
         return JAXBEncoderDecoder.unmarshall(createUnmarshaller(), reader, part, 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Mon Aug 10 18:45:42 2009
@@ -20,6 +20,7 @@
 package org.apache.cxf.systest.jaxws;
 
 import java.io.InputStream;
+import java.lang.reflect.Field;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.HttpURLConnection;
 import java.net.URL;
@@ -49,6 +50,7 @@
 import org.apache.cxf.anonymous_complex_type.SplitNameResponse.Names;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.common.WSDLConstants;
+import org.apache.cxf.common.util.ASMHelper;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
@@ -314,7 +316,7 @@
     }
     
     @Test
-    public void testStringListOutDocLitNoWsdl() throws Exception {
+    public void testDocLitWrappedCodeFirstServiceNoWsdl() throws Exception {
         QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

                                    "DocLitWrappedCodeFirstServicePort");
         QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

@@ -328,7 +330,7 @@
     }
 
     @Test
-    public void testStringListOutDocLitWsdl() throws Exception {
+    public void testDocLitWrappedCodeFirstServiceWsdl() throws Exception {
         QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

                                    "DocLitWrappedCodeFirstServicePort");
         QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

@@ -340,6 +342,52 @@
                                                              DocLitWrappedCodeFirstService.class);
         runDocLitTest(port);
     }
+
+    private void setASM(boolean b) throws Exception {
+        Field f = ASMHelper.class.getDeclaredField("oldASM");
+        f.setAccessible(true);
+        f.set(null, b);
+    }
+    
+    @Test
+    public void testDocLitWrappedCodeFirstServiceNoWsdlNoASM() throws Exception {
+        try {
+            setASM(false);
+            QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

+                                       "DocLitWrappedCodeFirstServicePort");
+            QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

+                                       "DocLitWrappedCodeFirstService");
+            
+            Service service = Service.create(servName);
+            service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.DOCLIT_CODEFIRST_URL);
+            DocLitWrappedCodeFirstService port = service.getPort(portName,
+                                                                 DocLitWrappedCodeFirstService.class);
+            runDocLitTest(port);
+        } finally {
+            setASM(true);
+        }
+    }
+
+    @Test
+    public void testDocLitWrappedCodeFirstServiceWsdlNoASM() throws Exception {
+        try {
+            setASM(false);
+            QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

+                                       "DocLitWrappedCodeFirstServicePort");
+            QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",

+                                       "DocLitWrappedCodeFirstService");
+            
+            Service service = Service.create(new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"),
+                                             servName);
+            DocLitWrappedCodeFirstService port = service.getPort(portName,
+                                                                 DocLitWrappedCodeFirstService.class);
+            runDocLitTest(port);
+        } finally {
+            setASM(true);
+        }
+    }
+    
+
     
     @Test
     public void testSimpleClientWithWsdl() throws Exception {
@@ -361,17 +409,19 @@
         assertEquals("Hello", echoMsg);
     }
     private void runDocLitTest(DocLitWrappedCodeFirstService port) throws Exception {
+        
+        assertEquals("hello", port.outOnly(new Holder<String>(), new Holder<String>()));
+        
         long start = System.currentTimeMillis();
         port.doOneWay();
         assertTrue((System.currentTimeMillis() - start) < 500);
         
         assertEquals("Hello", port.echoStringNotReallyAsync("Hello"));
-        
+
         Set<Foo> fooSet = port.getFooSet();
         assertEquals(2, fooSet.size());
         assertEquals("size: 2", port.doFooList(new ArrayList<Foo>(fooSet)));
         
-        
         assertEquals(24, port.echoIntDifferentWrapperName(24));
         
         String echoMsg = port.echo("Hello");
@@ -449,8 +499,12 @@
         int ints[] = port.echoIntArray(new int[] {1, 2 , 3}, null);
         assertEquals(3, ints.length);
         assertEquals(1, ints[0]);
-        
-        assertEquals("Val", port.createBar("Val").getName());
+
+        if (new ASMHelper().createClassWriter() != null) {
+            //doing the type adapter things and such really 
+            //requires the ASM generated helper classes
+            assertEquals("Val", port.createBar("Val").getName());
+        }
         testExceptionCases(port);
     }
     

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
Mon Aug 10 18:45:42 2009
@@ -138,6 +138,9 @@
     @WebMethod
     List<Foo[]> listObjectArrayOutput();
     
+    String outOnly(@WebParam(mode = WebParam.Mode.OUT) Holder<String> out1, 
+                   @WebParam(mode = WebParam.Mode.OUT) Holder<String> out2);
+    
     @WebMethod
     @WSDLDocumentationCollection({
         @WSDLDocumentation(value = "fault message doc",

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=802892&r1=802891&r2=802892&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Mon Aug 10 18:45:42 2009
@@ -215,5 +215,11 @@
     public String doFooList(List<Foo> fooList) {
         return "size: " + fooList.size();
     }
+
+    public String outOnly(Holder<String> out1, Holder<String> out2) {
+        out1.value = "out1";
+        out2.value = "out2";
+        return "hello";
+    }
     
 }



Mime
View raw message