src/share/jaxws_classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 408
b0610cd08440
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
60 import java.net.URL; 60 import java.net.URL;
61 import java.util.ArrayList; 61 import java.util.ArrayList;
62 import java.util.Arrays; 62 import java.util.Arrays;
63 import java.util.List; 63 import java.util.List;
64 import java.util.HashMap; 64 import java.util.HashMap;
65 import java.util.logging.Level;
66 import java.util.logging.Logger;
65 67
66 /** 68 /**
67 * @author Vivek Pandey 69 * @author Vivek Pandey
68 */ 70 */
69 public class WsimportOptions extends Options { 71 public class WsimportOptions extends Options {
137 private SchemaCompiler schemaCompiler = XJC.createSchemaCompiler(); 139 private SchemaCompiler schemaCompiler = XJC.createSchemaCompiler();
138 140
139 /** 141 /**
140 * Authentication file 142 * Authentication file
141 */ 143 */
142 public File authFile; 144 public File authFile = null;
145
146 //can user.home value be null?
147 public static final String defaultAuthfile
148 = System.getProperty("user.home") + System.getProperty("file.separator")
149 + ".metro" + System.getProperty("file.separator") + "auth";
143 150
144 /** 151 /**
145 * Setting disableAuthenticator to true disables the DefaultAuthenticator. 152 * Setting disableAuthenticator to true disables the DefaultAuthenticator.
146 * -XdisableAuthenticator 153 * -XdisableAuthenticator
147 */ 154 */
148 public boolean disableAuthenticator; 155 public boolean disableAuthenticator;
156
157 public String proxyAuth = null;
158 private String proxyHost = null;
159 private String proxyPort = null;
149 160
150 /** 161 /**
151 * Additional arguments 162 * Additional arguments
152 */ 163 */
153 public HashMap<String, String> extensionOptions = new HashMap<String, String>(); 164 public HashMap<String, String> extensionOptions = new HashMap<String, String>();
238 } else{ 249 } else{
239 addFile(args[i]); 250 addFile(args[i]);
240 } 251 }
241 } 252 }
242 } 253 }
254
255 if (encoding != null && schemaCompiler.getOptions().encoding == null) {
256 try {
257 schemaCompiler.getOptions().parseArgument(
258 new String[] {"-encoding", encoding}, 0);
259 } catch (com.sun.tools.internal.xjc.BadCommandLineException ex) {
260 Logger.getLogger(WsimportOptions.class.getName()).log(Level.SEVERE, null, ex);
261 }
262 }
263
243 if(destDir == null) 264 if(destDir == null)
244 destDir = new File("."); 265 destDir = new File(".");
245 if(sourceDir == null) 266 if(sourceDir == null)
246 sourceDir = destDir; 267 sourceDir = destDir;
247 } 268 }
290 } else if (args[i].startsWith("-httpproxy:")) { 311 } else if (args[i].startsWith("-httpproxy:")) {
291 String value = args[i].substring(11); 312 String value = args[i].substring(11);
292 if (value.length() == 0) { 313 if (value.length() == 0) {
293 throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i])); 314 throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i]));
294 } 315 }
295 int index = value.indexOf(':'); 316 parseProxy(value);
296 if (index == -1) { 317 if (proxyHost != null || proxyPort != null) {
297 System.setProperty("proxySet", "true"); 318 System.setProperty("proxySet", "true");
298 System.setProperty("proxyHost", value); 319 }
299 System.setProperty("proxyPort", "8080"); 320 if (proxyHost != null) {
300 } else { 321 System.setProperty("proxyHost", proxyHost);
301 System.setProperty("proxySet", "true"); 322 }
302 System.setProperty("proxyHost", value.substring(0, index)); 323 if (proxyPort != null) {
303 System.setProperty("proxyPort", value.substring(index + 1)); 324 System.setProperty("proxyPort", proxyPort);
304 } 325 }
305 return 1; 326 return 1;
306 } else if (args[i].equals("-Xno-addressing-databinding")) { 327 } else if (args[i].equals("-Xno-addressing-databinding")) {
307 noAddressingBbinding = true; 328 noAddressingBbinding = true;
308 return 1; 329 return 1;
574 */ 595 */
575 public String getExtensionOption(String argument) { 596 public String getExtensionOption(String argument) {
576 return extensionOptions.get(argument); 597 return extensionOptions.get(argument);
577 } 598 }
578 599
600 private void parseProxy(String text) throws BadCommandLineException {
601 int i = text.lastIndexOf('@');
602 int j = text.lastIndexOf(':');
603
604 if (i > 0) {
605 proxyAuth = text.substring(0, i);
606 if (j > i) {
607 proxyHost = text.substring(i + 1, j);
608 proxyPort = text.substring(j + 1);
609 } else {
610 proxyHost = text.substring(i + 1);
611 proxyPort = "8080";
612 }
613 } else {
614 //no auth info
615 if (j < 0) {
616 //no port
617 proxyHost = text;
618 proxyPort = "8080";
619 } else {
620 proxyHost = text.substring(0, j);
621 proxyPort = text.substring(j + 1);
622 }
623 }
624 try {
625 Integer.valueOf(proxyPort);
626 } catch (NumberFormatException e) {
627 throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_PROXY(text));
628 }
629 }
630
579 /** 631 /**
580 * Looks for all "META-INF/services/[className]" files and 632 * Looks for all "META-INF/services/[className]" files and
581 * create one instance for each class name found inside this file. 633 * create one instance for each class name found inside this file.
582 */ 634 */
583 private static <T> T[] findServices(Class<T> clazz, ClassLoader classLoader) { 635 private static <T> T[] findServices(Class<T> clazz, ClassLoader classLoader) {

mercurial