cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r598951 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/ws/src/test/java/org/apache/attachment/ tools/javato/ws/src/test/...
Date Wed, 28 Nov 2007 10:47:42 GMT
Author: ema
Date: Wed Nov 28 02:47:41 2007
New Revision: 598951

URL: http://svn.apache.org/viewvc?rev=598951&view=rev
Log:
[CXF-1176]Generate swaref type element when the parameter is annotated with XmlAttachmentRef
annotation

Added:
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbers.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbersImpl.java
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=598951&r1=598950&r2=598951&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Wed Nov 28 02:47:41 2007
@@ -111,7 +111,7 @@
     @Override
     public void setServiceClass(Class<?> serviceClass) {
         setJaxWsImplementorInfo(new JaxWsImplementorInfo(serviceClass));
-        super.setServiceClass(serviceClass);
+        super.setServiceClass(getJaxWsImplementorInfo().getEndpointClass());
     }
 
     @Override

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=598951&r1=598950&r2=598951&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
Wed Nov 28 02:47:41 2007
@@ -38,12 +38,16 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.activation.DataHandler;
+import javax.xml.bind.annotation.XmlAttachmentRef;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
@@ -120,7 +124,8 @@
     public static final String METHOD = "operation.method";
     public static final String METHOD_PARAM_ANNOTATIONS = "method.parameters.annotations";
     public static final String METHOD_ANNOTATONS = "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");
 
@@ -515,7 +520,7 @@
         QName intfName = getInterfaceName();
         InterfaceInfo intf = new InterfaceInfo(serviceInfo, intfName);
 
-        Method[] methods = serviceClass.getMethods();
+        Method[] methods = getServiceClass().getMethods();
 
         // The BP profile states we can't have operations of the same name
         // so we have to append numbers to the name. Different JVMs sort methods
@@ -870,12 +875,13 @@
         for (MessagePartInfo mpi : unwrappedMessage.getMessageParts()) {
             el = new XmlSchemaElement();
             XmlSchemaTools.setElementQName(el, mpi.getName());
+            Map<Class, Boolean> jaxbAnnoMap = getJaxbAnnoMap(mpi);
             if (mpi.isElement()) {
                 addImport(schema, mpi.getElementQName().getNamespaceURI());
                 XmlSchemaTools.setElementQName(el, null);
                 XmlSchemaTools.setElementRefName(el, mpi.getElementQName());
             } else {
-                if (mpi.getTypeQName() != null && !existXmlListAnno(mpi)) {
+                if (mpi.getTypeQName() != null && !jaxbAnnoMap.containsKey(XmlList.class))
{
                     el.setSchemaTypeName(mpi.getTypeQName());
                     addImport(schema, mpi.getTypeQName().getNamespaceURI());
                 }
@@ -905,7 +911,7 @@
                                 
                 if (mpi.getTypeClass() != null && mpi.getTypeClass().isArray()
                     && !Byte.TYPE.equals(mpi.getTypeClass().getComponentType()))
{
-                    if (existXmlListAnno(mpi)) {
+                    if (jaxbAnnoMap.containsKey(XmlList.class)) {
                         setSimpleTypeList(schema, el, mpi);                         
                     } else {
                         String min = (String)mpi.getProperty("minOccurs");
@@ -935,6 +941,12 @@
                     if (mpi.getTypeClass() != null && !mpi.getTypeClass().isPrimitive())
{
                         el.setMinOccurs(0);
                     }
+                    if (jaxbAnnoMap.containsKey(XmlAttachmentRef.class) 
+                        && mpi.getTypeClass() != null 
+                        && mpi.getTypeClass().isAssignableFrom(DataHandler.class))
{
+                        setSwaRefType(schema, el);
+
+                    }
                 }
                 seq.getItems().add(el);
                 mpi.setXmlSchema(el);
@@ -980,20 +992,27 @@
         }
     }
 
-    private boolean existXmlListAnno(MessagePartInfo mpi) {
+    private Map<Class, Boolean> getJaxbAnnoMap(MessagePartInfo mpi) {
+        Map<Class, Boolean> map = new ConcurrentHashMap<Class, Boolean>();
         Annotation[] anns = getMethodParameterAnnotations(mpi);
-        if (anns != null) {
+        if (anns != null) {           
             for (Annotation anno : anns) {
                 if (anno instanceof XmlList) {
-                    return true;
+                    map.put(XmlList.class, true);
+                }
+                if (anno instanceof XmlAttachmentRef) {
+                    map.put(XmlAttachmentRef.class, true);
+                }
+                if (anno instanceof XmlJavaTypeAdapter) {
+                    map.put(XmlJavaTypeAdapter.class, true);
                 }
             }
         }
-        return false;
+        return map;
     }
     
     private void setSimpleTypeList(XmlSchema schema, XmlSchemaElement el, MessagePartInfo
mpi) {
-        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);               
       
+        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
         XmlSchemaSimpleTypeList simpleList = new XmlSchemaSimpleTypeList();
         if (mpi.getXmlSchema() instanceof XmlSchemaType) {
             XmlSchemaType type = (XmlSchemaType)mpi.getXmlSchema();
@@ -1003,6 +1022,16 @@
         }
         simpleType.setContent(simpleList);
         el.setSchemaType(simpleType); 
+    }
+    
+    
+    private void setSwaRefType(XmlSchema schema, XmlSchemaElement  el) {
+        el.setSchemaType(null);
+        el.setSchemaTypeName(SWA_REF);
+        XmlSchemaImport swaImport = new XmlSchemaImport();
+        swaImport.setNamespace(SWA_REF.getNamespaceURI());
+        swaImport.setSchemaLocation(SWA_REF_LOCATION);
+        schema.getItems().add(swaImport);
     }
     
     private SchemaInfo getOrCreateSchema(ServiceInfo serviceInfo,

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbers.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbers.java?rev=598951&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbers.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbers.java
Wed Nov 28 02:47:41 2007
@@ -0,0 +1,33 @@
+/**
+ * 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.attachment;
+
+import javax.activation.DataHandler;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlAttachmentRef;
+
+@WebService
+public interface AddNumbers {
+    @WebMethod
+    int addNumbers(@WebParam
+                   @XmlAttachmentRef
+                   DataHandler body);
+}

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbersImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbersImpl.java?rev=598951&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbersImpl.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/attachment/AddNumbersImpl.java
Wed Nov 28 02:47:41 2007
@@ -0,0 +1,30 @@
+/**
+ * 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.attachment;
+
+
+@javax.jws.WebService(targetNamespace = "http://apache.org/attachment",
+                      endpointInterface = "org.apache.attachment.AddNumbers")
+public class AddNumbersImpl implements AddNumbers {
+
+    public int addNumbers(javax.activation.DataHandler body) {
+        return 1;
+    }
+
+}

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=598951&r1=598950&r2=598951&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Wed Nov 28 02:47:41 2007
@@ -256,6 +256,22 @@
 
     }
     
+    @Test
+    public void testXmlAttachementRef() throws Exception {
+        String[] args = new String[] {"-o", output.getPath() + "/swa-ref.wsdl", "-verbose",
+                                      "-wsdl", "org.apache.attachment.AddNumbersImpl"};
+        JavaToWS.main(args);
+        File file = new File(output.getPath() + "/AddNumbers.wsdl");
+        String str = FileUtils.getStringFromFile(file);
+        String swaImport = "<xsd:import  namespace=\"http://ws-i.org/profiles/basic/1.1/xsd\""

+            + "  schemaLocation=\"http://ws-i.org/profiles/basic/1.1/swaref.xsd\"";
+        
+        assertTrue("Java2wsdl did not generate swaRef type element", 
+                   str.indexOf(":swaRef") > -1 && str.indexOf(swaImport) >
-1);
+        
+    }
+    
+    
     protected String getClassPath() throws URISyntaxException {
         ClassLoader loader = getClass().getClassLoader();
         StringBuffer classPath = new StringBuffer();

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?rev=598951&r1=598950&r2=598951&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Wed Nov 28 02:47:41 2007
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.Collection;
+
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.BusFactory;
@@ -41,12 +42,13 @@
 import org.junit.Test;
 
 public class JaxwsServiceBuilderTest extends ProcessorTestBase {
-    JaxwsServiceBuilder builder = new JaxwsServiceBuilder();
+    JaxwsServiceBuilder builder;
     WSDL11Generator generator = new WSDL11Generator();
 
     @Before
     public void setUp() throws Exception {
         super.setUp();
+        builder = new JaxwsServiceBuilder();
         builder.setBus(BusFactory.getDefaultBus());
         generator.setBus(builder.getBus());
     }
@@ -60,7 +62,6 @@
     public void testGetOutputFile() {
         builder.setServiceClass(Stock.class);
         assertNull(builder.getOutputFile());
-
         builder.setServiceClass(Hello.class);
         assertNotNull(builder.getOutputFile());
         File expected = new File("file:///c:/tmp.wsdl");



Mime
View raw message