jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java
changeset 27837 86d4f46e622a
parent 25871 b80b84e87032
child 29839 6d5d546e953b
equal deleted inserted replaced
27581:9fffb959eb41 27837:86d4f46e622a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, 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
    55  * CLI entry-point to the schema generator.
    55  * CLI entry-point to the schema generator.
    56  *
    56  *
    57  * @author Bhakti Mehta
    57  * @author Bhakti Mehta
    58  */
    58  */
    59 public class SchemaGenerator {
    59 public class SchemaGenerator {
       
    60 
       
    61     private static final Logger LOGGER = Logger.getLogger(SchemaGenerator.class.getName());
       
    62 
    60     /**
    63     /**
    61      * Runs the schema generator.
    64      * Runs the schema generator.
    62      */
    65      */
    63     public static void main(String[] args) throws Exception {
    66     public static void main(String[] args) throws Exception {
    64         System.exit(run(args));
    67         System.exit(run(args));
    70             if (cl==null) {
    73             if (cl==null) {
    71                 cl = SecureLoader.getSystemClassLoader();
    74                 cl = SecureLoader.getSystemClassLoader();
    72             }
    75             }
    73             return run(args, cl);
    76             return run(args, cl);
    74         } catch(Exception e) {
    77         } catch(Exception e) {
    75             System.err.println(e.getMessage());
    78             LOGGER.log(Level.SEVERE, e.getMessage(), e);
    76             return -1;
    79             return -1;
    77         }
    80         }
    78     }
    81     }
    79 
    82 
    80     /**
    83     /**
   204             f = new File(new URL(jarFileUrl).getFile());
   207             f = new File(new URL(jarFileUrl).getFile());
   205             if (f.exists() && f.getName().endsWith(".jar")) { // this is here for potential backw. compatibility issues
   208             if (f.exists() && f.getName().endsWith(".jar")) { // this is here for potential backw. compatibility issues
   206                 return f.getPath();
   209                 return f.getPath();
   207             }
   210             }
   208         } catch (URISyntaxException ex) {
   211         } catch (URISyntaxException ex) {
   209             Logger.getLogger(SchemaGenerator.class.getName()).log(Level.SEVERE, null, ex);
   212             LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
   210         } catch (MalformedURLException ex) {
   213         } catch (MalformedURLException ex) {
   211             Logger.getLogger(SchemaGenerator.class.getName()).log(Level.SEVERE, null, ex);
   214             LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
   212         }
   215         }
   213         return null;
   216         return null;
   214     }
   217     }
   215 
   218 
   216     private static void usage( ) {
   219     private static void usage( ) {
   223             JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   226             JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   224             DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
   227             DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
   225             StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
   228             StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
   226             JavacOptions options = JavacOptions.parse(compiler, fileManager, args);
   229             JavacOptions options = JavacOptions.parse(compiler, fileManager, args);
   227             List<String> unrecognizedOptions = options.getUnrecognizedOptions();
   230             List<String> unrecognizedOptions = options.getUnrecognizedOptions();
   228             if (!unrecognizedOptions.isEmpty())
   231             if (!unrecognizedOptions.isEmpty()) {
   229                 Logger.getLogger(SchemaGenerator.class.getName()).log(Level.WARNING, "Unrecognized options found: {0}", unrecognizedOptions);
   232                 LOGGER.log(Level.WARNING, "Unrecognized options found: {0}", unrecognizedOptions);
       
   233             }
   230             Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(options.getFiles());
   234             Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(options.getFiles());
   231             JavaCompiler.CompilationTask task = compiler.getTask(
   235             JavaCompiler.CompilationTask task = compiler.getTask(
   232                     null,
   236                     null,
   233                     fileManager,
   237                     fileManager,
   234                     diagnostics,
   238                     diagnostics,