You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2002/05/16 16:48:21 UTC

cvs commit: xml-axis/java/samples/integrationGuide/example2 MyDeployWriter.java MyEmitter.java MyGeneratorFactory.java WSDL2Useless.java

butek       02/05/16 07:48:21

  Modified:    java/docs integration-guide.html
  Added:       java/samples/integrationGuide/example1
                        MyListPortsWriter.java MyWSDL2Java.java
               java/samples/integrationGuide/example2 MyDeployWriter.java
                        MyEmitter.java MyGeneratorFactory.java
                        WSDL2Useless.java
  Log:
  First cut at documenting the extensibility of WSDL2Java.  This documentation
  seems most appropriate in the integration guide so that's where I've put it.
  I've also written a couple examples.  This work is a LONG way from being
  done, but I've gotta do some non-AXIS work for a while, so I thought I
  should commit what I've done so far.
  
  Revision  Changes    Path
  1.6       +542 -0    xml-axis/java/docs/integration-guide.html
  
  Index: integration-guide.html
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/docs/integration-guide.html,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- integration-guide.html	15 Mar 2002 10:19:35 -0000	1.5
  +++ integration-guide.html	16 May 2002 14:48:20 -0000	1.6
  @@ -36,6 +36,7 @@
   <br>&nbsp; <a href="#Internationalization Plug">Internationalization</a>
   <br>&nbsp; <a href="#Performance Monitoring Plug">Performance Monitoring</a>
   <br>&nbsp; <a href="#Encoding Plug">Encoding</a>
  +<br>&nbsp; <a href="#WSDL plug">WSDL Parser and Code Generator Framework</a>
   <h2>
   <a NAME="Introduction"></a>Introduction</h2>
   The primary purpose of this guide is
  @@ -483,5 +484,546 @@
   Example</li>
   </ul>
   
  +<h3>
  +<a NAME="WSDL plug"></a>WSDL Parser and Code Generator Framework</h3>
  +WSDL2Java is AXIS's tool to generate Java artifacts from WSDL.&nbsp; This
  +tool is extensible.&nbsp; If users of AXIS wish to extend AXIS, then they
  +may also need to extend or change the generated artifacts.&nbsp; For example,
  +if AXIS is inserted into some product which has an existing deployment
  +model that's different than AXIS's deployment model, then that product's
  +version of WSDL2Java will be required to generate deployment descriptors
  +other than AXIS's deploy.wsdd.
  +<p>What follows immediately is a description of the framework.&nbsp; If
  +you would rather dive down into the dirt of <a href="#WSDL Examples">examples</a>,
  +you could learn a good deal just from them.&nbsp; Then you could come back
  +up here and learn the gory details.
  +<p>There are three parts to WSDL2Java:
  +<ol>
  +<li>
  +The symbol table</li>
  +
  +<li>
  +The parser front end with a generator framework</li>
  +
  +<li>
  +The code generator back end (WSDL2Java itself)</li>
  +</ol>
  +
  +<h4>
  +Symbol Table</h4>
  +The symbol table, found in org.apache.axis.wsdl.symbolTable, will contain
  +all the symbols from a WSDL document, both the symbols from the WSDL constructs
  +themselves (portType, binding, etc), and also the XML schema types that
  +the WSDL refers to.
  +<p><font color="#FF0000">NOTE:&nbsp; Needs lots of description here.</font>
  +<p>The symbol table is not extensible, but you <b>can</b> add fields to
  +it by using the Dynamic Variables construct:
  +<ul>
  +<li>
  +You must have some constant object for a dynamic variable key.&nbsp; For
  +example:&nbsp; public static final String MY_KEY = "my key";</li>
  +
  +<li>
  +You set the value of the variable in your GeneratorFactory.generatorPass:&nbsp;
  +entry.setDynamicVar(MY_KEY, myValue);</li>
  +
  +<li>
  +You get the value of the variable in your generators:&nbsp; Object myValue
  += entry.getDynamicVar(MY_KEY);</li>
  +</ul>
  +
  +<h4>
  +Parser Front End and Generator Framework</h4>
  +The parser front end and generator framework is located in org.apache.axis.wsdl.gen.&nbsp;
  +The parser front end consists of two files:
  +<ul>
  +<li>
  +Parser</li>
  +
  +<br><tt>public class Parser {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Parser();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public boolean isDebug();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setDebug(boolean);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public boolean isImports();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setImports(boolean);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public boolean isVerbose();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setVerbose(boolean);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public long getTimeout();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setTimeout(long);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getUsername();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setUsername(java.lang.String);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getPassword();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setPassword(java.lang.String);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public GeneratorFactory getFactory();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setFactory(GeneratorFactory);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public org.apache.axis.wsdl.symbolTable.SymbolTable
  +getSymbolTable();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public javax.wsdl.Definition getCurrentDefinition();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public java.lang.String getWSDLURI();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void run(String wsdl) throws java.lang.Exception;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void run(String context, org.w3c.dom.Document
  +wsdlDoc) throws java.io.IOException, javax.wsdl.WSDLException;</tt>
  +<br><tt>}</tt>
  +<p>The basic behavior of this class is simple:&nbsp; you instantiate a
  +Parser, then you run it.
  +<ul><tt>Parser parser = new Parser();</tt>
  +<br><tt>parser.run("myfile.wsdl");</tt></ul>
  +
  +<p><br>There are various options on the parser that have accessor methods:
  +<ul>
  +<li>
  +debug - default is false - dump the symbol table after the WSDL file has
  +been parsed</li>
  +
  +<li>
  +imports - default is true - should imported files be visited?</li>
  +
  +<li>
  +verbose - default is false - list each file as it is being parsed</li>
  +
  +<li>
  +timeout - default is 45 - the number of seconds to wait before halting
  +the parse</li>
  +
  +<li>
  +username - no default - needed for protected URI's</li>
  +
  +<li>
  +password - no default - needed for protected URI's</li>
  +</ul>
  +
  +<p><br>Other miscellaneous methods on the parser:
  +<ul>
  +<li>
  +get/setFactory - get or set the GeneratorFactory on this parser - see below
  +for details.&nbsp; The default generator factory is NoopFactory, which
  +generates nothing.</li>
  +
  +<li>
  +getSymbolTable - once a run method is called, the symbol table will be
  +populated and can get queried.</li>
  +
  +<li>
  +getCurrentDefinition - once a run method is called, the parser will contain
  +a Definition object which represents the given wsdl file.&nbsp; Definition
  +is a WSDL4J object.</li>
  +
  +<li>
  +getWSDLURI - once the run method which takes a string is called, the parser
  +will contain the string representing the location of the WSDL file.&nbsp;
  +Note that the other run method - run(String context, Document wsdlDoc)
  +- does not provide a location for the wsdl file.&nbsp; If this run method
  +is used, getWSDLURI will be null.</li>
  +
  +<li>
  +There are two run methods.&nbsp; The first, as shown above, takes a URI
  +string which represents the location of the WSDL file.&nbsp; If you've
  +already parsed the WSDL file into an XML Document, then you can use the
  +second run method, which takes a context and the WSDL Document.</li>
  +</ul>
  +
  +<p><br>An extension of this class would ...
  +<br><br>
  +<font color="#FF0000">NOTE:&nbsp; continue this sentiment...</font>
  +<br>&nbsp;
  +<li>
  +WSDL2</li>
  +
  +<br>Parser is the programmatic interface into the WSDL parser.&nbsp; WSDL2
  +is the command line tool for the parser.&nbsp; It provides an extensible
  +framework for calling the Parser from the command line.&nbsp; It is named
  +WSDL2 because extensions of it will likely begin with WSDL2:&nbsp; <b>WSDL2</b>Java,
  +<b>WSDL2</b>Lisp, <b>WSDL2</b>XXX.
  +<p><tt>public class WSDL2 {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected WSDL2();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected Parser createParser();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected Parser getParser();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void addOptions(org.apache.axis.utils.CLOptionDescriptor[]);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void parseOption(org.apache.axis.utils.CLOption);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void validateOptions();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void printUsage();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void run(String[]);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public static void main(String[]);</tt>
  +<br><tt>}</tt>
  +<p>Like all good command line tools, it has a main method.&nbsp; Unlike
  +some command line tools, however, its methods are not static.&nbsp; Static
  +methods are not extensible.&nbsp; WSDL2's main method constructs an instance
  +of itself and calls methods on that instance rather than calling static
  +methods.&nbsp; These methods follow a behavior pattern.&nbsp; The main
  +method is very simple:
  +<br>&nbsp;
  +<ul><tt>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WSDL2 wsdl2 = new WSDL2();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wsdl2.run(args);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt></ul>
  +
  +<p><br>The constructor calls createParser to construct a Parser or an extension
  +of Parser.
  +<p>run calls:
  +<ul>
  +<li>
  +parseOption to parse each command line option and call the appropriate
  +Parser accessor.&nbsp; For example, when this method parses --verbose,
  +it calls parser.setVerbose(true)</li>
  +
  +<li>
  +validateOptions to make sure all the option values are consistent</li>
  +
  +<li>
  +printUsage if the usage of the tool is in error</li>
  +
  +<li>
  +parser.run(args);</li>
  +</ul>
  +
  +<p><br>If an extension has additional options, then it is expected to call
  +addOptions before calling run.&nbsp; So extensions will call, as necessary,
  +getParser, addOptions, run.&nbsp; Extensions will override, as necessary,
  +createParser, parseOption, validateOptions, printUsage.
  +<br>&nbsp;
  +<p>The generator framework consists of 2 files:
  +<ul>
  +<li>
  +Generator</li>
  +
  +<br>The Generator interface is very simple.&nbsp; It just defines a generate
  +method.
  +<p><tt>public interface Generator</tt>
  +<br><tt>{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void generate() throws java.io.IOException;</tt>
  +<br><tt>}</tt>
  +<br>&nbsp;
  +<li>
  +GeneratorFactory</li>
  +
  +<p><br><tt>public interface GeneratorFactory</tt>
  +<br><tt>{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void generatorPass(javax.wsdl.Definition,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Message,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.PortType,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Binding,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Service,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(TypeEntry, SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public Generator getGenerator(javax.wsdl.Definition,
  +SymbolTable);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setBaseTypeMapping(BaseTypeMapping);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public BaseTypeMapping getBaseTypeMapping();</tt>
  +<br><tt>}</tt>
  +<p>The GeneratorFactory interface defines a set of methods that the parser
  +uses to get generators.&nbsp; There should be a generator for each of the
  +WSDL constructs (message, portType, etc - note that these depend on the
  +WSDL4J classes:&nbsp; javax.xml.Message, javax.xml.PortType, etc); a generator
  +for schema types; and a generator for the WSDL Definition itself.&nbsp;
  +This last generator is used to generate anything that doesn't fit into
  +the previous categories
  +<p>In addition to the getGeneratorMethods, the GeneratorFactory defines
  +a generatorPass method which provides the factory implementation a chance
  +to walk through the symbol table to do any preprocessing before the actual
  +generation begins.
  +<p>Accessors for the base type mapping are also defined.&nbsp; These are
  +used to translate QNames to base types in the given target mapping.
  +<br>&nbsp;</ul>
  +In addition to Parser, WSDL2, Generator, and GeneratorFactory, the org.apache.axis.wsdl.gen
  +package also contains a couple of no-op classes:&nbsp; NoopGenerator and
  +NoopFactory.&nbsp; NoopGenerator is a convenience class for extensions
  +that do not need to generate artifacts for every WSDL construct.&nbsp;
  +For example, WSDL2Java does not generate anything for messages, therefore
  +its factory's getGenerator(Message, SymbolTable) method returns an instance
  +of NoopGenerator.&nbsp; NoopFactory returns a NoopGenerator for all getGenerator
  +methods.&nbsp; The default factory for Parser is the NoopFactory.</ul>
  +
  +<h4>
  +Code Generator Back End</h4>
  +The meat of the WSDL2Java back end generators is in org.apache.axis.wsdl.toJava.&nbsp;
  +Emitter extends Parser.&nbsp; org.apache.axis.wsdl.WSDL2Java extends WSDL2.&nbsp;
  +JavaGeneratorFactory implements GeneratorFactory.&nbsp; And the various
  +JavaXXXWriter classes implement the Generator interface.
  +<p><font color="#FF0000">NOTE:&nbsp; Need lots more description here...</font>
  +<h4>
  +<a NAME="WSDL Examples"></a>WSDL Framework Extension Examples</h4>
  +Everything above sounds rather complex.&nbsp; It is, but that doesn't mean
  +your extension has to be.
  +<h5>
  +Example 1 - Simple extension of WSDL2Java - additional artifact</h5>
  +The simplest extension of the framework is one which generates everything
  +that WSDL2Java already generates, plus something new.&nbsp; Example 1 is
  +such an extension.&nbsp; It's extra artifact is a file for each service
  +that lists that service's ports.&nbsp; I don't know why you'd want to do
  +this, but it makes for a good, simple example.&nbsp; See samples/integrationGuide/example1
  +for the complete implementation of this example.
  +<br>&nbsp;
  +<ul>
  +<li>
  +First you must create your writer that writes the new artifact.&nbsp; This
  +new class extends org.apache.axis.wsdl.toJava.JavaWriter.&nbsp; JavaWriter
  +dictates behavior to its extensions; it calls writeFileHeader and writeFileBody.&nbsp;
  +Since we don't care about a file header for this example, writeFileHeader
  +is a no-op method.&nbsp; writeFileBody does the real work of this writer.</li>
  +
  +<p><br><tt>public class MyListPortsWriter extends JavaWriter {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; private Service service;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public MyListPortsWriter(</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +Emitter emitter,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +ServiceEntry sEntry,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +SymbolTable symbolTable) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(emitter,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +new QName(</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +sEntry.getQName().getNamespaceURI(),</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +sEntry.getQName().getLocalPart() + "Lst"),</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +"", "lst", "Generating service port list file", "service list");</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.service = sEntry.getService();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileHeader() throws IOException
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileBody() throws IOException
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Map portMap = service.getPorts();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iterator portIterator
  += portMap.values().iterator();</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (portIterator.hasNext())
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +Port p = (Port) portIterator.next();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +pw.println(p.getName());</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pw.close();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt>
  +<br>&nbsp;
  +<li>
  +Then you need a main program.&nbsp; This main program extends WSDL2Java
  +so that it gets all the functionality of that tool.&nbsp; The main of this
  +tool does 3 things:</li>
  +
  +<ul>
  +<li>
  +instantiates itself</li>
  +
  +<li>
  +adds MyListPortsWriter to the list of generators for a WSDL service</li>
  +
  +<li>
  +calls the run method.</li>
  +</ul>
  +That's it!&nbsp; The base tool does all the rest of the work.
  +<p><tt>public class MyWSDL2Java extends WSDL2Java {</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp; public static void main(String args[]) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyWSDL2Java myWSDL2Java
  += new MyWSDL2Java();</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JavaGeneratorFactory
  +factory =</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +(JavaGeneratorFactory) myWSDL2Java.getParser().getFactory();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factory.addGenerator(Service.class,
  +MyListPortsWriter.class);</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myWSDL2Java.run(args);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt></ul>
  +
  +<h5>
  +Example 2 - Not quite as simple an extension of WSDL2Java - change an artifact</h5>
  +In this example, we'll replace deploy.wsdd with mydeploy.useless.&nbsp;
  +For brevity, mydeploy.useless is rather useless.&nbsp; Making it useful
  +is an exercise left to the reader.&nbsp; See samples/integrationGuide/example2
  +for the complete implementation of this example.
  +<ul>
  +<li>
  +First, here is the writer for the mydeploy.useless.&nbsp; This new class
  +extends org.apache.axis.wsdl.toJava.JavaWriter.&nbsp; JavaWriter dictates
  +behavior to its extensions; it calls writeFileHeader and writeFileBody.&nbsp;
  +Since we don't care about a file header for this example, writeFileHeader
  +is a no-op method.&nbsp; writeFileBody does the real work of this writer.&nbsp;
  +It simply writes a bit of a song, depending on user input.</li>
  +
  +<p><br>Note that we've also overridden the generate method.&nbsp; The parser
  +always calls generate, but since this is a server-side artifact, we don't
  +want to generate it unless we are generating server-side artifacts (in
  +other words, in terms of the command line options, we've specified the
  +--serverSide option).
  +<p><tt>public class MyDeployWriter extends JavaWriter {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public MyDeployWriter(Emitter emitter, Definition
  +definition,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +SymbolTable symbolTable) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super(emitter,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +new QName(definition.getTargetNamespace(), "deploy"),</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +"", "useless", "Generating deploy.useless", "deploy");</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void generate() throws IOException {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (emitter.isServerSide())
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +super.generate();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileHeader() throws IOException
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void writeFileBody() throws IOException
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyEmitter myEmitter
  += (MyEmitter) emitter;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (myEmitter.getSong()
  +== MyEmitter.RUM) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +pw.println("Yo!&nbsp; Ho!&nbsp; Ho!&nbsp; And a bottle of rum.");</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if (myEmitter.getSong()
  +== MyEmitter.WORK) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +pw.println("Hi ho!&nbsp; Hi ho!&nbsp; It's off to work we go.");</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +pw.println("Feelings...&nbsp; Nothing more than feelings...");</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pw.close();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt>
  +<br><tt></tt>&nbsp;
  +<li>
  +Since we're changing what WSDL2Java generates, rather than simply adding
  +to it like the previous example did, calling addGenerator isn't good enough.&nbsp;
  +In order to change what WSDL2Java generates, you have to create a generator
  +factory and provide your own generators.&nbsp; Since we want to keep most
  +of WSDL2Java's artifacts, we can simply extend WSDL2Java's factory - JavaGeneratorFactory
  +- and override the addDefinitionGenerators method.</li>
  +
  +<p><br><tt>public class MyGeneratorFactory extends JavaGeneratorFactory
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void addDefinitionGenerators() {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
  +JavaDefinitionWriter.class); // WSDL2Java's JavaDefinitionWriter</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
  +MyDeployWriter.class); // our DeployWriter</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addGenerator(Definition.class,
  +JavaUndeployWriter.class); // WSDL2Java's JavaUndeployWriter</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt>
  +<br>&nbsp;
  +<li>
  +Now we must write the API's to our tool.&nbsp; Since we've added an option
  +- song - we need both the programmatic API - an extension of Parser (actually
  +Emitter in this case since we're extending WSDL2Java and Emitter is WSDL2Java's
  +parser extension) - and the command line API.</li>
  +
  +<p><br>Here is our programmatic API.&nbsp; It adds song accessors to Emitter.&nbsp;
  +It also, in the constructor, lets the factory know about the emitter and
  +the emitter know about the factory.
  +<p><tt>public class MyEmitter extends Emitter {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public static final int RUM&nbsp; = 0;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public static final int WORK = 1;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; private int song = -1;</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp; public MyEmitter() {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyGeneratorFactory factory
  += new MyGeneratorFactory();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setFactory(factory);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; factory.setEmitter(this);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public int getSong() {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return song;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public void setSong(int song) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.song = song;</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt>
  +<p>And here is our command line API.&nbsp; It's a bit more complex that
  +our previous example's main program, but it does 2 extra things:
  +<ol>
  +<li>
  +accept a new command line option:&nbsp; --song rum|work (this is the biggest
  +chunk of the new work).</li>
  +
  +<li>
  +create a new subclass of Parser</li>
  +</ol>
  +
  +<p><br><tt>public class WSDL2Useless extends WSDL2Java {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected static final int SONG_OPT = 'g';</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected static final CLOptionDescriptor[]
  +options = new CLOptionDescriptor[]{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new CLOptionDescriptor("song",</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +CLOptionDescriptor.ARGUMENT_REQUIRED,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +SONG_OPT,</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +"Choose a song for deploy.useless:&nbsp; work or rum")</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; };</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp; public WSDL2Useless() {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addOptions(options);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected Parser createParser() {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new MyEmitter();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; protected void parseOption(CLOption option)
  +{</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (option.getId() ==
  +SONG_OPT) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +String arg = option.getArgument();</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +if (arg.equals("rum")) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +((MyEmitter) parser).setSong(MyEmitter.RUM);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +}</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +else if (arg.equals("work")) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +((MyEmitter) parser).setSong(MyEmitter.WORK);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +}</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  +super.parseOption(option);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; public static void main(String args[]) {</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WSDL2Useless useless
  += new WSDL2Useless();</tt><tt></tt>
  +<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; useless.run(args);</tt>
  +<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
  +<br><tt>}</tt>
  +<p>Let's go through this one method at a time.
  +<ul>
  +<li>
  +constructor - this constructor adds the new option --song rum|work.&nbsp;
  +(the abbreviated version of this option is "-g", rather an odd abbreviation,
  +but "-s" is the abbreviation for --serverSide and "-S" is the abbreviation
  +for --skeletonDeploy.&nbsp; Bummer.&nbsp; I just picked some other letter.</li>
  +
  +<li>
  +createParser - we've got to provide a means by which the parent class can
  +get our Parser extension.</li>
  +
  +<li>
  +parseOption - this method processes our new option.&nbsp; If the given
  +option isn't ours, just let super.parseOption do its work.</li>
  +
  +<li>
  +main - this main is actually simpler than the first example's main.&nbsp;
  +The first main had to add our generator to the list of generators.&nbsp;
  +In this example, the factory already did that, so all that this main must
  +do is instantiate itself and run itself.</li>
  +</ul>
  +</ul>
   </body>
   </html>
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example1/MyListPortsWriter.java
  
  Index: MyListPortsWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example1;
  
  import java.io.IOException;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.wsdl.Port;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  import org.apache.axis.wsdl.symbolTable.ServiceEntry;
  import org.apache.axis.wsdl.symbolTable.SymbolTable;
  
  import org.apache.axis.wsdl.toJava.Emitter;
  import org.apache.axis.wsdl.toJava.JavaWriter;
  
  /**
  * This is my example of a class that writes a list of a service's
  * ports to a file named <serviceName>Lst.lst.
  *
  * Note:  because of a name clash problem, I add the suffix "Lst".
  * I hope to remove this in a future version of this example.
  *
  * Details of the JavaWriter bug:  JavaWriter looks to make sure a
  * class doesn't already exist before creating a file, but not all
  * files that we generate are .class files!  This works with
  * deploy.wsdd and undeploy.wsdd because these files just happen
  * to begin with lowercase letters, where Java classes begin with
  * uppercase letters.  But this example shows the problem quite
  * well.  I would LIKE to call the file <serviceName>.lst, but
  * JavaWriter sees that we already have a class called
  * <serviceName> and won't let me proceed.
  */
  public class MyListPortsWriter extends JavaWriter {
      private Service service;
  
      /**
       * Constructor.
       */
      public MyListPortsWriter(
              Emitter emitter,
              ServiceEntry sEntry,
              SymbolTable symbolTable) {
          super(emitter,
                  new QName(
                      sEntry.getQName().getNamespaceURI(),
                      sEntry.getQName().getLocalPart() + "Lst"),
                  "", "lst", "Generating service port list file", "service list");
          this.service = sEntry.getService();
      } // ctor
  
      /**
       * Override the common JavaWriter header to a no-op.
       */
      protected void writeFileHeader() throws IOException {
      } // writeFileHeader
  
      /**
       * Write the service list file.
       */
      protected void writeFileBody() throws IOException {
          Map portMap = service.getPorts();
          Iterator portIterator = portMap.values().iterator();
  
          while (portIterator.hasNext()) {
              Port p = (Port) portIterator.next();
              pw.println(p.getName());
          }
          pw.close(); // Note:  this really should be done in JavaWriter.
      } // writeFileBody
  
  } // class MyListPortsWriter
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example1/MyWSDL2Java.java
  
  Index: MyWSDL2Java.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example1;
  
  import javax.wsdl.Service;
  
  import org.apache.axis.wsdl.WSDL2Java;
  
  import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
  
  public class MyWSDL2Java extends WSDL2Java {
  
      /**
       * Main
       */
      public static void main(String args[]) {
          MyWSDL2Java myWSDL2Java = new MyWSDL2Java();
          JavaGeneratorFactory factory = (JavaGeneratorFactory) myWSDL2Java.getParser().getFactory();
          factory.addGenerator(Service.class, MyListPortsWriter.class);
          myWSDL2Java.run(args);
      } // main
  } // MyWSDL2Java
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example2/MyDeployWriter.java
  
  Index: MyDeployWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example2;
  
  import java.io.IOException;
  
  import javax.wsdl.Definition;
  import javax.wsdl.QName;
  
  import org.apache.axis.wsdl.symbolTable.SymbolTable;
  
  import org.apache.axis.wsdl.toJava.Emitter;
  import org.apache.axis.wsdl.toJava.JavaWriter;
  
  public class MyDeployWriter extends JavaWriter {
  
      public MyDeployWriter(Emitter emitter, Definition definition,
              SymbolTable symbolTable) {
          super(emitter,
                  new QName(definition.getTargetNamespace(), "deploy"),
                  "", "useless", "Generating deploy.useless", "deploy");
      } // ctor
  
      public void generate() throws IOException {
          if (emitter.isServerSide()) {
              super.generate();
          }
      } // generate
  
      /**
       * Override the common JavaWriter header to a no-op.
       */
      protected void writeFileHeader() throws IOException {
      } // writeFileHeader
  
      /**
       * Write the service list file.
       */
      protected void writeFileBody() throws IOException {
          MyEmitter myEmitter = (MyEmitter) emitter;
          if (myEmitter.getSong() == MyEmitter.RUM) {
              pw.println("Yo!  Ho!  Ho!  And a bottle of rum.");
          }
          else if (myEmitter.getSong() == MyEmitter.WORK) {
              pw.println("Hi ho!  Hi ho!  It's off to work we go.");
          }
          else {
              pw.println("Feelings...  Nothing more than feelings...");
          }
          pw.close(); // Note:  this really should be done in JavaWriter.
      } // writeFileBody
  } // class MyDeployWriter
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example2/MyEmitter.java
  
  Index: MyEmitter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example2;
  
  import org.apache.axis.wsdl.toJava.Emitter;
  
  public class MyEmitter extends Emitter {
  
      public static final int RUM  = 0;
      public static final int WORK = 1;
  
      private int song = -1;
  
      public MyEmitter() {
          MyGeneratorFactory factory = new MyGeneratorFactory();
          setFactory(factory);
          factory.setEmitter(this);
      } // ctor
  
      public int getSong() {
          return song;
      } // getSong
  
      public void setSong(int song) {
          this.song = song;
      } // setSong
  
  } // class MyEmitter
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example2/MyGeneratorFactory.java
  
  Index: MyGeneratorFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example2;
  
  import javax.wsdl.Definition;
  
  import org.apache.axis.wsdl.gen.Generator;
  
  import org.apache.axis.wsdl.symbolTable.SymbolTable;
  import org.apache.axis.wsdl.symbolTable.TypeEntry;
  
  import org.apache.axis.wsdl.toJava.Emitter;
  import org.apache.axis.wsdl.toJava.JavaDefinitionWriter;
  import org.apache.axis.wsdl.toJava.JavaGeneratorFactory;
  import org.apache.axis.wsdl.toJava.JavaUndeployWriter;
  
  /**
   * IBM Extension to WSDL2Java Emitter 
   * This class is used to locate the IBM extension writers.
   * (For example the IBM JavaType Writer)
   *
   * @author Rich Scheuerle (scheu@us.ibm.com)     
   * @author Russell Butek (butek@us.ibm.com)     
   */
  public class MyGeneratorFactory extends JavaGeneratorFactory {
      /*
       * NOTE!  addDefinitionGenerators is the ONLY addXXXGenerators method
       * that works at this point in time (2002-17-May).  This rest of them
       * are soon to be implemented.
       */
      protected void addDefinitionGenerators() {
          addGenerator(Definition.class, JavaDefinitionWriter.class); // WSDL2Java's JavaDefinitionWriter
          addGenerator(Definition.class, MyDeployWriter.class); // our DeployWriter
          addGenerator(Definition.class, JavaUndeployWriter.class); // WSDL2Java's JavaUndeployWriter
      } // addDefinitionGenerators
  
  } // class MyGeneratorFactory
  
  
  
  1.1                  xml-axis/java/samples/integrationGuide/example2/WSDL2Useless.java
  
  Index: WSDL2Useless.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package samples.integrationGuide.example2;
  
  import org.apache.axis.utils.CLOption;
  import org.apache.axis.utils.CLOptionDescriptor;
  
  import org.apache.axis.wsdl.WSDL2Java;
  
  import org.apache.axis.wsdl.gen.Parser;
  
  import org.apache.axis.wsdl.toJava.Emitter;
  
  public class WSDL2Useless extends WSDL2Java {
  
      protected static final int SONG_OPT = 'g';
  
      protected static final CLOptionDescriptor[] options = new CLOptionDescriptor[]{
          new CLOptionDescriptor("song",
                  CLOptionDescriptor.ARGUMENT_REQUIRED,
                  SONG_OPT,
                  "Choose a song for deploy.useless:  work or rum")
      };
  
      public WSDL2Useless() {
          addOptions(options);
      } // ctor
  
      protected Parser createParser() {
          return new MyEmitter();
      } // createParser
  
      protected void parseOption(CLOption option) {
          if (option.getId() == SONG_OPT) {
              String arg = option.getArgument();
              if (arg.equals("rum")) {
                  ((MyEmitter) parser).setSong(MyEmitter.RUM);
              }
              else if (arg.equals("work")) {
                  ((MyEmitter) parser).setSong(MyEmitter.WORK);
              }
          }
          else {
              super.parseOption(option);
          }
      } // parseOption
  
      /**
       * Main
       */
      public static void main(String args[]) {
          WSDL2Useless useless = new WSDL2Useless();
  
          useless.run(args);
      } // main
  } // class WSDL2Useless