1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.deployment.wsdd.WSDDConstants; 58 import org.jboss.axis.utils.Messages; 59 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 60 61 import javax.wsdl.Definition; 62 import javax.wsdl.Port; 63 import javax.wsdl.Service; 64 import java.io.File ; 65 import java.io.FileOutputStream ; 66 import java.io.IOException ; 67 import java.io.OutputStreamWriter ; 68 import java.io.PrintWriter ; 69 import java.util.Iterator ; 70 import java.util.Map ; 71 72 75 public class JavaUndeployWriter extends JavaWriter 76 { 77 protected Definition definition; 78 79 82 public JavaUndeployWriter(Emitter emitter, Definition definition, SymbolTable notUsed) 83 { 84 super(emitter, "undeploy"); 85 this.definition = definition; 86 } 88 92 public void generate() throws IOException 93 { 94 if (emitter.isServerSide()) 95 { 96 super.generate(); 97 } 98 } 100 104 protected String getFileName() 105 { 106 String dir = emitter.getNamespaces().getAsDir(definition.getTargetNamespace()); 107 return dir + "undeploy.wsdd"; 108 } 110 113 protected void writeFileHeader(PrintWriter pw) throws IOException 114 { 115 pw.println(Messages.getMessage("deploy01")); 116 pw.println(Messages.getMessage("deploy02")); 117 pw.println(Messages.getMessage("deploy04")); 118 pw.println(Messages.getMessage("deploy05")); 119 pw.println(Messages.getMessage("deploy06")); 120 pw.println(Messages.getMessage("deploy08")); 121 pw.println(Messages.getMessage("deploy09")); 122 pw.println(); 123 pw.println("<undeployment"); 124 pw.println(" xmlns=\"" + WSDDConstants.URI_WSDD + "\">"); 125 } 127 130 protected void writeFileBody(PrintWriter pw) throws IOException 131 { 132 writeDeployServices(pw); 133 pw.println("</undeployment>"); 134 } 136 139 private void writeDeployServices(PrintWriter pw) throws IOException 140 { 141 Map serviceMap = definition.getServices(); 143 for (Iterator mapIterator = serviceMap.values().iterator(); mapIterator.hasNext();) 144 { 145 Service myService = (Service)mapIterator.next(); 146 147 pw.println(); 148 pw.println(" <!-- " + Messages.getMessage("wsdlService00", 149 myService.getQName().getLocalPart()) + " -->"); 150 pw.println(); 151 152 for (Iterator portIterator = myService.getPorts().values().iterator(); portIterator.hasNext();) 153 { 154 Port myPort = (Port)portIterator.next(); 155 writeDeployPort(pw, myPort); 156 } 157 } 158 } 160 163 private void writeDeployPort(PrintWriter pw, Port port) throws IOException 164 { 165 String serviceName = port.getName(); 166 167 pw.println(" <service name=\"" + serviceName + "\"/>"); 168 } 170 protected PrintWriter getPrintWriter(String filename) throws IOException 171 { 172 File file = new File (filename); 173 File parent = new File (file.getParent()); 174 parent.mkdirs(); 175 FileOutputStream out = new FileOutputStream (file); 176 OutputStreamWriter writer = new OutputStreamWriter (out, "UTF-8"); 177 return new PrintWriter (writer); 178 } 179 } | Popular Tags |