axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject RE: cvs commit: xml-axis/java/tools/org/apache/axis/tools/ant/wsd l Wsdl2javaAntTask.java
Date Mon, 06 Jan 2003 18:59:05 GMT
Should i turn them into RuntimeException's?

Thanks,
dims

--- Tom Jordahl <tomj@macromedia.com> wrote:
> 
> Hi Dims,
> 
> There are a lot of new System.err.println() calls in this patch.
> 
> Are we sure we want to do this?  The Emitter is the class that get called programmatically
by
> people who embed Axis....
> 
> 
> --
> Tom Jordahl
> Macromedia Server Development
> 
> 
> 
> -----Original Message-----
> From: dims@apache.org [mailto:dims@apache.org]
> Sent: Monday, December 30, 2002 1:06 PM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit: xml-axis/java/tools/org/apache/axis/tools/ant/wsdl
> Wsdl2javaAntTask.java
> 
> 
> dims        2002/12/30 10:05:42
> 
>   Modified:    java/src/org/apache/axis/wsdl/toJava Emitter.java
>                java/src/org/apache/axis/i18n resource.properties
>                java/tools/org/apache/axis/tools/ant/wsdl
>                         Wsdl2javaAntTask.java
>   Log:
>   Fix for Bug 15675 - Ant Task WDSL2java - property namespacemappingfile broken
>   from karl.guggisberg@guggis.ch (Karl Guggisberg)
>   
>   Revision  Changes    Path
>   1.55      +64 -30    xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
>   
>   Index: Emitter.java
>   ===================================================================
>   RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
>   retrieving revision 1.54
>   retrieving revision 1.55
>   diff -u -r1.54 -r1.55
>   --- Emitter.java	11 Dec 2002 22:38:30 -0000	1.54
>   +++ Emitter.java	30 Dec 2002 18:05:42 -0000	1.55
>   @@ -58,6 +58,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 +89,14 @@
>     * @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;
>    
>        private boolean bEmitServer = false;
>        private boolean bDeploySkeleton = false;
>   @@ -249,12 +252,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 +420,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
>    
>   
>   
>   
>   1.39      +4 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
>   
>   Index: resource.properties
>   ===================================================================
>   RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
>   retrieving revision 1.38
>   retrieving revision 1.39
>   diff -u -r1.38 -r1.39
>   --- resource.properties	20 Dec 2002 17:28:22 -0000	1.38
>   +++ resource.properties	30 Dec 2002 18:05:42 -0000	1.39
>   @@ -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 
=== message truncated ===


=====
Davanum Srinivas - http://xml.apache.org/~dims/

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Mime
View raw message