cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r945464 - in /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/common/src/main/java/org/apache/cxf/tools/common/model/ tools/javato/ws/src/main/j...
Date Tue, 18 May 2010 02:25:40 GMT
Author: dkulp
Date: Tue May 18 02:25:40 2010
New Revision: 945464

URL: http://svn.apache.org/viewvc?rev=945464&view=rev
Log:
Start supporting some of the jaxws 2.2 extra fault properties

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanAnnotator.java
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Tue May 18 02:25:40 2010
@@ -348,27 +348,76 @@ public class JaxWsServiceConfiguration e
             return null;
         }
     }
+    @Override
+    public String getRequestWrapperPartName(OperationInfo op, Method method) {
+        method = getDeclaredMethod(method);
+        RequestWrapper rw = method.getAnnotation(RequestWrapper.class);
+        if (rw != null) {
+            return getWithReflection(RequestWrapper.class, rw, "partName");
+        }
+        return null;
+    }
 
     @Override
     public String getResponseWrapperPartName(OperationInfo op, Method method) {
         method = getDeclaredMethod(method);
         WebResult webResult = getWebResult(method);
+        ResponseWrapper rw = method.getAnnotation(ResponseWrapper.class);
+        if (rw != null) {
+            String pn = getWithReflection(ResponseWrapper.class, rw, "partName");
+            if (pn != null) {
+                return pn;
+            }
+        }
+        int countOut = 0;
+        int countHeaders = 0;
+        
         if (webResult != null
             && webResult.header()) {
-            for (int x = 0; x < method.getParameterTypes().length; x++) {
-                WebParam parm = getWebParam(method, x);
-                if (parm != null
-                    && !parm.header()
-                    && parm.mode() != WebParam.Mode.IN) {
-                    return null;
+            countHeaders++;
+        } else if (method.getReturnType() != Void.TYPE) {
+            countOut++;
+        }
+        
+        for (int x = 0; x < method.getParameterTypes().length; x++) {
+            WebParam parm = getWebParam(method, x);
+            if (parm != null) {                
+                if (parm.header()) {
+                    countHeaders++;
+                }
+                if (parm.mode() != WebParam.Mode.IN) {
+                    countOut++;
                 }
             }
+        }
+        if (countHeaders > 0 && countOut == 0) {
             //all outs are headers, thus it's an empty body part
             //thus return the default for an empty part of "result"
             return "result";
         }
         return null;
     }  
+    public String getFaultMessageName(OperationInfo op, Class<?> exClass, Class<?>
beanClass) {
+        WebFault f = exClass.getAnnotation(WebFault.class);
+        if (f != null) {
+            return getWithReflection(WebFault.class, f, "messageName");
+        }
+        
+        System.out.println(exClass.getName() + " has no WebFault");
+        return null;
+    }
+
+    private  <T> String getWithReflection(Class<T> cls, T obj, String name) {
+        try {
+            String s = cls.getMethod(name).invoke(obj).toString();
+            if (!StringUtils.isEmpty(s)) {
+                return s;
+            }
+        } catch (Exception e) {
+            //ignore = possibly JAX-WS 2.1
+        }
+        return null;
+    }
 
     @Override
     public QName getOutParameterName(OperationInfo op, Method method, int paramNumber) {
      

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
Tue May 18 02:25:40 2010
@@ -162,6 +162,9 @@ public abstract class AbstractServiceCon
     public String getResponseWrapperPartName(OperationInfo op, Method method) {
         return null;        
     }  
+    public String getRequestWrapperPartName(OperationInfo op, Method method) {
+        return null;        
+    }  
  
     public Class getResponseWrapper(Method selected) {
         return null;
@@ -202,4 +205,8 @@ public abstract class AbstractServiceCon
     public Long getWrapperPartMinOccurs(MessagePartInfo mpi) {
         return null;
     }
+
+    public String getFaultMessageName(OperationInfo op, Class<?> exClass, Class<?>
beanClass) {
+        return null;
+    }
 }

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Tue May 18 02:25:40 2010
@@ -1632,7 +1632,18 @@ public class ReflectionServiceFactoryBea
     
 
     protected void createInputWrappedMessageParts(OperationInfo op, Method method, MessageInfo
inMsg) {
-        MessagePartInfo part = inMsg.addMessagePart("parameters");
+        String partName = null;
+        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
+            AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
+            partName = c.getRequestWrapperPartName(op, method);
+            if (partName != null) {
+                break;
+            }
+        }
+        if (partName == null) {
+            partName = "parameters";
+        }
+        MessagePartInfo part = inMsg.addMessagePart(partName);
         part.setElement(true);
         for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
             AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
@@ -2046,14 +2057,25 @@ public class ReflectionServiceFactoryBea
         if (beanClass == null) {
             return null;
         }
+        String faultMsgName = null;
+        for (Iterator itr = serviceConfigurations.iterator(); itr.hasNext();) {
+            AbstractServiceConfiguration c = (AbstractServiceConfiguration)itr.next();
+            faultMsgName = c.getFaultMessageName(op, exClass, beanClass);
+            if (faultMsgName != null) {
+                break;
+            }
+        }
+        if (faultMsgName == null) {
+            faultMsgName = exClass.getSimpleName();
+        }
 
         QName faultName = getFaultName(service, op, exClass, beanClass);
-        FaultInfo fi = op.addFault(new QName(op.getName().getNamespaceURI(), exClass.getSimpleName()),
-                                   new QName(op.getName().getNamespaceURI(), exClass.getSimpleName()));
+        FaultInfo fi = op.addFault(new QName(op.getName().getNamespaceURI(), faultMsgName),
+                                   new QName(op.getName().getNamespaceURI(), faultMsgName));
         fi.setProperty(Class.class.getName(), exClass);
         fi.setProperty("elementName", faultName);
-        MessagePartInfo mpi = fi.addMessagePart(new QName(faultName.getNamespaceURI(), exClass
-            .getSimpleName()));
+        MessagePartInfo mpi = fi.addMessagePart(new QName(faultName.getNamespaceURI(), 
+                                                          exClass.getSimpleName()));
         mpi.setElementQName(faultName);
         mpi.setTypeClass(beanClass);
         sendEvent(Event.OPERATIONINFO_FAULT, op, exClass, fi);

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
(original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
Tue May 18 02:25:40 2010
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.tools.common.model;
 
+import java.lang.reflect.Array;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -78,10 +79,19 @@ public final class JAnnotationElement {
                 for (int i = 0; i < list.size(); i++) {
                     appendValue(sb, list.get(i));
                     if (i < list.size() - 1) {
-                        sb.append(",");
+                        sb.append(", ");
                     }
                 }
                 sb.append("}");
+            } else if (value instanceof String[]) {
+                sb.append("{");
+                for (int i = 0; i < Array.getLength(value); i++) {
+                    appendValue(sb, Array.get(value, i));
+                    if (i < Array.getLength(value) - 1) {
+                        sb.append(", ");
+                    }
+                }                
+                sb.append("}");
             } else {
                 appendValue(sb, value);
             }

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanAnnotator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanAnnotator.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanAnnotator.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/annotator/WrapperBeanAnnotator.java
Tue May 18 02:25:40 2010
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlAcce
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.tools.common.model.Annotator;
 import org.apache.cxf.tools.common.model.JAnnotation;
 import org.apache.cxf.tools.common.model.JAnnotationElement;
@@ -34,7 +35,15 @@ import org.apache.cxf.tools.common.model
 import org.apache.cxf.tools.common.model.JavaField;
 import org.apache.cxf.tools.java2wsdl.generator.wsdl11.model.WrapperBeanClass;
 public class WrapperBeanAnnotator implements Annotator {
-
+    Class<?> sourceClass;
+    
+    public WrapperBeanAnnotator() {
+        
+    }
+    public WrapperBeanAnnotator(Class<?> cls) {
+        this.sourceClass = cls;
+    }
+    
     public void annotate(final JavaAnnotatable clz) {
         WrapperBeanClass beanClass = null;
         if (clz instanceof WrapperBeanClass) {
@@ -52,12 +61,36 @@ public class WrapperBeanAnnotator implem
         JAnnotation xmlAccessorType = new JAnnotation(XmlAccessorType.class);
         xmlAccessorType.addElement(new JAnnotationElement(null, XmlAccessType.FIELD));
 
+        XmlType tp = null;
+        if (sourceClass != null) {
+            tp = sourceClass.getAnnotation(XmlType.class);
+        }
         JAnnotation xmlType = new JAnnotation(XmlType.class);
-        xmlType.addElement(new JAnnotationElement("name", 
+        if (tp == null) {
+            xmlType.addElement(new JAnnotationElement("name", 
                                                   beanClass.getElementName().getLocalPart()));
-        xmlType.addElement(new JAnnotationElement("namespace", 
+            xmlType.addElement(new JAnnotationElement("namespace", 
                                                   beanClass.getElementName().getNamespaceURI()));
-        
+        } else {
+            if (!"##default".equals(tp.name())) {
+                xmlType.addElement(new JAnnotationElement("name", 
+                                                          tp.name()));
+            }
+            if (!"##default".equals(tp.namespace())) {
+                xmlType.addElement(new JAnnotationElement("namespace", 
+                                                          tp.namespace()));
+            }
+            if (!StringUtils.isEmpty(tp.factoryMethod())) {
+                xmlType.addElement(new JAnnotationElement("factoryMethod",
+                                                          tp.factoryMethod()));
+            }
+            if (tp.propOrder().length != 1 
+                || !StringUtils.isEmpty(tp.propOrder()[0])) {
+                xmlType.addElement(new JAnnotationElement("propOrder", 
+                                                      tp.propOrder()));
+            }
+            
+        }
         List<String> props = new ArrayList<String>();
         for (JavaField f : beanClass.getFields()) {
             props.add(f.getParaName());

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java?rev=945464&r1=945463&r2=945464&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
Tue May 18 02:25:40 2010
@@ -87,7 +87,7 @@ public final class FaultBean {
             jClass.setElementName(new QName(URIParserUtil.getNamespace(ToolConstants.DEFAULT_PACKAGE_NAME),
                                         exceptionClass.getSimpleName()));
         }
-        jClass.annotate(new WrapperBeanAnnotator());
+        jClass.annotate(new WrapperBeanAnnotator(exceptionClass));
         
         return jClass;
     }



Mime
View raw message