com.sun.tools.ws.wscompile
Class Plugin

java.lang.Object
  extended by 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

Constructor Summary
Plugin()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plugin

public Plugin()
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 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.


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 option 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 {@link Plugin} needs 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 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.

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.
errorHandler - 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 to ErrorHandler, the same exception can be thrown to indicate a fatal irrecoverable error. ErrorHandler itself may throw it, if it chooses not to recover from the error.


Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.