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

Wed, 27 Apr 2016 01:27:09 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:27:09 +0800
changeset 0
373ffda63c9a
child 637
9c07ef4934dd
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.internal.ws.wscompile;
aoqi@0 27
aoqi@0 28 import com.sun.codemodel.internal.JCodeModel;
aoqi@0 29 import com.sun.tools.internal.ws.processor.model.Model;
aoqi@0 30 import java.io.IOException;
aoqi@0 31 import org.xml.sax.SAXException;
aoqi@0 32
aoqi@0 33 /**
aoqi@0 34 * Add-on that works on the generated source code.
aoqi@0 35 *
aoqi@0 36 * <p> This add-on will be called after the default generation has finished.
aoqi@0 37 *
aoqi@0 38 * @author Lukas Jungmann
aoqi@0 39 * @since 2.2.6
aoqi@0 40 */
aoqi@0 41 public abstract class Plugin {
aoqi@0 42
aoqi@0 43 /**
aoqi@0 44 * Gets the option name to turn on this add-on.
aoqi@0 45 *
aoqi@0 46 * <p> For example, if "abc" is returned, "-abc" will turn on this plugin. A
aoqi@0 47 * plugin needs to be turned on explicitly, or else no other methods of {@link Plugin}
aoqi@0 48 * will be invoked.
aoqi@0 49 *
aoqi@0 50 * <p> When an option matches the name returned from this method, WsImport
aoqi@0 51 * will then invoke {@link #parseArgument(Options, String[], int)}, allowing
aoqi@0 52 * plugins to handle arguments to this option.
aoqi@0 53 */
aoqi@0 54 public abstract String getOptionName();
aoqi@0 55
aoqi@0 56 /**
aoqi@0 57 * Gets the description of this add-on. Used to generate a usage screen.
aoqi@0 58 *
aoqi@0 59 * @return localized description message. should be terminated by \n.
aoqi@0 60 */
aoqi@0 61 public abstract String getUsage();
aoqi@0 62
aoqi@0 63 /**
aoqi@0 64 * Parses an option <code>args[i]</code> and augment the <code>opt</code> object
aoqi@0 65 * appropriately, then return the number of tokens consumed.
aoqi@0 66 *
aoqi@0 67 * <p> The callee doesn't need to recognize the option that the
aoqi@0 68 * getOptionName method returns.
aoqi@0 69 *
aoqi@0 70 * <p> Once a plugin is activated, this method is called for options that
aoqi@0 71 * WsImport didn't recognize. This allows a plugin to define additional
aoqi@0 72 * options to customize its behavior.
aoqi@0 73 *
aoqi@0 74 * <p> Since options can appear in no particular order, WsImport allows
aoqi@0 75 * sub-options of a plugin to show up before the option that activates a
aoqi@0 76 * plugin (one that's returned by {@link #getOptionName()}.)
aoqi@0 77 *
aoqi@0 78 * But nevertheless a {@link Plugin} needs to be activated to participate in
aoqi@0 79 * further processing.
aoqi@0 80 *
aoqi@0 81 * @return 0 if the argument is not understood. Otherwise return the number
aoqi@0 82 * of tokens that are consumed, including the option itself. (so if you have
aoqi@0 83 * an option like "-foo 3", return 2.)
aoqi@0 84 * @exception BadCommandLineException If the option was recognized but
aoqi@0 85 * there's an error. This halts the argument parsing process and causes
aoqi@0 86 * WsImport to abort, reporting an error.
aoqi@0 87 */
aoqi@0 88 public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException {
aoqi@0 89 return 0;
aoqi@0 90 }
aoqi@0 91
aoqi@0 92 /**
aoqi@0 93 * Notifies a plugin that it's activated.
aoqi@0 94 *
aoqi@0 95 * <p> This method is called when a plugin is activated through the command
aoqi@0 96 * line option (as specified by {@link #getOptionName()}.
aoqi@0 97 *
aoqi@0 98 * <p> Noop by default.
aoqi@0 99 *
aoqi@0 100 */
aoqi@0 101 public void onActivated(Options opts) throws BadCommandLineException {
aoqi@0 102 // noop
aoqi@0 103 }
aoqi@0 104
aoqi@0 105 /**
aoqi@0 106 * Run the add-on.
aoqi@0 107 *
aoqi@0 108 * <p> This method is invoked after WsImport has internally finished the
aoqi@0 109 * code generation. Plugins can tweak some of the generated code (or add
aoqi@0 110 * more code) by altering {@link JCodeModel} obtained from {@link WsimportOptions#getCodeModel()
aoqi@0 111 * } according to the current
aoqi@0 112 * {@link Model WSDL model} and {@link WsimportOptions}.
aoqi@0 113 *
aoqi@0 114 * <p> Note that this method is invoked only when a {@link Plugin} is
aoqi@0 115 * activated.
aoqi@0 116 *
aoqi@0 117 * @param wsdlModel This object allows access to the WSDL model used for
aoqi@0 118 * code generation.
aoqi@0 119 *
aoqi@0 120 * @param options This object allows access to various options used for code
aoqi@0 121 * generation as well as access to the generated code.
aoqi@0 122 *
aoqi@0 123 * @param errorReceiver Errors should be reported to this handler.
aoqi@0 124 *
aoqi@0 125 * @return If the add-on executes successfully, return true. If it detects
aoqi@0 126 * some errors but those are reported and recovered gracefully, return
aoqi@0 127 * false.
aoqi@0 128 *
aoqi@0 129 * @throws SAXException After an error is reported to {@link ErrorReceiver},
aoqi@0 130 * the same exception can be thrown to indicate a fatal irrecoverable error. {@link ErrorReceiver}
aoqi@0 131 * itself may throw it, if it chooses not to recover from the error.
aoqi@0 132 */
aoqi@0 133 public abstract boolean run(
aoqi@0 134 Model wsdlModel, WsimportOptions options, ErrorReceiver errorReceiver) throws SAXException;
aoqi@0 135 }

mercurial