FileDocCategorySizeDatePackage
MyListPortsWriter.javaAPI DocApache Axis 1.43234Sat Apr 22 18:56:52 BST 2006samples.integrationGuide.example1

MyListPortsWriter

public class MyListPortsWriter extends 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 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 .lst, but JavaWriter sees that we already have a class called and won't let me proceed.

Fields Summary
private javax.wsdl.Service
service
private String
fileName
Constructors Summary
public MyListPortsWriter(org.apache.axis.wsdl.toJava.Emitter emitter, org.apache.axis.wsdl.symbolTable.ServiceEntry sEntry, org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Constructor.

        super(emitter, "service list");
        this.service = sEntry.getService();

        // Create the fully-qualified file name
        String javaName = sEntry.getName();
        fileName = emitter.getNamespaces().toDir(
                Utils.getJavaPackageName(javaName))
                + Utils.getJavaLocalName(javaName) + ".lst";
    
Methods Summary
protected java.lang.StringgetFileName()

        return fileName;
    
protected voidwriteFileBody(java.io.PrintWriter pw)
Write the service list file.

        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.
    
protected voidwriteFileHeader(java.io.PrintWriter pw)
Override the common JavaWriter header to a no-op.