stevel 2002/10/25 12:13:10 Modified: java/tools/org/apache/axis/tools/ant/wsdl Java2WsdlAntTask.java Mapper.java MappingSet.java NamespaceMapping.java Wsdl2javaAntTask.java Log: adding packageIsKey flag to mapper and so dynamically choosing the mapping key:value precendence appropriate for the tasks. Some of the diff is larger than needed, looks like IDE funnies. Revision Changes Path 1.10 +5 -5 xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java Index: Java2WsdlAntTask.java =================================================================== RCS file: /home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Java2WsdlAntTask.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Java2WsdlAntTask.java 25 Oct 2002 06:24:36 -0000 1.9 +++ Java2WsdlAntTask.java 25 Oct 2002 19:13:10 -0000 1.10 @@ -79,7 +79,7 @@ * 4. check in the changes in docs/ant */ /** - * Generates a WSDL description from a Java class. + * Generates a WSDL description from a Java class. * @author Rich Scheuerle ([EMAIL PROTECTED]) * @author Steve Loughran * @ant.task category="axis" name="axis-java2wsdl" @@ -166,8 +166,8 @@ validate(); // Instantiate the emitter Emitter emitter = new Emitter(); - //do the mappings - mappings.execute(this,namespaceMap); + //do the mappings, packages are the key for this map + mappings.execute(this,namespaceMap, true); if (!namespaceMap.isEmpty()) { emitter.setNamespaceMap(namespaceMap); } @@ -426,14 +426,14 @@ public void setMethods(String methods) { this.methods = methods; } - + /** * Set the use option */ public void setUse(String use) { this.use = use; } - + /** * the name of the service element. * If not specified, the service element is the <tt>portTypeName</tt>Service. 1.2 +2 -1 xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Mapper.java Index: Mapper.java =================================================================== RCS file: /home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Mapper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Mapper.java 25 Oct 2002 06:24:37 -0000 1.1 +++ Mapper.java 25 Oct 2002 19:13:10 -0000 1.2 @@ -69,7 +69,8 @@ * execute the mapping * @param owner owner object * @param map map to map to + * @param packageIsKey if the package is to be the key for the map * @throws BuildException in case of emergency */ - void execute(ProjectComponent owner, HashMap map) throws BuildException; + void execute(ProjectComponent owner, HashMap map, boolean packageIsKey) throws BuildException; } 1.2 +5 -4 xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/MappingSet.java Index: MappingSet.java =================================================================== RCS file: /home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/MappingSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MappingSet.java 25 Oct 2002 06:24:37 -0000 1.1 +++ MappingSet.java 25 Oct 2002 19:13:10 -0000 1.2 @@ -87,14 +87,15 @@ /** * execute by mapping everything iteratively and recursively - * @param owner - * @param map + * @param owner owner task + * @param map map to map into + * @param packageIsKey if the package is to be the key for the map */ - public void execute(ProjectComponent owner, HashMap map) { + public void execute(ProjectComponent owner, HashMap map, boolean packageIsKey) { Iterator it=mappings.iterator(); while (it.hasNext()) { Mapper mapper = (Mapper) it.next(); - mapper.execute(owner,map); + mapper.execute(owner,map, packageIsKey); } } } 1.3 +20 -10 xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/NamespaceMapping.java Index: NamespaceMapping.java =================================================================== RCS file: /home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/NamespaceMapping.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NamespaceMapping.java 25 Oct 2002 13:18:05 -0000 1.2 +++ NamespaceMapping.java 25 Oct 2002 19:13:10 -0000 1.3 @@ -68,6 +68,7 @@ /** * Used for nested package definitions. + * The file format used for storing mappings is a list of package=namespace */ public class NamespaceMapping implements Mapper { @@ -101,7 +102,7 @@ /** * name of a property file that contains mappings in * package=namespace format - * @param file + * @param file file to load */ public void setFile(File file) { mappingFile = file; @@ -113,14 +114,21 @@ * @param map map to assign to * @param packName package name * @param nspace namespace + * @param packageIsKey if the package is to be the key for the map */ protected void map(ProjectComponent owner, HashMap map, String packName, - String nspace) { + String nspace, + boolean packageIsKey) { owner.log("mapping "+nspace+" to "+packName, Project.MSG_VERBOSE); - map.put(nspace, packName); + if(packageIsKey) { + map.put(packName,nspace); + } else { + map.put(nspace, packName); + } } + /** * validate the option set */ @@ -144,15 +152,16 @@ * Load a mapping file and save it to the map * @param owner owner component * @param map target map file + * @param packageIsKey if the package is to be the key for the map * @throws BuildException if an IOException needed swallowing */ - protected void mapFile(ProjectComponent owner, HashMap map) throws BuildException { + protected void mapFile(ProjectComponent owner, HashMap map, boolean packageIsKey) throws BuildException { Properties props = loadMappingPropertiesFile(); Enumeration keys = props.keys(); while (keys.hasMoreElements()) { - String key = (String) keys.nextElement(); - String uri = props.getProperty(key); - map(owner, map, key, uri); + String packageName = (String) keys.nextElement(); + String namespace = props.getProperty(packageName); + map(owner, map, packageName, namespace, packageIsKey); } } @@ -185,14 +194,15 @@ * execute the mapping * @param owner owner object * @param map map to map to + * @param packageIsKey if the package is to be the key for the map * @throws BuildException in case of emergency */ - public void execute(ProjectComponent owner, HashMap map) throws BuildException { + public void execute(ProjectComponent owner, HashMap map, boolean packageIsKey) throws BuildException { validate(); if (mappingFile != null) { - mapFile(owner, map); + mapFile(owner, map,packageIsKey); } else { - map(owner, map, packageName, namespace); + map(owner, map, packageName, namespace, packageIsKey); } } 1.6 +20 -20 xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java Index: Wsdl2javaAntTask.java =================================================================== RCS file: /home/cvs/xml-axis/java/tools/org/apache/axis/tools/ant/wsdl/Wsdl2javaAntTask.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Wsdl2javaAntTask.java 25 Oct 2002 06:24:37 -0000 1.5 +++ Wsdl2javaAntTask.java 25 Oct 2002 19:13:10 -0000 1.6 @@ -143,8 +143,8 @@ /** * validation code * @throws BuildException if validation failed - */ - protected void validate() + */ + protected void validate() throws BuildException { if(url==null || url.length()==0) { throw new BuildException("No url specified"); @@ -156,9 +156,9 @@ if(!outdir.isDirectory() || !outdir.exists()) { throw new BuildException("output directory is not valid"); } - + } - + /** * trace out parameters * @param logLevel to log at @@ -189,7 +189,7 @@ /** * The method executing the task * @throws BuildException if validation or execution failed - */ + */ public void execute() throws BuildException { //before we get any further, if the user didnt spec a namespace mapping //file, we load in the default @@ -212,17 +212,17 @@ } else { log("Unrecognized scope: " + deployScope + ". Ignoring it.", Project.MSG_VERBOSE); } - - //do the mappings - mappings.execute(this, namespaceMap); + + //do the mappings, with namespaces mapped as the key + mappings.execute(this, namespaceMap, false); if (!namespaceMap.isEmpty()) { emitter.setNamespaceMap(namespaceMap); } emitter.setTestCaseWanted(testCase); - emitter.setHelperWanted(helperGen); + emitter.setHelperWanted(helperGen); if (factory != null) { emitter.setFactory(factory); - } + } emitter.setImports(!noImports); emitter.setAllWanted(all); emitter.setOutputDir(output); @@ -266,7 +266,7 @@ 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); } } @@ -275,7 +275,7 @@ * flag for verbose output; default=false * *@param verbose The new verbose value - */ + */ public void setVerbose(boolean verbose) { this.verbose = verbose; } @@ -284,10 +284,10 @@ * flag for debug output; default=false * *@param debug The new debug value - */ + */ public void setDebug(boolean debug) { this.debug = debug; - } + } /** * emit server-side bindings for web service; default=false @@ -297,8 +297,8 @@ } /** - * deploy skeleton (true) or implementation (false) in deploy.wsdd. - * Default is false. Assumes server-side="true". + * deploy skeleton (true) or implementation (false) in deploy.wsdd. + * Default is false. Assumes server-side="true". */ public void setSkeletonDeploy(boolean parameter) { this.skeletonDeploy = parameter; @@ -321,7 +321,7 @@ } /** - * name of the Java2WSDLFactory class for + * name of the Java2WSDLFactory class for * extending WSDL generation functions */ public void setFactory(String parameter) { @@ -337,7 +337,7 @@ } /** - * output directory for emitted files + * output directory for emitted files */ public void setOutput(File parameter) throws BuildException { try { @@ -348,8 +348,8 @@ } /** - * add scope to deploy.xml: "Application", "Request", "Session" - * optional; + * add scope to deploy.xml: "Application", "Request", "Session" + * optional; */ public void setDeployScope(String scope) { this.deployScope = scope;