cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r603180 - in /incubator/cxf/trunk/rt/frontend: jaxws/src/main/java/org/apache/cxf/jaxws/ jaxws/src/test/java/org/apache/cxf/jaxws/ jaxws/src/test/java/org/apache/cxf/jaxws/service/ simple/src/main/java/org/apache/cxf/service/factory/
Date Tue, 11 Dec 2007 08:51:20 GMT
Author: ema
Date: Tue Dec 11 00:51:09 2007
New Revision: 603180

URL: http://svn.apache.org/viewvc?rev=603180&view=rev
Log:
* Configure WrapperClassInterceptor for jaxws Client to marshal request message with generated
wrapper class 
* Clean up ReflectionServiceFactoryBean 
* [CXF-1177]Add runtime test for SEI with XMLList annotation
 

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java?rev=603180&r1=603179&r2=603180&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
Tue Dec 11 00:51:09 2007
@@ -18,12 +18,23 @@
  */
 package org.apache.cxf.jaxws;
 
+import java.util.List;
+
 import javax.xml.ws.BindingProvider;
 
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
+import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
+import org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor;
+import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 
 public class JaxWsProxyFactoryBean extends ClientProxyFactoryBean {
     public JaxWsProxyFactoryBean() {
@@ -39,4 +50,37 @@
         Class cls = getClientFactoryBean().getServiceClass();
         return new Class[] {cls, BindingProvider.class};
     }
+    
+    @Override
+    public Object create() {
+        Object obj = super.create();
+        Service service = getServiceFactory().getService();
+        if (needWrapperClassInterceptor(service.getServiceInfos().get(0))) {
+            List<Interceptor> in = super.getInInterceptors();
+            List<Interceptor> out = super.getOutInterceptors();
+            in.add(new WrapperClassInInterceptor());
+            in.add(new HolderInInterceptor());
+            out.add(new WrapperClassOutInterceptor());
+            out.add(new HolderOutInterceptor());
+        }
+        return obj;
+              
+    }
+    
+    private boolean needWrapperClassInterceptor(ServiceInfo serviceInfo) {
+        if (serviceInfo == null) {
+            return false;
+        }
+
+        for (OperationInfo opInfo : serviceInfo.getInterface().getOperations()) {
+            if (opInfo.isUnwrappedCapable()
+                && opInfo.getProperty(ReflectionServiceFactoryBean.WRAPPERGEN_NEEDED)
!= null) {
+                return true;
+
+            }
+        }
+        return false;
+    }
+   
+    
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=603180&r1=603179&r2=603180&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
Tue Dec 11 00:51:09 2007
@@ -98,11 +98,12 @@
                 != null) {
                 Method method = (Method)opInfo.getProperty(ReflectionServiceFactoryBean.METHOD);
                 MessageInfo messageInfo = opInfo.getUnwrappedOperation().getInput();
-                createWrapperClass(messageInfo, method, true);
-
+                Class requestWrapperClass = createWrapperClass(messageInfo, method, true);
+                opInfo.getInput().getMessageParts().get(0).setTypeClass(requestWrapperClass);
                 messageInfo = opInfo.getUnwrappedOperation().getOutput();
                 if (messageInfo != null) {
-                    createWrapperClass(messageInfo, method, false);
+                    Class responseWrapperClass = createWrapperClass(messageInfo, method,
false);
+                    opInfo.getOutput().getMessageParts().get(0).setTypeClass(responseWrapperClass);
                 }
 
 
@@ -111,7 +112,7 @@
         return wrapperBeans;
     }
 
-    private void createWrapperClass(MessageInfo messageInfo, Method method, boolean isRequest)
{
+    private Class<?> createWrapperClass(MessageInfo messageInfo, Method method, boolean
isRequest) {
 
         QName wrapperElement = messageInfo.getName();
 
@@ -161,6 +162,7 @@
         Class<?> clz = loadClass(className, method.getDeclaringClass(), cw.toByteArray());
         messageInfo.getMessagePart(0).setTypeClass(clz);
         wrapperBeans.add(clz);
+        return clz;
 
     }
 

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java?rev=603180&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SEIWithJAXBAnnoTest.java
Tue Dec 11 00:51:09 2007
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.service.AddNumbers;
+import org.apache.cxf.jaxws.service.AddNumbersImpl;
+import org.junit.Test;
+
+
+public class SEIWithJAXBAnnoTest extends AbstractJaxWsTest {
+    String address = "http://localhost:9000/Hello";
+
+    
+    @Test
+    public void testXMLList() throws Exception {
+        
+        AddNumbersImpl serviceImpl = new AddNumbersImpl();
+        Endpoint.publish("http://localhost:9000/Hello", serviceImpl);
+        
+        
+     
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setBus(SpringBusFactory.getDefaultBus());
+        factory.setServiceClass(AddNumbers.class);
+        
+
+        factory.setAddress(address);
+        AddNumbers proxy = (AddNumbers)factory.create();
+        StringWriter strWriter = new StringWriter();
+        LoggingOutInterceptor log = new LoggingOutInterceptor(new PrintWriter(strWriter));
+        factory.getClientFactoryBean().getClient().getOutInterceptors().add(log);
+        
+        List<String> args = new ArrayList<String>();
+        args.add("str1");
+        args.add("str2");
+        args.add("str3");
+        List<Integer> result = proxy.addNumbers(args);
+        String expected = "<ns2:addNumbers xmlns:ns2=\"http://service.jaxws.cxf.apache.org/\">"

+            + "<arg0>str1 str2 str3</arg0></ns2:addNumbers>";
+        assertTrue("Client does not use the generated wrapper class to marshal request parameters",
+                     strWriter.toString().indexOf(expected) > -1);
+        assertEquals("Get the wrong result", 100, result.get(0));
+        
+    }    
+}
+

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java?rev=603180&r1=603179&r2=603180&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersImpl.java
Tue Dec 11 00:51:09 2007
@@ -19,13 +19,18 @@
 
 package org.apache.cxf.jaxws.service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @javax.jws.WebService(endpointInterface = "org.apache.cxf.jaxws.service.AddNumbers")
 public class AddNumbersImpl implements AddNumbers {
 
     public List<Integer> addNumbers(List<String> arg) {
-        return null;
+        List<Integer> res = new ArrayList<Integer>();
+        res.add(100);
+        res.add(200);
+        return res;
+
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=603180&r1=603179&r2=603180&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Tue Dec 11 00:51:09 2007
@@ -127,8 +127,6 @@
     public static final String METHOD = "operation.method";
     public static final String METHOD_PARAM_ANNOTATIONS = "method.parameters.annotations";
     public static final String METHOD_ANNOTATIONS = "method.return.annotations";
-    public static final QName SWA_REF = new QName("http://ws-i.org/profiles/basic/1.1/xsd",
"swaRef");
-    public static final String SWA_REF_LOCATION = "http://ws-i.org/profiles/basic/1.1/swaref.xsd";
     private static final Logger LOG = LogUtils.getL7dLogger(ReflectionServiceFactoryBean.class,
                                                             "SimpleMessages");
 



Mime
View raw message