1 16 package org.apache.axis.wsdl.toJava; 17 18 import org.apache.axis.utils.Messages; 19 import org.apache.axis.wsdl.gen.Generator; 20 import org.apache.axis.wsdl.symbolTable.BindingEntry; 21 import org.apache.axis.wsdl.symbolTable.PortTypeEntry; 22 import org.apache.axis.wsdl.symbolTable.SymbolTable; 23 24 import javax.wsdl.Binding; 25 import java.io.IOException ; 26 27 31 public class JavaBindingWriter implements Generator { 32 33 34 protected Generator stubWriter = null; 35 36 37 protected Generator skelWriter = null; 38 39 40 protected Generator implWriter = null; 41 42 43 protected Generator interfaceWriter = null; 44 45 46 protected Emitter emitter; 47 48 49 protected Binding binding; 50 51 52 protected SymbolTable symbolTable; 53 54 60 61 public static String INTERFACE_NAME = "interface name"; 62 63 70 public JavaBindingWriter(Emitter emitter, Binding binding, 71 SymbolTable symbolTable) { 72 73 this.emitter = emitter; 74 this.binding = binding; 75 this.symbolTable = symbolTable; 76 } 78 87 protected Generator getJavaInterfaceWriter(Emitter emitter, 88 PortTypeEntry ptEntry, 89 BindingEntry bEntry, 90 SymbolTable st) { 91 return new JavaInterfaceWriter(emitter, ptEntry, bEntry, st); 92 } 93 94 102 protected Generator getJavaStubWriter(Emitter emitter, BindingEntry bEntry, 103 SymbolTable st) { 104 return new JavaStubWriter(emitter, bEntry, st); 105 } 106 107 115 protected Generator getJavaSkelWriter(Emitter emitter, BindingEntry bEntry, 116 SymbolTable st) { 117 return new JavaSkelWriter(emitter, bEntry, st); 118 } 119 120 128 protected Generator getJavaImplWriter(Emitter emitter, BindingEntry bEntry, 129 SymbolTable st) { 130 return new JavaImplWriter(emitter, bEntry, st); 131 } 132 133 138 public void generate() throws IOException { 139 140 setGenerators(); 141 postSetGenerators(); 142 143 if (interfaceWriter != null) { 144 interfaceWriter.generate(); 145 } 146 147 if (stubWriter != null) { 148 stubWriter.generate(); 149 } 150 151 if (skelWriter != null) { 152 skelWriter.generate(); 153 } 154 155 if (implWriter != null) { 156 implWriter.generate(); 157 } 158 } 160 166 protected void setGenerators() { 167 168 BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); 169 170 PortTypeEntry ptEntry = 172 symbolTable.getPortTypeEntry(binding.getPortType().getQName()); 173 174 if (ptEntry.isReferenced()) { 175 interfaceWriter = getJavaInterfaceWriter(emitter, ptEntry, bEntry, 176 symbolTable); 177 } 178 179 if (bEntry.isReferenced()) { 180 181 stubWriter = getJavaStubWriter(emitter, bEntry, symbolTable); 183 184 if (emitter.isServerSide()) { 186 if (emitter.isSkeletonWanted()) { 187 skelWriter = getJavaSkelWriter(emitter, bEntry, 188 symbolTable); 189 } 190 191 String fileName = emitter.getImplementationClassName(); 193 if ( fileName == null) 194 fileName = Utils.getJavaLocalName(bEntry.getName()) 195 + "Impl.java"; 196 else 197 fileName = Utils.getJavaLocalName(fileName) + ".java"; 198 199 try { 200 if (Utils.fileExists(fileName, 201 binding.getQName().getNamespaceURI(), 202 emitter.getNamespaces())) { 203 if (!emitter.isQuiet()) { 204 System.out.println( 205 Messages.getMessage("wontOverwrite", 206 fileName)); 207 } 208 } else { 209 implWriter = getJavaImplWriter(emitter, bEntry, 210 symbolTable); 211 } 212 } catch (IOException ioe) { 213 System.err.println(Messages.getMessage("fileExistError00", 214 fileName)); 215 } 216 } 217 } 218 } 219 220 223 protected void postSetGenerators() { 224 if (emitter.isDeploy()) { 225 interfaceWriter = null; 226 stubWriter = null; 227 skelWriter = null; 228 implWriter = null; 229 } 230 } 231 } | Popular Tags |