You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/05/21 19:26:38 UTC

svn commit: r658770 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/tools/common/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ ...

Author: dkulp
Date: Wed May 21 10:26:37 2008
New Revision: 658770

URL: http://svn.apache.org/viewvc?rev=658770&view=rev
Log:
Merged revisions 658766 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r658766 | dkulp | 2008-05-21 13:16:36 -0400 (Wed, 21 May 2008) | 4 lines
  
  [CXF-1600, CXF-1601] 
  * Add -autoNameResolution flag to wsdl2java to have it handle jaxb classname conflicts automatically instead of requiring a jaxb bindings file.
  * Fix some issues of mapping out-of-band headers out of wsdl
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=658770&r1=658769&r2=658770&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Wed May 21 10:26:37 2008
@@ -38,6 +38,7 @@
     public static final String CFG_VERBOSE = "verbose";
     public static final String CFG_PORT = "port";
     public static final String CFG_BINDING = "binding";
+    public static final String CFG_AUTORESOLVE = "autoNameResolution";
     public static final String CFG_WEBSERVICE = "webservice";
     public static final String CFG_SERVER = "server";
     public static final String CFG_CLIENT = "client";

Modified: cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=658770&r1=658769&r2=658770&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
+++ cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Wed May 21 10:26:37 2008
@@ -403,7 +403,7 @@
             if (def != null && schemas != null) {
                 javax.wsdl.Message msg = def.getMessage(header.getMessage());
                 if (msg != null) {
-                    addOutOfBandParts(bop, msg, schemas, isInput);
+                    addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
                     serviceInfo.refresh();
                 } else {
                     throw new RuntimeException("Header message not defined in service model.");
@@ -413,7 +413,8 @@
     }
 
     private void addOutOfBandParts(final BindingOperationInfo bop, final javax.wsdl.Message msg,
-                                   final SchemaCollection schemas, boolean isInput) {
+                                   final SchemaCollection schemas, boolean isInput,
+                                   final String partName) {
         MessageInfo minfo = null;
         int nextId = 0;
         minfo = bop.getOperationInfo().getInput();
@@ -442,7 +443,7 @@
         if (minfo == null) {
             minfo = new MessageInfo(null, msg.getQName());
         }
-        buildMessage(minfo, msg, schemas, nextId);
+        buildMessage(minfo, msg, schemas, nextId, partName);
 
         // for wrapped style
         OperationInfo unwrapped = bop.getOperationInfo().getUnwrappedOperation();
@@ -478,29 +479,35 @@
         if (minfo == null) {
             minfo = new MessageInfo(unwrapped, msg.getQName());
         }
-        buildMessage(minfo, msg, schemas, nextId);
+        buildMessage(minfo, msg, schemas, nextId, partName);
     }
 
     private void buildMessage(MessageInfo minfo,
                               javax.wsdl.Message msg,
                               SchemaCollection schemas,
-                              int nextId) {
+                              int nextId,
+                              String partNameFilter) {
         for (Part part : cast(msg.getParts().values(), Part.class)) {
-            MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(), part
-                                                                .getName()));
-            if (part.getTypeName() != null) {
-                pi.setTypeQName(part.getTypeName());
-                pi.setElement(false);
-                pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
-            } else {
-                pi.setElementQName(part.getElementName());
-                pi.setElement(true);
-                pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
+            
+            if (StringUtils.isEmpty(partNameFilter)
+                || part.getName().equals(partNameFilter)) {
+            
+                MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(), part
+                                                                    .getName()));
+                if (part.getTypeName() != null) {
+                    pi.setTypeQName(part.getTypeName());
+                    pi.setElement(false);
+                    pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
+                } else {
+                    pi.setElementQName(part.getElementName());
+                    pi.setElement(true);
+                    pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
+                }
+                pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
+                pi.setProperty(HEADER, Boolean.TRUE);
+                pi.setIndex(nextId);
+                nextId++;
             }
-            pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
-            pi.setProperty(HEADER, Boolean.TRUE);
-            pi.setIndex(nextId);
-            nextId++;
         }
     }
 

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java?rev=658770&r1=658769&r2=658770&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java (original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java Wed May 21 10:26:37 2008
@@ -21,15 +21,17 @@
 
 import com.sun.tools.xjc.api.ClassNameAllocator;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.tools.util.ClassCollector;
 
 public class ClassNameAllocatorImpl implements ClassNameAllocator {
     private static final String TYPE_SUFFIX = "_Type";
     private ClassCollector collector;
+    private boolean autoResolveConflicts;
 
-    public ClassNameAllocatorImpl(ClassCollector classCollector) {
+    public ClassNameAllocatorImpl(ClassCollector classCollector, boolean autoResolve) {
         collector = classCollector;
-
+        autoResolveConflicts = autoResolve;
     }
 
     private boolean isNameCollision(String packageName, String className) {
@@ -41,7 +43,24 @@
         if (isNameCollision(packageName, className)) {
             fullClzName = className + TYPE_SUFFIX;
         }
-        collector.addTypesClassName(packageName, className, packageName + "." + fullClzName);
+        String fullPckClass = packageName + "." + fullClzName;
+        
+        if (autoResolveConflicts) {
+            String t2 = collector.getTypesFullClassName(packageName, className);
+            int cnt = 1;
+            while (!StringUtils.isEmpty(t2)) {
+                
+                cnt++;
+                t2 = collector.getTypesFullClassName(packageName, className + cnt);
+            }
+            if (cnt != 1) {
+                className = className + cnt;
+                fullClzName = fullClzName + cnt;
+                fullPckClass = packageName + "." + fullClzName;
+            }
+        }
+        collector.addTypesClassName(packageName, className, fullPckClass);
+        
         return fullClzName;
     }
    

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=658770&r1=658769&r2=658770&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Wed May 21 10:26:37 2008
@@ -129,7 +129,11 @@
         
         SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
         ClassCollector classCollector = context.get(ClassCollector.class);
-        ClassNameAllocatorImpl allocator = new ClassNameAllocatorImpl(classCollector);
+        
+        
+        ClassNameAllocatorImpl allocator 
+            = new ClassNameAllocatorImpl(classCollector,
+                                         c.optionSet(ToolConstants.CFG_AUTORESOLVE));
 
         schemaCompiler.setClassNameAllocator(allocator);
            

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=658770&r1=658769&r2=658770&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml (original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml Wed May 21 10:26:37 2008
@@ -159,6 +159,14 @@
                 </annotation>
                 <switch>all</switch>
             </option>
+            
+            <option id="autoNameResolution" maxOccurs="1">
+                <annotation>
+                    If there are conflicts in the generated classnames, try to auto-generate new
+                    classnames instead of forcing the use of binding customizations.
+                </annotation>
+                <switch>autoNameResolution</switch>
+            </option>
 
 	        <option id="defaultValues" maxOccurs="1">
                 <annotation>



Re: svn commit: r658770 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/tools/common/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ ...

Posted by Daniel Kulp <dk...@apache.org>.
On May 21, 2008, at 7:22 PM, Glen Mazza wrote:

> BTW, if I want to make changes to the latest/nightly of the 2.0.x
> branch, I need to use the 2.0.x-fixes tag and *not* the 2.0.6 one,
> correct?

Yep.   Just checkout:
http://svn.apache.org/repos/asf/cxf/branches/2.0.x-fixes/
and make any changes.

For the most part, however, if the fixes/changes should be applied to  
trunk as well, it's easier to just to do them on trunk and use  
svnmerge.py to merge them over to 2.0.x.  Or, wait for me to merge  
them over.  :-)


---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog





Re: svn commit: r658770 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/tools/common/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ ...

Posted by Glen Mazza <gl...@verizon.net>.
BTW, if I want to make changes to the latest/nightly of the 2.0.x
branch, I need to use the 2.0.x-fixes tag and *not* the 2.0.6 one,
correct?


2008-05-21 dkulp@apache.org wrote:
> Author: dkulp
> Date: Wed May 21 10:26:37 2008
> New Revision: 658770
> 
> ==============================================================================
> ---
> cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
> +++
> cxf/branches/2.0.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Wed May 21 10:26:37 2008
> @@ -403,7 +403,7 @@
>              if (def != null && schemas != null) {
>                  javax.wsdl.Message msg =
> def.getMessage(header.getMessage());
>                  if (msg != null) {
> -                    addOutOfBandParts(bop, msg, schemas, isInput);
> +                    addOutOfBandParts(bop, msg, schemas, isInput,
> header.getPart());


Any serious risk of this NPE'ing?

Regards,
Glen