1 16 package org.apache.axis.wsdl.toJava; 17 18 import org.apache.axis.deployment.wsdd.WSDDConstants; 19 import org.apache.axis.utils.Messages; 20 import org.apache.axis.wsdl.symbolTable.SymbolTable; 21 22 import javax.wsdl.Definition; 23 import javax.wsdl.Port; 24 import javax.wsdl.Service; 25 import java.io.File ; 26 import java.io.FileOutputStream ; 27 import java.io.IOException ; 28 import java.io.OutputStreamWriter ; 29 import java.io.PrintWriter ; 30 import java.util.Iterator ; 31 import java.util.Map ; 32 33 36 public class JavaUndeployWriter extends JavaWriter { 37 38 39 protected Definition definition; 40 41 48 public JavaUndeployWriter(Emitter emitter, Definition definition, 49 SymbolTable notUsed) { 50 51 super(emitter, "undeploy"); 52 53 this.definition = definition; 54 } 56 62 public void generate() throws IOException { 63 64 if (emitter.isServerSide()) { 65 super.generate(); 66 } 67 } 69 75 protected String getFileName() { 76 77 String dir = 78 emitter.getNamespaces().getAsDir(definition.getTargetNamespace()); 79 80 return dir + "undeploy.wsdd"; 81 } 83 89 protected void writeFileHeader(PrintWriter pw) throws IOException { 90 91 pw.println(Messages.getMessage("deploy01")); 92 pw.println(Messages.getMessage("deploy02")); 93 pw.println(Messages.getMessage("deploy04")); 94 pw.println(Messages.getMessage("deploy05")); 95 pw.println(Messages.getMessage("deploy06")); 96 pw.println(Messages.getMessage("deploy08")); 97 pw.println(Messages.getMessage("deploy09")); 98 pw.println(); 99 pw.println("<undeployment"); 100 pw.println(" xmlns=\"" + WSDDConstants.URI_WSDD + "\">"); 101 } 103 109 protected void writeFileBody(PrintWriter pw) throws IOException { 110 writeDeployServices(pw); 111 pw.println("</undeployment>"); 112 } 114 120 protected void writeDeployServices(PrintWriter pw) throws IOException { 121 122 Map serviceMap = definition.getServices(); 124 125 for (Iterator mapIterator = serviceMap.values().iterator(); 126 mapIterator.hasNext();) { 127 Service myService = (Service) mapIterator.next(); 128 129 pw.println(); 130 pw.println( 131 " <!-- " 132 + Messages.getMessage( 133 "wsdlService00", myService.getQName().getLocalPart()) + " -->"); 134 pw.println(); 135 136 for (Iterator portIterator = myService.getPorts().values().iterator(); 137 portIterator.hasNext();) { 138 Port myPort = (Port) portIterator.next(); 139 140 writeDeployPort(pw, myPort); 141 } 142 } 143 } 145 152 protected void writeDeployPort(PrintWriter pw, Port port) throws IOException { 153 154 String serviceName = port.getName(); 155 156 pw.println(" <service name=\"" + serviceName + "\"/>"); 157 } 159 166 protected PrintWriter getPrintWriter(String filename) throws IOException { 167 168 File file = new File (filename); 169 File parent = new File (file.getParent()); 170 171 parent.mkdirs(); 172 173 FileOutputStream out = new FileOutputStream (file); 174 OutputStreamWriter writer = new OutputStreamWriter (out, "UTF-8"); 175 176 return new PrintWriter (writer); 177 } 178 } | Popular Tags |