cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r537095 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/jaxb/ common/common/src/test/java/org/apache/cxf/jaxb/ tools/common/src/main/java/org/apache/cxf/tools/util/ tools/wsdlto/databinding/jaxb/src/main/java/org/apach...
Date Fri, 11 May 2007 05:03:27 GMT
Author: ema
Date: Thu May 10 22:03:26 2007
New Revision: 537095

URL: http://svn.apache.org/viewvc?view=rev&rev=537095
Log:
* Fixed issue CXF-640
* Fix the namespaceToPackage mapping issue with urn in JAXBUtils

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
    incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?view=diff&rev=537095&r1=537094&r2=537095
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Thu
May 10 22:03:26 2007
@@ -155,11 +155,12 @@
      * @return the package name.
      */
     public static String nameSpaceURIToPackage(URI uri) {
-        
-        StringBuffer packageName = new StringBuffer();   
-        
+       
+        StringBuffer packageName = new StringBuffer();
         String authority = uri.getAuthority();
-        
+        if (authority == null && "urn".equals(uri.getScheme())) {
+            authority = uri.getSchemeSpecificPart();
+        }
         
         if (null != authority && !"".equals(authority)) {
             if ("urn".equals(uri.getScheme())) {
@@ -167,12 +168,26 @@
                 for (int i = 0; i < packageName.length(); i++) {
                     if (packageName.charAt(i) == '-') {
                         packageName.setCharAt(i, '.');
+                    } 
+                }
+                authority = packageName.toString();
+                packageName.setLength(0);
+                
+                StringTokenizer st = new StringTokenizer(authority, ":");
+                while (st.hasMoreTokens()) {
+                    String token = st.nextToken();
+                    if (packageName.length() > 0) {
+                        packageName.insert(0, ".");
+                        packageName.insert(0, normalizePackageNamePart(token));
+                    } else {
+                        packageName.insert(0, token);
                     }
                 }
                 authority = packageName.toString();
                 packageName.setLength(0);
-            }
-
+                
+            }  
+            
             StringTokenizer st = new StringTokenizer(authority, ".");
             if (st.hasMoreTokens()) {
                 String token = null;
@@ -185,18 +200,16 @@
                     } else {
                         packageName.insert(0, ".");
                     }
-                    packageName.insert(0, token);
-                }
-
-                if (!("com".equals(token) || "gov".equals(token) || "net".equals(token)
-                      || "org".equals(token) || "edu".equals(token))) {
-                    packageName.setLength(0);
-
+                    packageName.insert(0, normalizePackageNamePart(token));
                 }
+               
             }
         }
 
         String path = uri.getPath();
+        if (path == null) {
+            path = "";
+        }
         int index = path.lastIndexOf('.');
         if (index < 0) {
             index = path.length();

Modified: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java?view=diff&rev=537095&r1=537094&r2=537095
==============================================================================
--- incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
(original)
+++ incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/jaxb/JAXBUtilsTest.java
Thu May 10 22:03:26 2007
@@ -112,4 +112,15 @@
         assertEquals("OTHER_PUNCT_CHARS", 
                      JAXBUtils.nameToIdentifier("other_punct-chars", JAXBUtils.IdentifierType.CONSTANT));
     }
+    
+    @Test
+    public void testNsToPkg() {
+        String urn = "urn:cxf.apache.org";     
+        String pkg = JAXBUtils.namespaceURIToPackage(urn);
+        assertEquals("org.apache.cxf", pkg);
+        
+        urn = "urn:cxf.apache.org:test.v4.6.4";
+        pkg = JAXBUtils.namespaceURIToPackage(urn);
+        assertEquals("org.apache.cxf.test_v4_6_4", pkg);       
+    }
 }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java?view=diff&rev=537095&r1=537094&r2=537095
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java
Thu May 10 22:03:26 2007
@@ -104,7 +104,7 @@
         Element rootElement = doc.createElement("schema");
         rootElement.setAttribute("xmlns", ToolConstants.SCHEMA_URI);
         rootElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
-        rootElement.setAttribute("jaxb:version", "1.0");
+        rootElement.setAttribute("jaxb:version", "2.0");
         rootElement.setAttribute("targetNamespace", namespace);
         Element annoElement = doc.createElement("annotation");
         Element appInfo = doc.createElement("appinfo");

Modified: incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=537095&r1=537094&r2=537095
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Thu May 10 22:03:26 2007
@@ -70,12 +70,13 @@
     private void initialize(ToolContext c) throws ToolException {
         this.context = c;
 
+        
         SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
         ClassCollector classCollector = context.get(ClassCollector.class);
         ClassNameAllocatorImpl allocator = new ClassNameAllocatorImpl(classCollector);
 
         schemaCompiler.setClassNameAllocator(allocator);
-
+           
         JAXBBindErrorListener listener = new JAXBBindErrorListener(context.isVerbose());
         schemaCompiler.setErrorListener(listener);
         // Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
@@ -101,17 +102,23 @@
             schemaCompiler.parseSchema(binding);
         }
 
-        if (context.getPackageName() != null) {
+        /*if (context.getPackageName() != null) {
             schemaCompiler.forcePackageName(context.getPackageName());
-        } else {
-            Map<String, String> nsPkgMap = context.getNamespacePackageMap();
-            for (String ns : nsPkgMap.keySet()) {
-                File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, nsPkgMap.get(ns));
-                InputSource ins = new InputSource(file.toURI().toString());
-                schemaCompiler.parseSchema(ins);
-                FileUtils.delete(file);
-            }
+        } else {*/
+            
+            
+        Map<String, String> nsPkgMap = context.getNamespacePackageMap();
+        for (String ns : nsPkgMap.keySet()) {
+            File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
+            InputSource ins = new InputSource(file.toURI().toString());
+            schemaCompiler.parseSchema(ins);
+            FileUtils.delete(file);
         }
+        
+        if (context.getPackageName() != null) {
+            schemaCompiler.setDefaultPackageName(context.getPackageName());
+        }  
+        
 
         rawJaxbModelGenCode = schemaCompiler.bind();
 

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=537095&r1=537094&r2=537095
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Thu May 10 22:03:26 2007
@@ -457,12 +457,39 @@
         env.put(ToolConstants.CFG_BINDING, "http://localhost:8585/remote-hello_world_binding.xsd");
         processor.setContext(env);
         processor.execute();
-        server.stop();
+        server.stop();      
+        
+    }
+    
+    
+    @Test
+    public void testDefaultNSWithPkg() throws Exception {
+        String[] args = new String[] {"-d", output.getCanonicalPath(), "-p", "org.cxf",
+                                      getLocation("/wsdl2java_wsdl/basic_callback.wsdl")};
 
+        WSDLToJava.main(args);
         
+        assertNotNull(output);
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File cxf = new File(apache, "cxf");
+        assertTrue(cxf.exists());
+        File ws = new File(cxf, "ws");
+        assertTrue(ws.exists());
+        File address = new File(ws, "addressing");
+        assertTrue(address.exists());
+
+        File[] files = address.listFiles();
+        assertEquals(11, files.length);
         
+        cxf = new File(output, "org/cxf");
+        assertTrue(cxf.exists());
+        files = cxf.listFiles();
+        assertEquals(5, files.length);
+
     }
-    
     
     
     



Mime
View raw message