Class Plugin
- java.lang.Object
-
- com.sun.tools.ws.wscompile.Plugin
-
- Direct Known Subclasses:
PluginImpl
public abstract class Plugin extends Object
Add-on that works on the generated source code.This add-on will be called after the default generation has finished.
- Since:
- 2.2.6
- Author:
- Lukas Jungmann
-
-
Constructor Summary
Constructors Constructor Description Plugin()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract StringgetOptionName()Gets the option name to turn on this add-on.abstract StringgetUsage()Gets the description of this add-on.voidonActivated(Options opts)Notifies a plugin that it's activated.intparseArgument(Options opt, String[] args, int i)Parses an optionargs[i]and augment theoptobject appropriately, then return the number of tokens consumed.abstract booleanrun(Model wsdlModel, WsimportOptions options, ErrorReceiver errorReceiver)Run the add-on.
-
-
-
Method Detail
-
getOptionName
public abstract String getOptionName()
Gets the option name to turn on this add-on.For example, if "abc" is returned, "-abc" will turn on this plugin. A plugin needs to be turned on explicitly, or else no other methods of
Pluginwill be invoked.When an option matches the name returned from this method, WsImport will then invoke
parseArgument(Options, String[], int), allowing plugins to handle arguments to this option.
-
getUsage
public abstract String getUsage()
Gets the description of this add-on. Used to generate a usage screen.- Returns:
- localized description message. should be terminated by \n.
-
parseArgument
public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException
Parses an optionargs[i]and augment theoptobject appropriately, then return the number of tokens consumed.The callee doesn't need to recognize the option that the getOptionName method returns.
Once a plugin is activated, this method is called for options that WsImport didn't recognize. This allows a plugin to define additional options to customize its behavior.
Since options can appear in no particular order, WsImport allows sub-options of a plugin to show up before the option that activates a plugin (one that's returned by
getOptionName().) But nevertheless aPluginneeds to be activated to participate in further processing.- Returns:
- 0 if the argument is not understood. Otherwise return the number of tokens that are consumed, including the option itself. (so if you have an option like "-foo 3", return 2.)
- Throws:
BadCommandLineException- If the option was recognized but there's an error. This halts the argument parsing process and causes WsImport to abort, reporting an error.IOException
-
onActivated
public void onActivated(Options opts) throws BadCommandLineException
Notifies a plugin that it's activated.This method is called when a plugin is activated through the command line option (as specified by
getOptionName().Noop by default.
- Throws:
BadCommandLineException
-
run
public abstract boolean run(Model wsdlModel, WsimportOptions options, ErrorReceiver errorReceiver) throws SAXException
Run the add-on.This method is invoked after WsImport has internally finished the code generation. Plugins can tweak some of the generated code (or add more code) by altering
JCodeModelobtained fromWsimportOptions.getCodeModel()according to the currentWSDL modelandWsimportOptions.Note that this method is invoked only when a
Pluginis activated.- Parameters:
wsdlModel- This object allows access to the WSDL model used for code generation.options- This object allows access to various options used for code generation as well as access to the generated code.errorReceiver- Errors should be reported to this handler.- Returns:
- If the add-on executes successfully, return true. If it detects some errors but those are reported and recovered gracefully, return false.
- Throws:
SAXException- After an error is reported toErrorReceiver, the same exception can be thrown to indicate a fatal irrecoverable error.ErrorReceiveritself may throw it, if it chooses not to recover from the error.
-
-