axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: ws-axis/java/tools/org/apache/axis/tools/ant/wsdl Wsdl2javaAntTask.java
Date Fri, 27 Feb 2004 15:00:14 GMT
tomj        2004/02/27 07:00:14

  Modified:    java/src/org/apache/axis/wsdl/toJava
                        JavaBuildFileWriter.java
               java/tools/org/apache/axis/tools/ant/wsdl
                        Wsdl2javaAntTask.java
  Log:
  Put back in build file generator code accidentaly commented out.
  Remove useless commented code from Ant task.
  
  Reformated both files to clean them up.
  
  Revision  Changes    Path
  1.4       +93 -90    ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBuildFileWriter.java
  
  Index: JavaBuildFileWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaBuildFileWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavaBuildFileWriter.java	25 Feb 2004 14:02:52 -0000	1.3
  +++ JavaBuildFileWriter.java	27 Feb 2004 15:00:14 -0000	1.4
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2001-2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -23,118 +23,121 @@
   import javax.wsdl.Definition;
   
   import org.apache.axis.wsdl.symbolTable.SymbolTable;
  +
   /**
    * <p>This is Wsdl2java's build file Writer.  It writes the build.xml file.
  - * The build.xml file is a ant build file. After run the WSDL2Java and filling 
  + * The build.xml file is a ant build file. After run the WSDL2Java and filling
    * the implementation the user just have to cd to the out dir and type
  - * and "ant" (of course you must have ant installed). Then the ant will genarate a 
  + * and "ant" (of course you must have ant installed). Then the ant will genarate a
    * jar file which named after the wsdl file you used for WSDL2Java.
  - * (named after wsdl file ??? I do not get anything better .. the wsdl file may have 
  + * (named after wsdl file ??? I do not get anything better .. the wsdl file may have
    * more than one service ect ... so we can use them.)</p>
  - * 
  - * <p>This build file work on the where it is created ... User can not move the genarated
code 
  + *
  + * <p>This build file work on the where it is created ... User can not move the genarated
code
    * to another mechine and try to build. (class path is broken). But of cource user can
    * move genarated build file at his will.</p>
  - * 
  + *
    * <p>deploy the webservice using the AdminClient and drop the jar to servlet Container.
  - * We might even add another task to deploy the WS as well.</p> 
  - * 
  + * We might even add another task to deploy the WS as well.</p>
  + *
    * <p>This feature can be on and off using the -B option default is off</p>
    * @author Srinath Perera(hemapani@opensource.lk)
    */
  -public class JavaBuildFileWriter extends JavaWriter {
  -	protected Definition definition;
  +public class JavaBuildFileWriter extends JavaWriter
  +{
  +    protected Definition definition;
  +
  +    /** Field symbolTable */
  +    protected SymbolTable symbolTable;
   
  -	 /** Field symbolTable */
  -	 protected SymbolTable symbolTable;
   
       /**
  -     * @param emitter
  -     * @param type
  +     * Constructor
        */
  -	public JavaBuildFileWriter(Emitter emitter, Definition definition,
  -						 SymbolTable symbolTable) {
  +    public JavaBuildFileWriter(Emitter emitter, Definition definition,
  +                               SymbolTable symbolTable) {
  +
  +        super(emitter, "build");
   
  -	 super(emitter, "build");
  +        this.definition = definition;
  +        this.symbolTable = symbolTable;
  +    }
   
  -	 this.definition = definition;
  -	 this.symbolTable = symbolTable;
  -    }    
  -    
       protected String getFileName() {
  -		String dir = emitter.getOutputDir();
  -   		return dir + "/build.xml";
  +        String dir = emitter.getOutputDir();
  +        return dir + "/build.xml";
       }
   
       protected void writeFileBody(PrintWriter out) throws IOException {
  -		out.write("<?xml version=\"1.0\"?>\n");
  -        
  -		out.write("<project basedir=\".\" default=\"jar\">\n");
  -		out.write("	<property name=\"src\" location=\".\"/>\n");
  -		out.write("	<property name=\"build.classes\" location=\"classes\"/>\n");
  -        
  -		out.write("	<path id=\"classpath\">\n");
  -		StringTokenizer tok = getClasspathComponets();
  -		while(tok.hasMoreTokens()){
  -			out.write("		<pathelement location=\""+tok.nextToken()+"\"/>\n");
  -		}	
  -		out.write("	</path>\n");
  -        
  -		out.write("	<target name=\"compile\">\n");
  -		out.write("	   <mkdir dir=\"${build.classes}\"/>\n");
  -		out.write("		<javac destdir=\"${build.classes}\" debug=\"on\">\n");
  -		out.write("			<classpath refid=\"classpath\" />\n");
  -		out.write("			<src path=\"${src}\"/>\n");
  -		out.write("		</javac>\n");
  -		out.write("	</target>\n");
  -        
  -		out.write("	<target name=\"jar\" depends=\"compile\">\n");
  -		out.write("        <copy todir=\"${build.classes}\">\n");
  -		out.write("            <fileset dir=\".\" casesensitive=\"yes\" >\n");
  -		out.write("                <include name=\"**/*.wsdd\"/>\n");
  -		out.write("            </fileset>\n");
  -		out.write("        </copy>\n");
  -
  -		out.write("		<jar jarfile=\""+getJarFileName(symbolTable.getWSDLURI())+".jar\" basedir=\"${build.classes}\"
>\n");
  -		out.write("		<include name=\"**\" />\n");
  -		out.write("		<manifest>\n");
  -		out.write("			<section name=\"org/apache/ws4j2ee\">\n");
  -		out.write("			<attribute name=\"Implementation-Title\" value=\"Apache Axis\"/>\n");
  -		out.write("			<attribute name=\"Implementation-Vendor\" value=\"Apache Web Services\"/>\n");
  -		out.write("			</section>\n");
  -		out.write("		</manifest>\n");
  -		out.write("		</jar>\n");
  -		out.write("		<delete dir=\"${build.classes}\"/>\n");
  -		out.write("	</target>\n");
  -		out.write("</project>\n");
  -		out.close();
  -	}
  -	
  -	private StringTokenizer getClasspathComponets(){
  -		String classpath = System.getProperty("java.class.path");
  -		String spearator  = ";";
  -		if(classpath.indexOf(';') < 0){
  -			//then it is UNIX
  -			spearator = ":";
  -		}
  -		
  -		return new StringTokenizer(classpath,spearator);
  -	}
  -	
  -	private String getJarFileName(String wsdlFile){
  -		int index = 0;
  -		if((index = wsdlFile.lastIndexOf("/"))>0){
  -			wsdlFile = wsdlFile.substring(index+1);
  -		}
  -		return wsdlFile.substring(0,wsdlFile.indexOf('.'));
  -	}
  +        out.write("<?xml version=\"1.0\"?>\n");
  +
  +        out.write("<project basedir=\".\" default=\"jar\">\n");
  +        out.write("	<property name=\"src\" location=\".\"/>\n");
  +        out.write("	<property name=\"build.classes\" location=\"classes\"/>\n");
  +
  +        out.write("	<path id=\"classpath\">\n");
  +        StringTokenizer tok = getClasspathComponets();
  +        while (tok.hasMoreTokens()) {
  +            out.write("		<pathelement location=\"" + tok.nextToken() + "\"/>\n");
  +        }
  +        out.write("	</path>\n");
  +
  +        out.write("	<target name=\"compile\">\n");
  +        out.write("	   <mkdir dir=\"${build.classes}\"/>\n");
  +        out.write("		<javac destdir=\"${build.classes}\" debug=\"on\">\n");
  +        out.write("			<classpath refid=\"classpath\" />\n");
  +        out.write("			<src path=\"${src}\"/>\n");
  +        out.write("		</javac>\n");
  +        out.write("	</target>\n");
  +
  +        out.write("	<target name=\"jar\" depends=\"compile\">\n");
  +        out.write("        <copy todir=\"${build.classes}\">\n");
  +        out.write("            <fileset dir=\".\" casesensitive=\"yes\" >\n");
  +        out.write("                <include name=\"**/*.wsdd\"/>\n");
  +        out.write("            </fileset>\n");
  +        out.write("        </copy>\n");
  +
  +        out.write("		<jar jarfile=\"" + getJarFileName(symbolTable.getWSDLURI()) + ".jar\"
basedir=\"${build.classes}\" >\n");
  +        out.write("		<include name=\"**\" />\n");
  +        out.write("		<manifest>\n");
  +        out.write("			<section name=\"org/apache/ws4j2ee\">\n");
  +        out.write("			<attribute name=\"Implementation-Title\" value=\"Apache Axis\"/>\n");
  +        out.write("			<attribute name=\"Implementation-Vendor\" value=\"Apache Web Services\"/>\n");
  +        out.write("			</section>\n");
  +        out.write("		</manifest>\n");
  +        out.write("		</jar>\n");
  +        out.write("		<delete dir=\"${build.classes}\"/>\n");
  +        out.write("	</target>\n");
  +        out.write("</project>\n");
  +        out.close();
  +    }
  +
  +    private StringTokenizer getClasspathComponets() {
  +        String classpath = System.getProperty("java.class.path");
  +        String spearator = ";";
  +        if (classpath.indexOf(';') < 0) {
  +            //t hen it is UNIX
  +            spearator = ":";
  +        }
  +
  +        return new StringTokenizer(classpath, spearator);
  +    }
  +
  +    private String getJarFileName(String wsdlFile) {
  +        int index = 0;
  +        if ((index = wsdlFile.lastIndexOf("/")) > 0) {
  +            wsdlFile = wsdlFile.substring(index + 1);
  +        }
  +        return wsdlFile.substring(0, wsdlFile.indexOf('.'));
  +    }
  +
       /* (non-Javadoc)
        * @see org.apache.axis.wsdl.gen.Generator#generate()
        */
       public void generate() throws IOException {
  -//		if(emitter.isBuildFileWanted()){
  -//        	super.generate();
  -//		}
  +        if (emitter.isBuildFileWanted()) {
  +            super.generate();
  +        }
       }
   
   }
  
  
  
  1.16      +44 -49    ws-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java
  
  Index: Wsdl2javaAntTask.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Wsdl2javaAntTask.java	25 Feb 2004 14:03:06 -0000	1.15
  +++ Wsdl2javaAntTask.java	27 Feb 2004 15:00:14 -0000	1.16
  @@ -1,12 +1,12 @@
   /*
    * Copyright 2001-2002,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -87,32 +87,31 @@
       private boolean noWrapped = false;
       private String factory = null;
       private HashMap namespaceMap = new HashMap();
  -    private String output = "." ;
  +    private String output = ".";
       private String protocolHandlerPkgs = "";
       private String deployScope = "";
       private String url = "";
       private String typeMappingVersion = TypeMappingVersionEnum.DEFAULT_VERSION;
       private long timeout = 45000;
  -    private File  namespaceMappingFile=null;
  +    private File namespaceMappingFile = null;
       private MappingSet mappings = new MappingSet();
  -    private String username=null;
  -    private String password=null;
  -    private Path classpath=null;
  +    private String username = null;
  +    private String password = null;
  +    private Path classpath = null;
       private List nsIncludes = new ArrayList();
       private List nsExcludes = new ArrayList();
       private List properties = new ArrayList();
  -    
   
   
       /**
        * do we print a stack trace when something goes wrong?
        */
  -    private boolean printStackTraceOnFailure=true;
  +    private boolean printStackTraceOnFailure = true;
       /**
        * what action to take when there was a failure and the source was some
        * URL
        */
  -    private boolean failOnNetworkErrors=false;
  +    private boolean failOnNetworkErrors = false;
   
       public Wsdl2javaAntTask() {
       }
  @@ -123,14 +122,14 @@
        */
       protected void validate()
               throws BuildException {
  -        if(url==null || url.length()==0) {
  +        if (url == null || url.length() == 0) {
               throw new BuildException("No url specified");
           }
  -        if(timeout<-1) {
  +        if (timeout < -1) {
               throw new BuildException("negative timeout supplied");
           }
  -        File outdir=new File(output);
  -        if(!outdir.isDirectory() || !outdir.exists()) {
  +        File outdir = new File(output);
  +        if (!outdir.isDirectory() || !outdir.exists()) {
               throw new BuildException("output directory is not valid");
           }
   
  @@ -164,7 +163,7 @@
           log("\ttimeout:" + timeout, logLevel);
           log("\tfailOnNetworkErrors:" + failOnNetworkErrors, logLevel);
           log("\tprintStackTraceOnFailure:" + printStackTraceOnFailure, logLevel);
  -        log("\tnamespaceMappingFile:"+namespaceMappingFile, logLevel);
  +        log("\tnamespaceMappingFile:" + namespaceMappingFile, logLevel);
           log("\tusername:" + username, logLevel);
           log("\t:password" + password, logLevel);
           log("\t:noWrapped" + noWrapped, logLevel);
  @@ -179,7 +178,7 @@
       public void execute() throws BuildException {
           //before we get any further, if the user didnt spec a namespace mapping
           //file, we load in the default
  -     
  +
           traceParams(Project.MSG_VERBOSE);
           validate();
           try {
  @@ -190,8 +189,8 @@
               Scope scope = Scope.getScope(deployScope, null);
               if (scope != null) {
                   emitter.setScope(scope);
  -            } else if (deployScope.length()==0
  -                    ||  "none".equalsIgnoreCase(deployScope)) {
  +            } else if (deployScope.length() == 0
  +                    || "none".equalsIgnoreCase(deployScope)) {
                   /* leave default (null, or not-explicit) */;
               } else {
                   log("Unrecognized scope:  " + deployScope + ".  Ignoring it.", Project.MSG_VERBOSE);
  @@ -204,10 +203,6 @@
               }
               emitter.setTestCaseWanted(testCase);
               emitter.setHelperWanted(helperGen);
  -//            if (factorySpec != null) {
  -//                emitter.setFactorySpec(factorySpec);
  -//            }
  -//            else 
               if (factory != null) {
                   emitter.setFactory(factory);
               }
  @@ -223,12 +218,12 @@
               emitter.setDebug(debug);
               emitter.setTypeMappingVersion(typeMappingVersion);
               emitter.setNowrap(noWrapped);
  -	        if (namespaceMappingFile != null) {
  -	            emitter.setNStoPkg(namespaceMappingFile.toString());
  -	        }    
  +            if (namespaceMappingFile != null) {
  +                emitter.setNStoPkg(namespaceMappingFile.toString());
  +            }
               emitter.setTimeout(timeout);
   
  -            Authenticator.setDefault(new DefaultAuthenticator(username,password));
  +            Authenticator.setDefault(new DefaultAuthenticator(username, password));
               if (classpath != null) {
                   AntClassLoader cl = new AntClassLoader(
                           getClass().getClassLoader(),
  @@ -239,7 +234,7 @@
                           Project.MSG_VERBOSE);
                   ClassUtils.setDefaultClassLoader(cl);
               }
  -            
  +
               log("WSDL2Java " + url, Project.MSG_INFO);
               try {
                   emitter.run(url);
  @@ -248,14 +243,14 @@
                       // What we have is either a network error or invalid XML -
                       // the latter most likely an HTML error page.  This makes
                       // it impossible to continue with the test, so we stop here
  -                    if(!failOnNetworkErrors) {
  +                    if (!failOnNetworkErrors) {
                           // test mode, issue a warning, and return without
                           //reporting a fatal error.
                           log(e.toString(), Project.MSG_WARN);
                           return;
                       } else {
                           //in 'consumer' mode, bail out with the URL
  -                        throw new BuildException("Could not build "+url,e);
  +                        throw new BuildException("Could not build " + url, e);
                       }
                   } else {
                       throw e;
  @@ -266,11 +261,11 @@
               //mistaken for a throwable.
               throw b;
           } catch (Throwable t) {
  -            if(printStackTraceOnFailure) {
  +            if (printStackTraceOnFailure) {
                   traceParams(Project.MSG_INFO);
                   t.printStackTrace();
               }
  -            throw new BuildException("Error while processing WSDL in Wsdl2javaAntTask for
"+url,t);
  +            throw new BuildException("Error while processing WSDL in Wsdl2javaAntTask for
" + url, t);
           }
   
       }
  @@ -361,7 +356,7 @@
           if (currentPkgs == null)
               newPkgs = handlerPkgs;
           else
  -            // append to the existing list
  +        // append to the existing list
               newPkgs = currentPkgs + "|" + handlerPkgs;
   
           System.setProperty("java.protocol.handler.pkgs", newPkgs);
  @@ -449,7 +444,7 @@
   
       }
       */
  -    
  +
       /**
        * should the task fail the build if there is a network error?
        * optional: defaults to false
  @@ -490,31 +485,31 @@
       /**
        * Set the noWrapped flag.
        * @param noWrapped
  -     */ 
  +     */
       public void setNoWrapped(boolean noWrapped) {
  -      this.noWrapped = noWrapped;
  +        this.noWrapped = noWrapped;
       }
   
       /**
        * set the classpath
        * @return
  -     */ 
  +     */
       public Path createClasspath() {
           if (classpath == null) {
               classpath = new Path(project);
           }
           return classpath.createPath();
       }
  -    
  +
       /** Adds an additional namespace to the list to be included
        * in source code generation.
  -     */    
  +     */
       public NamespaceSelector createNsInclude() {
           NamespaceSelector selector = new NamespaceSelector();
           nsIncludes.add(selector);
           return selector;
       }
  -    
  +
       /** Adds an additional namespace to the list to be excluded
        * from source code generation.
        */
  @@ -523,8 +518,8 @@
           nsExcludes.add(selector);
           return selector;
       }
  -    
  -    /** Adds a property name/value pair for specialized 
  +
  +    /** Adds a property name/value pair for specialized
        * JavaGeneratorFactories.
        */
       public FactoryProperty createProperty() {
  @@ -532,25 +527,25 @@
           properties.add(property);
           return property;
       }
  -    
  +
       /** This factory method makes it easier to extend this Ant task
        * with a custom Emitter, if necessary.
        */
       protected Emitter createEmitter() {
           return new Emitter();
       }
  -        
  +
       protected NamespaceSelector createSelector() {
           return new NamespaceSelector();
       }
  -    
  -    private void traceSystemSetting(String setting,int logLevel) {
  -        String value=System.getProperty(setting);
  -        log("\t"+setting+"=" + value, logLevel);
  +
  +    private void traceSystemSetting(String setting, int logLevel) {
  +        String value = System.getProperty(setting);
  +        log("\t" + setting + "=" + value, logLevel);
       }
   
       private void traceNetworkSettings(int logLevel) {
  -        traceSystemSetting("http.proxyHost",logLevel);
  +        traceSystemSetting("http.proxyHost", logLevel);
           traceSystemSetting("http.proxyPort", logLevel);
           traceSystemSetting("http.proxyUser", logLevel);
           traceSystemSetting("http.proxyPassword", logLevel);
  
  
  

Mime
View raw message