axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15675] New: - Ant Task WDSL2java - property namespacemappingfile broken
Date Fri, 27 Dec 2002 00:12:37 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15675>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15675

Ant Task WDSL2java - property namespacemappingfile broken

           Summary: Ant Task WDSL2java - property namespacemappingfile
                    broken
           Product: Axis
           Version: current (nightly)
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: WSDL processing
        AssignedTo: axis-dev@xml.apache.org
        ReportedBy: karl.guggisberg@guggis.ch


*******************************************
*** Example
*******************************************
<target name="wsdl2java">
  <wsdl2java
     url="sample2.wsdl"
     output="outputdir"
     <!-- mapping file is not loaded, but file exists and is readable;
         no warning or error message displayed -->
     namespacemappingfile="c:\sample2\namespace2package.properties"	
  />		
</target>

*******************************************
*** Patch
*******************************************
Here are three patches which solve the problem
1) org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
2) org/apache/axis/i18n/resource.properties 
3) org/apache/axis/wsdl/toJava/Emitter.java



Index: Wsdl2javaAntTask.java
===================================================================
RCS file: /home/cvspublic/xml-
axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java,v
retrieving revision 1.8
diff -r1.8 Wsdl2javaAntTask.java
199,201c199
<         if(namespaceMappingFile==null) {
<             namespaceMappingFile = getProject().resolveFile
("NStoPkg.properties");
<         }
---
>      
237c235,237
<             emitter.setNStoPkg(namespaceMappingFile);
---
> 	        if (namespaceMappingFile != null) {
> 	            emitter.setNStoPkg(namespaceMappingFile.toString());
> 	        }    
434a435,436
>     
>     

Index: resource.properties
===================================================================
RCS file: /home/cvspublic/xml-
axis/java/src/org/apache/axis/i18n/resource.properties,v
retrieving revision 1.38
diff -u -r1.38 resource.properties
--- resource.properties	20 Dec 2002 17:28:22 -0000	1.38
+++ resource.properties	27 Dec 2002 00:05:18 -0000
@@ -1083,3 +1083,7 @@
 wsdlFileMissing=Unable to find WSDL file or resource {0}
 nullEngine=Null engine passed to SOAPService.setEngine()!
 servletEngineWebInfError03=Unable to find config file.  Creating new servlet 
engine config file: {0}
+nsToPkgFileNotFound00=WARNING: Unable to open namespace-to-package mapping 
file "{0}". Using default mappings.
+nsToPkgFileLoaded00=INFO: Loaded namespace-to-package mapping file "{0}".
+nsToPkgDefaultFileLoaded00=INFO: Loaded default namespace-to-package mapping 
file "{0}" as java resource.
+nsToPkgDefaultFileNotFound00=WARNING: Unable to open default namespace-to-
package mapping file "{0}". Using default mappings.



Index: Emitter.java
===================================================================
RCS file: /home/cvspublic/xml-
axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
retrieving revision 1.54
diff -u -r1.54 Emitter.java
--- Emitter.java	11 Dec 2002 22:38:30 -0000	1.54
+++ Emitter.java	27 Dec 2002 00:06:29 -0000
@@ -34,7 +34,8 @@
  *    permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * WARRANTIES, INCLUD
+ * ING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -58,6 +59,7 @@
 import org.apache.axis.encoding.DefaultTypeMappingImpl;
 import org.apache.axis.encoding.TypeMapping;
 import org.apache.axis.enum.Scope;
+import org.apache.axis.i18n.Messages;
 import org.apache.axis.utils.ClassUtils;
 import org.apache.axis.utils.JavaUtils;
 import org.apache.axis.wsdl.gen.GeneratorFactory;
@@ -88,12 +90,16 @@
  * @author Steve Graham (sggraham@us.ibm.com)
  */
 public class Emitter extends Parser {
+	
+	public static final String DEFAULT_NSTOPKG_FILE = "NStoPkg.properties";
+	
+	
     protected HashMap namespaceMap = new HashMap();
     protected String typeMappingVersion = "1.1";
     protected BaseTypeMapping baseTypeMapping = null;
     protected Namespaces namespaces = null;
-    protected String NStoPkgFilename = "NStoPkg.properties";
-    protected File NStoPkgFile = null;
+    protected String NStoPkgFilename = null;
+    //protected File NStoPkgFile = null;
 
     private boolean bEmitServer = false;
     private boolean bDeploySkeleton = false;
@@ -249,12 +255,7 @@
         }
     } // setNStoPkg
 
-    /**
-     * Set the NStoPkg mappings file.
-     */
-    public void setNStoPkg(File NStoPkgFile) {
-        this.NStoPkgFile = NStoPkgFile;
-    } // setNStoPkg
+
 
     /**
      * Set a map of namespace -> Java package names
@@ -422,36 +423,72 @@
         }
     } // setup
 
+
     /**
-     * Look for a NStoPkg.properties file in the CLASSPATH.  If it exists,
-     * then collect the namespace->package mappings from it.
+	 * Tries to load the namespace-to-package mapping file.
+	 * <ol>
+	 *   <li>if a file name is explicitly set using <code>setNStoPkg()
</code>, tries
+	 *      to load the mapping from this file. If this fails, the built-
in default
+	 *      mapping is used.
+	 * 
+	 *    <li>if no file name is set, tries to load the file 
<code>DEFAULT_NSTOPKG_FILE</code>
+	 *       as a java resource. If this fails, the built-in dfault 
mapping is used.
+	 * </ol>
+	 * 
+	 * @param namespaces  a hashmap which is filled with the namespace-to-
package mapping
+	 *    in this method
+	 * 
+	 * @see #setNStoPkg(String)
+	 * @see #DEFAULT_NSTOPKG_FILE
+	 * @see org.apache.axis.utils.ClassUtils#getResourceAsStream
(java.lang.Class,String)
+	 * 
      */
     private void getNStoPkgFromPropsFile(HashMap namespaces)
     {
-        try {
-            Properties mappings = new Properties();
-            if (NStoPkgFile != null) {
-                try {
-                    mappings.load(new FileInputStream(NStoPkgFilename));
-                } catch (Throwable t) {
-                    mappings.load(ClassUtils.getResourceAsStream(
-                            Emitter.class, NStoPkgFilename));
-                }
-            }
-            else {
+
+        Properties mappings = new Properties();
+        if (NStoPkgFilename != null) {
+            try {
                 mappings.load(new FileInputStream(NStoPkgFilename));
+                System.out.println(
+                  Messages.getMessage("nsToPkgFileLoaded00", NStoPkgFilename)
+                );
+            } catch (Throwable t) {
+				// loading the custom mapping file failed. We 
do not try
+				// to load the mapping from a default mapping 
file. 
+				System.err.println(
+                        Messages.getMessage("nsToPkgFileNotFound00", 
NStoPkgFilename)
+                );
             }
-            Enumeration keys = mappings.propertyNames();
-            while (keys.hasMoreElements()) {
-                try {
-                    String key = (String) keys.nextElement();
-                    namespaces.put(key, mappings.getProperty(key));
-                }
-                catch (Throwable t) {
-                }
+        }
+        else {
+            try {
+                mappings.load(new FileInputStream(DEFAULT_NSTOPKG_FILE));
+                System.out.println(
+                  Messages.getMessage("nsToPkgFileLoaded00", 
DEFAULT_NSTOPKG_FILE)
+                );
+            } catch (Throwable t) {
+            	try {
+                    mappings.load(ClassUtils.getResourceAsStream(
+                        Emitter.class, DEFAULT_NSTOPKG_FILE));
+                    System.out.println(
+                      Messages.getMessage("nsToPkgDefaultFileLoaded00", 
DEFAULT_NSTOPKG_FILE)
+                    );
+
+            	} catch(Throwable t1) {
+					// loading the default mapping file 
failed. The built-in default
+					// mapping is used 
+					System.err.println(
+                            Messages.getMessage
("nsToPkgDefaultFileNotFound00", DEFAULT_NSTOPKG_FILE)
+                    );                		
+            	}        
             }
         }
-        catch (Throwable t) {
+
+        Enumeration keys = mappings.propertyNames();
+        while (keys.hasMoreElements()) {
+            String key = (String) keys.nextElement();
+            namespaces.put(key, mappings.getProperty(key));
         }
     } // getNStoPkgFromPropsFile

Mime
View raw message