1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/JwsImplGenerator.java Thu Apr 04 19:05:24 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/JwsImplGenerator.java Tue Apr 09 14:51:13 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -50,6 +50,7 @@ 1.11 import javax.xml.namespace.QName; 1.12 import javax.xml.ws.Holder; 1.13 import java.io.File; 1.14 +import java.text.MessageFormat; 1.15 import java.util.ArrayList; 1.16 import java.util.HashMap; 1.17 import java.util.List; 1.18 @@ -84,12 +85,12 @@ 1.19 jwsImplGenerator.init(model, options, receiver); 1.20 jwsImplGenerator.doGeneration(); 1.21 // print a warning message while implFiles.size() is zero 1.22 - if (jwsImplGenerator.implFiles.size() == 0) { 1.23 - StringBuffer msg = new StringBuffer(); 1.24 + if (jwsImplGenerator.implFiles.isEmpty()) { 1.25 + StringBuilder msg = new StringBuilder(); 1.26 if (options.implServiceName != null) 1.27 - msg.append("serviceName=[" + options.implServiceName + "] "); 1.28 + msg.append("serviceName=[").append(options.implServiceName).append("] "); 1.29 if (options.implPortName != null) 1.30 - msg.append("portName=[" + options.implPortName + "] "); 1.31 + msg.append("portName=[").append(options.implPortName).append("] "); 1.32 1.33 if (msg.length() > 0) 1.34 msg.append(", Not found in wsdl file.\n"); 1.35 @@ -107,7 +108,7 @@ 1.36 public static boolean moveToImplDestDir(List<String> gImplFiles, 1.37 WsimportOptions options, ErrorReceiver receiver) { 1.38 if (options.implDestDir == null || gImplFiles == null 1.39 - || gImplFiles.size() == 0) 1.40 + || gImplFiles.isEmpty()) 1.41 return true; 1.42 1.43 List<ImplFile> generatedImplFiles = ImplFile.toImplFiles(gImplFiles); 1.44 @@ -335,24 +336,29 @@ 1.45 webServiceAnn.param("wsdlLocation", wsdlLocation); 1.46 webServiceAnn.param("endpointInterface", port.getJavaInterface().getName()); 1.47 } 1.48 + 1.49 //CR373098 To transform the java class name as validate. 1.50 - private String transToValidJavaIdentifier(String s) { 1.51 - if (s == null) return null; 1.52 - final int len = s.length(); 1.53 - StringBuffer retSB = new StringBuffer(); 1.54 - if (len == 0 || !Character.isJavaIdentifierStart(s.charAt(0))) 1.55 - retSB.append("J"); //update to a default start char 1.56 - else 1.57 - retSB.append(s.charAt(0)); 1.58 + private String transToValidJavaIdentifier(String s) { 1.59 + if (s == null) { 1.60 + return null; 1.61 + } 1.62 + final int len = s.length(); 1.63 + StringBuilder retSB = new StringBuilder(); 1.64 + if (len == 0 || !Character.isJavaIdentifierStart(s.charAt(0))) { 1.65 + retSB.append("J"); //update to a default start char 1.66 + } else { 1.67 + retSB.append(s.charAt(0)); 1.68 + } 1.69 1.70 - for (int i = 1; i < len; i++) { 1.71 - if (!Character.isJavaIdentifierPart(s.charAt(i))) 1.72 - ; //delete it if it is illegal //TODO: It might conflict "a-b" vs. "ab" 1.73 - else 1.74 - retSB.append(s.charAt(i)); 1.75 - } 1.76 - return retSB.toString(); 1.77 - } 1.78 + for (int i = 1; i < len; i++) { 1.79 + if (!Character.isJavaIdentifierPart(s.charAt(i))) 1.80 + ; //delete it if it is illegal //TODO: It might conflict "a-b" vs. "ab" 1.81 + else { 1.82 + retSB.append(s.charAt(i)); 1.83 + } 1.84 + } 1.85 + return retSB.toString(); 1.86 + } 1.87 1.88 private String makePackageQualified(String s) { 1.89 s = transToValidJavaIdentifier(s); 1.90 @@ -446,21 +452,20 @@ 1.91 } 1.92 } 1.93 1.94 - // process the bindings in backup list of model 1.95 + // process the bindings in whole document 1.96 if (value == null) { 1.97 - // TODO: The property "BAKEUP_BINDINGS" is set in WsdlModeler when init 1.98 - // the model 1.99 - // make this as a const if needed. 1.100 - HashMap hm = (HashMap) model.getProperty("BAKEUP_BINDINGS"); 1.101 - Binding b = (Binding) hm.get(bName); 1.102 - if (b != null) { 1.103 + if (model.getEntity() instanceof Definitions) { 1.104 + Definitions definitions = (Definitions) model.getEntity(); 1.105 + Binding b = (Binding) definitions.resolveBindings().get(bName); 1.106 + if (b != null) { 1.107 List<TWSDLExtension> bindextends = (List<TWSDLExtension>) b 1.108 .extensions(); 1.109 for (TWSDLExtension wsdlext : bindextends) { 1.110 - value = resolveBindingValue(wsdlext); 1.111 - if (value != null) 1.112 - break; 1.113 + value = resolveBindingValue(wsdlext); 1.114 + if (value != null) 1.115 + break; 1.116 } 1.117 + } 1.118 } 1.119 } 1.120 1.121 @@ -478,14 +483,14 @@ 1.122 * retrieved from WSDL 1.123 * @return Standard BindingType URI defined by JAX-WS 2.0 specification. 1.124 */ 1.125 - private String translate(String transportURI) 1.126 - { 1.127 - String translatedBindingId = TRANSLATION_MAP.get(transportURI); 1.128 - if (translatedBindingId == null) 1.129 - translatedBindingId = transportURI; 1.130 - 1.131 - return translatedBindingId; 1.132 - } 1.133 +// private String translate(String transportURI) 1.134 +// { 1.135 +// String translatedBindingId = TRANSLATION_MAP.get(transportURI); 1.136 +// if (translatedBindingId == null) 1.137 +// translatedBindingId = transportURI; 1.138 +// 1.139 +// return translatedBindingId; 1.140 +// } 1.141 1.142 /***************************************************************************** 1.143 * Inner classes definition 1.144 @@ -529,7 +534,10 @@ 1.145 ret = options.implDestDir; 1.146 } 1.147 1.148 - ret.mkdirs(); 1.149 + boolean created = ret.mkdirs(); 1.150 + if (options.verbose && !created) { 1.151 + System.out.println(MessageFormat.format("Directory not created: {0}", ret)); 1.152 + } 1.153 return ret; 1.154 } 1.155 1.156 @@ -549,7 +557,7 @@ 1.157 1.158 private static File findFile(WsimportOptions options, String qualifiedFileName) 1.159 throws java.io.IOException { 1.160 - String baseDir = options.destDir.getCanonicalPath(); 1.161 + String baseDir = options.sourceDir.getCanonicalPath(); 1.162 String fp = null; 1.163 for (File f : options.getGeneratedFiles()) { 1.164 fp = getQualifiedFileName(baseDir, f);