1 55 package org.jboss.axis.wsdl.toJava; 56 57 import org.jboss.axis.encoding.DefaultTypeMappingImpl; 58 import org.jboss.axis.encoding.TypeMapping; 59 import org.jboss.axis.utils.JavaUtils; 60 import org.jboss.axis.utils.Messages; 61 import org.jboss.axis.wsdl.gen.Generator; 62 import org.jboss.axis.wsdl.gen.GeneratorFactory; 63 import org.jboss.axis.wsdl.gen.NoopGenerator; 64 import org.jboss.axis.wsdl.symbolTable.BaseTypeMapping; 65 import org.jboss.axis.wsdl.symbolTable.BindingEntry; 66 import org.jboss.axis.wsdl.symbolTable.Element; 67 import org.jboss.axis.wsdl.symbolTable.FaultInfo; 68 import org.jboss.axis.wsdl.symbolTable.MessageEntry; 69 import org.jboss.axis.wsdl.symbolTable.Parameter; 70 import org.jboss.axis.wsdl.symbolTable.Parameters; 71 import org.jboss.axis.wsdl.symbolTable.PortTypeEntry; 72 import org.jboss.axis.wsdl.symbolTable.SchemaUtils; 73 import org.jboss.axis.wsdl.symbolTable.ServiceEntry; 74 import org.jboss.axis.wsdl.symbolTable.SymTabEntry; 75 import org.jboss.axis.wsdl.symbolTable.SymbolTable; 76 import org.jboss.axis.wsdl.symbolTable.Type; 77 import org.jboss.axis.wsdl.symbolTable.TypeEntry; 78 79 import javax.wsdl.Binding; 80 import javax.wsdl.Definition; 81 import javax.wsdl.Fault; 82 import javax.wsdl.Message; 83 import javax.wsdl.Operation; 84 import javax.wsdl.OperationType; 85 import javax.wsdl.PortType; 86 import javax.wsdl.Service; 87 import javax.xml.namespace.QName ; 88 import javax.xml.rpc.holders.BooleanHolder ; 89 import java.io.IOException ; 90 import java.lang.reflect.Constructor ; 91 import java.util.ArrayList ; 92 import java.util.HashMap ; 93 import java.util.HashSet ; 94 import java.util.Iterator ; 95 import java.util.Map ; 96 import java.util.Vector ; 97 98 101 102 public class JavaGeneratorFactory implements GeneratorFactory 103 { 104 protected Emitter emitter; 105 protected SymbolTable symbolTable; 106 107 public static String COMPLEX_TYPE_FAULT = "ComplexTypeFault"; 108 public static String EXCEPTION_CLASS_NAME = "ExceptionClassName"; 109 public static String EXCEPTION_DATA_TYPE = "ExceptionDataType"; 110 111 115 116 public JavaGeneratorFactory() 117 { 118 addGenerators(); 119 } 121 public JavaGeneratorFactory(Emitter emitter) 122 { 123 this.emitter = emitter; 124 addGenerators(); 125 } 127 public void setEmitter(Emitter emitter) 128 { 129 this.emitter = emitter; 130 } 132 private void addGenerators() 133 { 134 addMessageGenerators(); 135 addPortTypeGenerators(); 136 addBindingGenerators(); 137 addServiceGenerators(); 138 addTypeGenerators(); 139 addDefinitionGenerators(); 140 } 142 153 protected void addMessageGenerators() 154 { 155 } 157 protected void addPortTypeGenerators() 158 { 159 } 161 protected void addBindingGenerators() 162 { 163 } 165 protected void addServiceGenerators() 166 { 167 } 169 protected void addTypeGenerators() 170 { 171 } 173 protected void addDefinitionGenerators() 174 { 175 addGenerator(Definition.class, JavaDefinitionWriter.class); addGenerator(Definition.class, JavaDeployWriter.class); addGenerator(Definition.class, JavaUndeployWriter.class); } 180 185 public void generatorPass(Definition def, SymbolTable symbolTable) 186 { 187 this.symbolTable = symbolTable; 188 javifyNames(symbolTable); 189 setFaultContext(symbolTable); 190 resolveNameClashes(symbolTable); 191 determineInterfaceNames(symbolTable); 192 if (emitter.isAllWanted()) 193 { 194 setAllReferencesToTrue(); 195 } 196 else 197 { 198 ignoreNonSOAPBindings(symbolTable); 199 } 200 constructSignatures(symbolTable); 201 determineIfHoldersNeeded(symbolTable); 202 } 204 207 private Writers messageWriters = new Writers(); 208 209 public Generator getGenerator(Message message, SymbolTable symbolTable) 210 { 211 MessageEntry mEntry = symbolTable.getMessageEntry(message.getQName()); 212 messageWriters.addStuff(new NoopGenerator(), mEntry, symbolTable); 213 return messageWriters; 214 } 216 219 private Writers portTypeWriters = new Writers(); 220 221 public Generator getGenerator(PortType portType, SymbolTable symbolTable) 222 { 223 PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); 224 portTypeWriters.addStuff(new NoopGenerator(), ptEntry, symbolTable); 225 return portTypeWriters; 226 } 228 231 protected Writers bindingWriters = new Writers(); 232 233 public Generator getGenerator(Binding binding, SymbolTable symbolTable) 234 { 235 Generator writer = new JavaBindingWriter(emitter, binding, symbolTable); 236 BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); 237 bindingWriters.addStuff(writer, bEntry, symbolTable); 238 return bindingWriters; 239 } 241 244 protected Writers serviceWriters = new Writers(); 245 246 public Generator getGenerator(Service service, SymbolTable symbolTable) 247 { 248 Generator writer = new JavaServiceWriter(emitter, service, symbolTable); 249 ServiceEntry sEntry = symbolTable.getServiceEntry(service.getQName()); 250 serviceWriters.addStuff(writer, sEntry, symbolTable); 251 return serviceWriters; 252 } 254 257 private Writers typeWriters = new Writers(); 258 259 public Generator getGenerator(TypeEntry type, SymbolTable symbolTable) 260 { 261 Generator writer = new JavaTypeWriter(emitter, type, symbolTable); 262 typeWriters.addStuff(writer, type, symbolTable); 263 return typeWriters; 264 } 266 269 private Writers defWriters = new Writers(); 270 271 public Generator getGenerator(Definition definition, SymbolTable symbolTable) 272 { 273 defWriters.addStuff(null, definition, symbolTable); 274 return defWriters; 275 } 277 protected class Writers implements Generator 279 { 280 Vector writers = new Vector (); 281 SymbolTable symbolTable = null; 282 Generator baseWriter = null; 283 284 SymTabEntry entry = null; 286 Definition def = null; 287 288 public void addGenerator(Class writer) 289 { 290 writers.add(writer); 291 } 293 public void addStuff(Generator baseWriter, SymTabEntry entry, SymbolTable symbolTable) 294 { 295 this.baseWriter = baseWriter; 296 this.entry = entry; 297 this.symbolTable = symbolTable; 298 } 300 public void addStuff(Generator baseWriter, Definition def, SymbolTable symbolTable) 301 { 302 this.baseWriter = baseWriter; 303 this.def = def; 304 this.symbolTable = symbolTable; 305 } 307 public void generate() throws IOException 308 { 309 if (baseWriter != null) 310 { 311 baseWriter.generate(); 312 } 313 Class [] formalArgs = null; 314 Object [] actualArgs = null; 315 if (entry != null) 316 { 317 formalArgs = new Class []{Emitter.class, entry.getClass(), SymbolTable.class}; 318 actualArgs = new Object []{emitter, entry, symbolTable}; 319 } 320 else 321 { 322 formalArgs = new Class []{Emitter.class, Definition.class, SymbolTable.class}; 323 actualArgs = new Object []{emitter, def, symbolTable}; 324 } 325 for (int i = 0; i < writers.size(); ++i) 326 { 327 Class wClass = (Class )writers.get(i); 328 Generator gen = null; 329 try 330 { 331 Constructor ctor = wClass.getConstructor(formalArgs); 332 gen = (Generator)ctor.newInstance(actualArgs); 333 } 334 catch (Throwable t) 335 { 336 throw new IOException (Messages.getMessage("exception01", t.getMessage())); 337 } 338 gen.generate(); 339 } 340 } } 343 public void addGenerator(Class wsdlClass, Class generator) 344 { 345 if (Message.class.isAssignableFrom(wsdlClass)) 347 { 348 messageWriters.addGenerator(generator); 349 } 350 else if (PortType.class.isAssignableFrom(wsdlClass)) 351 { 352 portTypeWriters.addGenerator(generator); 353 } 354 else if (Binding.class.isAssignableFrom(wsdlClass)) 355 { 356 bindingWriters.addGenerator(generator); 357 } 358 else if (Service.class.isAssignableFrom(wsdlClass)) 359 { 360 serviceWriters.addGenerator(generator); 361 } 362 else if (TypeEntry.class.isAssignableFrom(wsdlClass)) 363 { 364 typeWriters.addGenerator(generator); 365 } 366 else if (Definition.class.isAssignableFrom(wsdlClass)) 367 { 368 defWriters.addGenerator(generator); 369 } 370 } 372 377 protected void javifyNames(SymbolTable symbolTable) 378 { 379 int uniqueNum = 0; 380 HashMap anonQNames = new HashMap (); 381 Iterator it = symbolTable.getHashMap().values().iterator(); 382 while (it.hasNext()) 383 { 384 Vector v = (Vector )it.next(); 385 for (int i = 0; i < v.size(); ++i) 386 { 387 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 388 if (entry.getName() != null) 389 continue; 390 391 if (entry instanceof TypeEntry) 393 { 394 TypeEntry tEntry = (TypeEntry)entry; 395 String dims = tEntry.getDimensions(); 396 TypeEntry refType = tEntry.getRefType(); 397 while (refType != null) 398 { 399 tEntry = refType; 400 dims += tEntry.getDimensions(); 401 refType = tEntry.getRefType(); 402 } 403 404 405 if (tEntry.getName() == null) 408 { 409 QName typeQName = tEntry.getQName(); 412 if ((typeQName.getLocalPart(). 413 indexOf(SymbolTable.ANON_TOKEN) < 0)) 414 { 415 tEntry.setName(emitter.getJavaName(typeQName)); 419 } 420 else 421 { 422 428 429 437 String localName = typeQName.getLocalPart(); 438 439 StringBuffer sb = new StringBuffer (localName); 445 int aidx = -1; 446 while ( 447 (aidx = sb.toString().indexOf(SymbolTable.ANON_TOKEN)) > -1) 448 { 449 sb.replace(aidx, aidx + SymbolTable.ANON_TOKEN.length(), "_"); 450 } 451 localName = sb.toString(); 452 453 typeQName = new QName (typeQName.getNamespaceURI(), 454 localName); 455 456 symbolTable.getType(typeQName); 462 if (anonQNames.get(typeQName) != null) 463 { 464 localName += "Type" + uniqueNum++; 465 typeQName = 466 new QName (typeQName.getNamespaceURI(), 467 localName); 468 } 469 anonQNames.put(typeQName, typeQName); 470 471 tEntry.setName(emitter.getJavaName(typeQName)); 473 } 474 } 475 entry.setName(tEntry.getName() + dims); 478 } 479 480 else 483 { 484 entry.setName(emitter.getJavaName(entry.getQName())); 485 } 486 } 487 } 488 } 490 503 private void setFaultContext(SymbolTable symbolTable) 504 { 505 Iterator it = symbolTable.getHashMap().values().iterator(); 506 while (it.hasNext()) 507 { 508 Vector v = (Vector )it.next(); 509 for (int i = 0; i < v.size(); ++i) 510 { 511 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 512 if (entry instanceof BindingEntry) 514 { 515 BindingEntry bEntry = (BindingEntry)entry; 516 Map allOpFaults = bEntry.getFaults(); 517 Iterator ops = allOpFaults.values().iterator(); 518 while (ops.hasNext()) 520 { 521 ArrayList faults = (ArrayList )ops.next(); 522 for (int j = 0; j < faults.size(); ++j) 523 { 524 FaultInfo info = (FaultInfo)faults.get(j); 525 setFaultContext(info, symbolTable); 526 } 527 } 528 } 529 } 530 } 531 } 533 542 private void setFaultContext(FaultInfo fault, 543 SymbolTable symbolTable) 544 { 545 QName faultXmlType = null; 546 547 Vector parts = new Vector (); 548 try 552 { 553 symbolTable.getParametersFromParts(parts, 554 fault.getMessage().getOrderedParts(null), 555 false, 556 fault.getName(), 557 null); 558 } 559 catch (IOException e) 560 { 561 } 562 563 String exceptionClassName = null; 565 for (int j = 0; j < parts.size(); j++) 566 { 567 TypeEntry te = ((Parameter)(parts.elementAt(j))).getType(); 568 569 TypeEntry elementTE = null; 572 if (te instanceof Element) 573 { 574 elementTE = te; 575 te = te.getRefType(); 576 } 577 578 faultXmlType = te.getQName(); 580 581 if (te.getBaseType() != null || 585 te.isSimpleType() || 586 (te.getDimensions().length() > 0 && 587 te.getRefType().getBaseType() != null)) 588 { 589 } 591 else 592 { 593 Boolean isComplexFault = (Boolean )te.getDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT); 595 if (isComplexFault == null || 596 !isComplexFault.booleanValue()) 597 { 598 te.setDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT, 600 new Boolean (true)); 601 if (elementTE != null) 602 { 603 te.setDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT, 604 new Boolean (true)); 605 } 606 607 HashSet derivedSet = 609 org.jboss.axis.wsdl.symbolTable.Utils.getDerivedTypes(te, symbolTable); 610 Iterator derivedI = derivedSet.iterator(); 611 while (derivedI.hasNext()) 612 { 613 TypeEntry derivedTE = (TypeEntry) 614 derivedI.next(); 615 derivedTE.setDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT, 616 new Boolean (true)); 617 } 618 TypeEntry base = SchemaUtils.getComplexElementExtensionBase(te.getNode(), 620 symbolTable); 621 while (base != null) 622 { 623 base.setDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT, 624 new Boolean (true)); 625 base = SchemaUtils.getComplexElementExtensionBase(base.getNode(), 626 symbolTable); 627 } 628 } 629 exceptionClassName = te.getName(); 631 } 632 } 633 MessageEntry me = symbolTable.getMessageEntry(fault.getMessage().getQName()); 636 if (me != null) 637 { 638 me.setDynamicVar(JavaGeneratorFactory.EXCEPTION_DATA_TYPE, 639 faultXmlType); 640 if (exceptionClassName != null) 641 { 642 me.setDynamicVar(JavaGeneratorFactory.COMPLEX_TYPE_FAULT, 643 new Boolean (true)); 644 me.setDynamicVar(JavaGeneratorFactory.EXCEPTION_CLASS_NAME, 645 exceptionClassName); 646 } 647 else 648 { 649 me.setDynamicVar(JavaGeneratorFactory.EXCEPTION_CLASS_NAME, 650 emitter.getJavaName(me.getQName())); 651 } 652 653 } 654 } 655 656 protected void determineInterfaceNames(SymbolTable symbolTable) 657 { 658 Iterator it = symbolTable.getHashMap().values().iterator(); 659 while (it.hasNext()) 660 { 661 Vector v = (Vector )it.next(); 662 for (int i = 0; i < v.size(); ++i) 663 { 664 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 665 if (entry instanceof BindingEntry) 666 { 667 BindingEntry bEntry = (BindingEntry)entry; 670 String seiName = null; 671 672 PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(bEntry.getBinding().getPortType().getQName()); 673 seiName = ptEntry.getName(); 674 bEntry.setDynamicVar(JavaBindingWriter.INTERFACE_NAME, seiName); 675 } 676 } 677 } 678 } 680 684 protected void resolveNameClashes(SymbolTable symbolTable) 685 { 686 687 HashSet anonTypes = new HashSet (); 689 690 Iterator it = symbolTable.getHashMap().values().iterator(); 691 while (it.hasNext()) 692 { 693 Vector v = new Vector ((Vector )it.next()); 695 int index = 0; 697 while (index < v.size()) 698 { 699 if (v.elementAt(index) instanceof MessageEntry) 700 { 701 v.removeElementAt(index); 702 } 703 else 704 { 705 index++; 706 } 707 } 708 709 if (v.size() > 1) 710 { 711 boolean resolve = true; 712 if (v.size() == 2 && 717 ((v.elementAt(0) instanceof Element && 718 v.elementAt(1) instanceof Type) || 719 (v.elementAt(1) instanceof Element && 720 v.elementAt(0) instanceof Type))) 721 { 722 Element e = null; 723 if (v.elementAt(0) instanceof Element) 724 { 725 e = (Element)v.elementAt(0); 726 } 727 else 728 { 729 e = (Element)v.elementAt(1); 730 } 731 BooleanHolder forElement = new BooleanHolder (); 732 QName eType = Utils.getTypeQName(e.getNode(), forElement, false); 733 if (eType != null && 734 eType.equals(e.getQName()) && 735 !forElement.value) 736 resolve = false; 737 } 738 739 if (resolve) 742 { 743 resolve = false; String name = null; 745 for (int i = 0; i < v.size() && !resolve; ++i) 746 { 747 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 748 if (entry instanceof MessageEntry || 749 entry instanceof BindingEntry) 750 { 751 ; } 753 else if (name == null) 754 { 755 name = entry.getName(); 756 } 757 else if (name.equals(entry.getName())) 758 { 759 resolve = true; } 761 762 } 763 } 764 765 if (resolve) 767 { 768 boolean firstType = true; 769 for (int i = 0; i < v.size(); ++i) 770 { 771 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 772 if (entry instanceof Element) 773 { 774 entry.setName(mangleName(entry.getName(), 775 "_ElemType")); 776 777 QName anonQName = new QName (entry.getQName().getNamespaceURI(), 781 SymbolTable.ANON_TOKEN + 782 entry.getQName().getLocalPart()); 783 TypeEntry anonType = symbolTable.getType(anonQName); 784 if (anonType != null) 785 { 786 anonType.setName(entry.getName()); 787 anonTypes.add(anonType); 788 } 789 } 790 else if (entry instanceof TypeEntry) 791 { 792 if (firstType) 796 { 797 firstType = false; 798 Iterator types = symbolTable.getTypeIndex().values().iterator(); 799 while (types.hasNext()) 800 { 801 TypeEntry type = (TypeEntry) 802 types.next(); 803 if (type != entry && type.getBaseType() == null && 804 sameJavaClass(entry.getName(), type.getName())) 805 { 806 v.add(type); 807 } 808 } 809 } 810 if (!anonTypes.contains(entry)) 813 { 814 entry.setName(mangleName(entry.getName(), "_Type")); 815 } 816 } 817 else if (entry instanceof PortTypeEntry) 818 { 819 entry.setName(mangleName(entry.getName(), "_Port")); 820 } 821 else if (entry instanceof ServiceEntry) 822 { 823 entry.setName(mangleName(entry.getName(), 824 "_Service")); 825 } 826 else if (entry instanceof BindingEntry) 830 { 831 BindingEntry bEntry = (BindingEntry)entry; 832 833 if (bEntry.hasLiteral()) 840 { 841 entry.setName(mangleName(entry.getName(), 842 "_Binding")); 843 } 844 } 845 } 846 } 847 } 848 } 849 } 851 854 private String mangleName(String name, String mangle) 855 { 856 int index = name.indexOf("["); 857 if (index >= 0) 858 { 859 String pre = name.substring(0, index); 860 String post = name.substring(index); 861 return pre + mangle + post; 862 } 863 else 864 return name + mangle; 865 } 866 867 870 private boolean sameJavaClass(String one, String two) 871 { 872 int index1 = one.indexOf("["); 873 int index2 = two.indexOf("["); 874 if (index1 > 0) 875 one = one.substring(0, index1); 876 if (index2 > 0) 877 two = two.substring(0, index2); 878 return one.equals(two); 879 } 880 881 886 protected void setAllReferencesToTrue() 887 { 888 Iterator it = symbolTable.getHashMap().values().iterator(); 889 while (it.hasNext()) 890 { 891 Vector v = (Vector )it.next(); 892 for (int i = 0; i < v.size(); ++i) 893 { 894 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 895 if (entry instanceof BindingEntry && 896 ((BindingEntry)entry).getBindingType() != 897 BindingEntry.TYPE_SOAP) 898 { 899 entry.setIsReferenced(false); 900 } 901 else 902 { 903 entry.setIsReferenced(true); 904 } 905 } 906 } 907 } 909 913 protected void ignoreNonSOAPBindings(SymbolTable symbolTable) 914 { 915 916 919 Vector unusedPortTypes = new Vector (); 920 Vector usedPortTypes = new Vector (); 921 922 Iterator it = symbolTable.getHashMap().values().iterator(); 923 while (it.hasNext()) 924 { 925 Vector v = (Vector )it.next(); 926 for (int i = 0; i < v.size(); ++i) 927 { 928 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 929 if (entry instanceof BindingEntry) 930 { 931 BindingEntry bEntry = (BindingEntry)entry; 932 Binding binding = bEntry.getBinding(); 933 PortType portType = binding.getPortType(); 934 PortTypeEntry ptEntry = 935 symbolTable.getPortTypeEntry(portType.getQName()); 936 937 if (bEntry.getBindingType() == BindingEntry.TYPE_SOAP) 938 { 939 usedPortTypes.add(ptEntry); 944 if (unusedPortTypes.contains(ptEntry)) 945 { 946 unusedPortTypes.remove(ptEntry); 947 } 948 } 949 else 950 { 951 bEntry.setIsReferenced(false); 952 953 if (!usedPortTypes.contains(ptEntry)) 956 { 957 unusedPortTypes.add(ptEntry); 958 } 959 } 960 } 961 } 962 } 963 964 for (int i = 0; i < unusedPortTypes.size(); ++i) 967 { 968 PortTypeEntry ptEntry = (PortTypeEntry)unusedPortTypes.get(i); 969 ptEntry.setIsReferenced(false); 970 } 971 } 973 protected void constructSignatures(SymbolTable symbolTable) 974 { 975 Iterator it = symbolTable.getHashMap().values().iterator(); 976 while (it.hasNext()) 977 { 978 Vector v = (Vector )it.next(); 979 for (int i = 0; i < v.size(); ++i) 980 { 981 SymTabEntry entry = (SymTabEntry)v.elementAt(i); 982 if (entry instanceof BindingEntry) 983 { 984 BindingEntry bEntry = (BindingEntry)entry; 985 Binding binding = bEntry.getBinding(); 986 PortTypeEntry ptEntry = 987 symbolTable.getPortTypeEntry(binding.getPortType().getQName()); 988 PortType portType = ptEntry.getPortType(); 989 Iterator operations = portType.getOperations().iterator(); 990 while (operations.hasNext()) 991 { 992 Operation operation = (Operation)operations.next(); 993 OperationType type = operation.getStyle(); 994 String name = operation.getName(); 995 Parameters parameters = bEntry.getParameters(operation); 996 if (type == OperationType.SOLICIT_RESPONSE) 997 { 998 parameters.signature = " // " + Messages.getMessage("invalidSolResp00", name); 999 System.err.println(Messages.getMessage("invalidSolResp00", name)); 1000 } 1001 else if (type == OperationType.NOTIFICATION) 1002 { 1003 parameters.signature = " // " + Messages.getMessage("invalidNotif00", name); 1004 System.err.println(Messages.getMessage("invalidNotif00", name)); 1005 } 1006 else 1007 { if (parameters != null) 1009 { 1010 parameters.signature = constructSignature(parameters, name); 1011 } 1012 } 1013 } 1014 } 1015 } 1016 } 1017 } 1019 1022 private String constructSignature(Parameters parms, String opName) 1023 { 1024 String name = Utils.xmlNameToJava(opName); 1025 1026 String ret = "void"; 1027 if (parms != null && parms.returnParam != null) 1028 { 1029 ret = Utils.getParameterTypeName(parms.returnParam); 1030 } 1031 String signature = " public " + ret + " " + name + "("; 1032 1033 boolean needComma = false; 1034 1035 for (int i = 0; parms != null && i < parms.list.size(); ++i) 1036 { 1037 Parameter p = (Parameter)parms.list.get(i); 1038 1039 if (needComma) 1040 { 1041 signature = signature + ", "; 1042 } 1043 else 1044 { 1045 needComma = true; 1046 } 1047 1048 String javifiedName = Utils.xmlNameToJava(p.getName()); 1049 if (p.getMode() == Parameter.IN) 1050 { 1051 signature = signature + Utils.getParameterTypeName(p) + " " + javifiedName; 1052 } 1053 else 1054 { 1055 signature = signature + Utils.holder(p.getMIMEInfo(), p.getType(), emitter) + " " 1056 + javifiedName; 1057 } 1058 } 1059 signature = signature + ") throws java.rmi.RemoteException"; 1060 if (parms != null && parms.faults != null) 1061 { 1062 1064 Iterator i = parms.faults.values().iterator(); 1065 while (i.hasNext()) 1066 { 1067 Fault fault = (Fault)i.next(); 1068 String exceptionName = 1069 Utils.getFullExceptionName(fault.getMessage(), symbolTable); 1070 if (exceptionName != null) 1071 { 1072 signature = signature + ", " + exceptionName; 1073 } 1074 } 1075 } 1076 return signature; 1077 } 1079 1083 protected void determineIfHoldersNeeded(SymbolTable symbolTable) 1084 { 1085 Iterator it = symbolTable.getHashMap().values().iterator(); 1086 while (it.hasNext()) 1087 { 1088 Vector v = (Vector )it.next(); 1089 for (int i = 0; i < v.size(); ++i) 1090 { 1091 if (v.get(i) instanceof BindingEntry) 1092 { 1093 BindingEntry bEntry = (BindingEntry)v.get(i); 1096 Iterator operations = 1099 bEntry.getParameters().values().iterator(); 1100 while (operations.hasNext()) 1101 { 1102 Parameters parms = (Parameters)operations.next(); 1103 for (int j = 0; j < parms.list.size(); ++j) 1104 { 1105 Parameter p = 1106 (Parameter)parms.list.get(j); 1107 1108 if (p.getMode() != Parameter.IN) 1111 { 1112 TypeEntry typeEntry = p.getType(); 1113 typeEntry.setDynamicVar(JavaTypeWriter.HOLDER_IS_NEEDED, 1114 new Boolean (true)); 1115 if (!typeEntry.isSimpleType() && typeEntry.getRefType() != null) 1118 { 1119 typeEntry.getRefType().setDynamicVar(JavaTypeWriter.HOLDER_IS_NEEDED, 1120 new Boolean (true)); 1121 } 1122 1123 QName anonQName = SchemaUtils. 1126 getElementAnonQName(p.getType().getNode()); 1127 if (anonQName != null) 1128 { 1129 TypeEntry anonType = 1130 symbolTable.getType(anonQName); 1131 if (anonType != null) 1132 { 1133 anonType.setDynamicVar(JavaTypeWriter.HOLDER_IS_NEEDED, 1134 new Boolean (true)); 1135 } 1136 } 1137 } 1138 } 1139 } 1140 } 1141 } 1142 } 1143 } 1145 1149 BaseTypeMapping btm = null; 1150 1151 public void setBaseTypeMapping(BaseTypeMapping btm) 1152 { 1153 this.btm = btm; 1154 } 1155 1156 public BaseTypeMapping getBaseTypeMapping() 1157 { 1158 if (btm == null) 1159 { 1160 btm = new BaseTypeMapping() 1161 { 1162 TypeMapping defaultTM = DefaultTypeMappingImpl.getSingleton(); 1163 1164 public String getBaseName(QName qNameIn) 1165 { 1166 javax.xml.namespace.QName qName = 1167 new javax.xml.namespace.QName (qNameIn.getNamespaceURI(), 1168 qNameIn.getLocalPart()); 1169 Class cls = defaultTM.getClassForQName(qName); 1170 if (cls == null) 1171 return null; 1172 else 1173 return JavaUtils.getTextClassName(cls.getName()); 1174 } 1175 }; 1176 } 1177 return btm; 1178 } 1179 1180} | Popular Tags |