public abstract class Plugin extends Object
This add-on will be called after the default generation has finished.
Constructor and Description |
---|
Plugin() |
Modifier and Type | Method and Description |
---|---|
abstract String |
getOptionName()
Gets the option name to turn on this add-on.
|
abstract String |
getUsage()
Gets the description of this add-on.
|
void |
onActivated(Options opts)
Notifies a plugin that it's activated.
|
int |
parseArgument(Options opt,
String[] args,
int i)
Parses an option
args[i] and augment the opt object
appropriately, then return the number of tokens consumed. |
abstract boolean |
run(Model wsdlModel,
WsimportOptions options,
ErrorReceiver errorReceiver)
Run the add-on.
|
public abstract String getOptionName()
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 Plugin
will 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.
public abstract String getUsage()
public int parseArgument(Options opt, String[] args, int i) throws BadCommandLineException, IOException
args[i]
and augment the opt
object
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 a Plugin
needs to be activated to participate in
further processing.
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
public void onActivated(Options opts) throws BadCommandLineException
This method is called when a plugin is activated through the command
line option (as specified by getOptionName()
.
Noop by default.
BadCommandLineException
public abstract boolean run(Model wsdlModel, WsimportOptions options, ErrorReceiver errorReceiver) throws SAXException
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 JCodeModel
obtained from WsimportOptions.getCodeModel()
according to the current
WSDL model
and WsimportOptions
.
Note that this method is invoked only when a Plugin
is
activated.
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.SAXException
- After an error is reported to ErrorReceiver
,
the same exception can be thrown to indicate a fatal irrecoverable error. ErrorReceiver
itself may throw it, if it chooses not to recover from the error.Copyright © 2017 Oracle Corporation. All rights reserved.