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

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 408
b0610cd08440
     1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2012, 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 @@ -62,6 +62,8 @@
    1.11  import java.util.Arrays;
    1.12  import java.util.List;
    1.13  import java.util.HashMap;
    1.14 +import java.util.logging.Level;
    1.15 +import java.util.logging.Logger;
    1.16  
    1.17  /**
    1.18   * @author Vivek Pandey
    1.19 @@ -139,7 +141,12 @@
    1.20      /**
    1.21       * Authentication file
    1.22       */
    1.23 -    public File authFile;
    1.24 +    public File authFile = null;
    1.25 +
    1.26 +    //can user.home value be null?
    1.27 +    public static final String defaultAuthfile
    1.28 +            = System.getProperty("user.home") + System.getProperty("file.separator")
    1.29 +            + ".metro" + System.getProperty("file.separator") + "auth";
    1.30  
    1.31      /**
    1.32       * Setting disableAuthenticator to true disables the DefaultAuthenticator.
    1.33 @@ -147,6 +154,10 @@
    1.34       */
    1.35      public boolean disableAuthenticator;
    1.36  
    1.37 +    public String proxyAuth = null;
    1.38 +    private String proxyHost = null;
    1.39 +    private String proxyPort = null;
    1.40 +
    1.41      /**
    1.42       * Additional arguments
    1.43       */
    1.44 @@ -240,6 +251,16 @@
    1.45                  }
    1.46              }
    1.47          }
    1.48 +
    1.49 +        if (encoding != null && schemaCompiler.getOptions().encoding == null) {
    1.50 +            try {
    1.51 +                schemaCompiler.getOptions().parseArgument(
    1.52 +                        new String[] {"-encoding", encoding}, 0);
    1.53 +            } catch (com.sun.tools.internal.xjc.BadCommandLineException ex) {
    1.54 +                Logger.getLogger(WsimportOptions.class.getName()).log(Level.SEVERE, null, ex);
    1.55 +            }
    1.56 +        }
    1.57 +
    1.58          if(destDir == null)
    1.59              destDir = new File(".");
    1.60          if(sourceDir == null)
    1.61 @@ -292,15 +313,15 @@
    1.62              if (value.length() == 0) {
    1.63                  throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i]));
    1.64              }
    1.65 -            int index = value.indexOf(':');
    1.66 -            if (index == -1) {
    1.67 +            parseProxy(value);
    1.68 +            if (proxyHost != null || proxyPort != null) {
    1.69                  System.setProperty("proxySet", "true");
    1.70 -                System.setProperty("proxyHost", value);
    1.71 -                System.setProperty("proxyPort", "8080");
    1.72 -            } else {
    1.73 -                System.setProperty("proxySet", "true");
    1.74 -                System.setProperty("proxyHost", value.substring(0, index));
    1.75 -                System.setProperty("proxyPort", value.substring(index + 1));
    1.76 +            }
    1.77 +            if (proxyHost != null) {
    1.78 +                System.setProperty("proxyHost", proxyHost);
    1.79 +            }
    1.80 +            if (proxyPort != null) {
    1.81 +                System.setProperty("proxyPort", proxyPort);
    1.82              }
    1.83              return 1;
    1.84          } else if (args[i].equals("-Xno-addressing-databinding")) {
    1.85 @@ -576,6 +597,37 @@
    1.86          return extensionOptions.get(argument);
    1.87      }
    1.88  
    1.89 +    private void parseProxy(String text) throws BadCommandLineException {
    1.90 +        int i = text.lastIndexOf('@');
    1.91 +        int j = text.lastIndexOf(':');
    1.92 +
    1.93 +        if (i > 0) {
    1.94 +            proxyAuth = text.substring(0, i);
    1.95 +            if (j > i) {
    1.96 +                proxyHost = text.substring(i + 1, j);
    1.97 +                proxyPort = text.substring(j + 1);
    1.98 +            } else {
    1.99 +                proxyHost = text.substring(i + 1);
   1.100 +                proxyPort = "8080";
   1.101 +            }
   1.102 +        } else {
   1.103 +            //no auth info
   1.104 +            if (j < 0) {
   1.105 +                //no port
   1.106 +                proxyHost = text;
   1.107 +                proxyPort = "8080";
   1.108 +            } else {
   1.109 +                proxyHost = text.substring(0, j);
   1.110 +                proxyPort = text.substring(j + 1);
   1.111 +            }
   1.112 +        }
   1.113 +        try {
   1.114 +            Integer.valueOf(proxyPort);
   1.115 +        } catch (NumberFormatException e) {
   1.116 +            throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_PROXY(text));
   1.117 +        }
   1.118 +    }
   1.119 +
   1.120      /**
   1.121       * Looks for all "META-INF/services/[className]" files and
   1.122       * create one instance for each class name found inside this file.

mercurial