1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.wsdl.symbolTable.BindingEntry; 58 import org.jboss.axis.wsdl.symbolTable.Parameter; 59 import org.jboss.axis.wsdl.symbolTable.Parameters; 60 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 61 import org.jboss.axis.wsdl.symbolTable.TypeEntry; 62 63 import javax.wsdl.Binding; 64 import javax.wsdl.BindingOperation; 65 import javax.wsdl.Operation; 66 import javax.wsdl.OperationType; 67 import javax.xml.rpc.holders.BooleanHolder ; 68 import java.io.IOException ; 69 import java.io.PrintWriter ; 70 import java.util.Iterator ; 71 import java.util.List ; 72 73 77 public class JavaImplWriter extends JavaClassWriter 78 { 79 protected Binding binding; 80 protected SymbolTable symbolTable; 81 protected BindingEntry bEntry; 82 83 86 protected JavaImplWriter(Emitter emitter, 87 BindingEntry bEntry, 88 SymbolTable symbolTable) 89 { 90 super(emitter, bEntry.getName() + "Impl", "templateImpl"); 91 this.binding = bEntry.getBinding(); 92 this.symbolTable = symbolTable; 93 this.bEntry = bEntry; 94 } 96 99 protected void writeFileBody(PrintWriter pw) throws IOException 100 { 101 List operations = binding.getBindingOperations(); 102 for (int i = 0; i < operations.size(); ++i) 103 { 104 BindingOperation operation = (BindingOperation)operations.get(i); 105 Operation ptOperation = operation.getOperation(); 106 OperationType type = ptOperation.getStyle(); 107 Parameters parameters = 108 bEntry.getParameters(operation.getOperation()); 109 110 if (type == OperationType.NOTIFICATION 113 || type == OperationType.SOLICIT_RESPONSE) 114 { 115 pw.println(parameters.signature); 116 pw.println(); 117 } 118 else 119 { 120 writeOperation(pw, parameters); 121 } 122 } 123 } 125 130 protected String getImplementsText() 131 { 132 String portTypeName = (String )bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME); 133 String implementsText = "implements " + portTypeName; 134 return implementsText; 135 } 136 137 140 protected void writeOperation(PrintWriter pw, Parameters parms) throws IOException 141 { 142 pw.println(parms.signature + " {"); 143 144 Iterator iparam = parms.list.iterator(); 146 while (iparam.hasNext()) 147 { 148 Parameter param = (Parameter)iparam.next(); 149 if (param.getMode() == Parameter.OUT) 150 { 151 153 BooleanHolder bThrow = new BooleanHolder (false); 154 String constructorString = 155 Utils.getConstructorForParam(param, symbolTable, bThrow); 156 if (bThrow.value) 157 { 158 pw.println(" try {"); 159 } 160 pw.println(" " + Utils.xmlNameToJava(param.getName()) 161 + ".value = " + constructorString + ";"); 162 if (bThrow.value) 163 { 164 pw.println(" } catch (Exception e) {"); 165 pw.println(" }"); 166 } 167 } 168 } 169 170 if (parms.returnParam != null) 172 { 173 TypeEntry returnType = parms.returnParam.getType(); 174 pw.print(" return "); 175 176 if (Utils.isPrimitiveType(returnType)) 177 { 178 String returnString = returnType.getName(); 179 if ("boolean".equals(returnString)) 180 { 181 pw.println("false;"); 182 } 183 else if ("byte".equals(returnString)) 184 { 185 pw.println("(byte)-3;"); 186 } 187 else if ("short".equals(returnString)) 188 { 189 pw.println("(short)-3;"); 190 } 191 else 192 { 193 pw.println("-3;"); 194 } 195 } 196 else 197 { 198 pw.println("null;"); 199 } 200 } 201 pw.println(" }"); 202 pw.println(); 203 } 205 } | Popular Tags |