1 package customfactory.client; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.Hashtable ; 6 import java.util.Iterator ; 7 import java.util.List ; 8 import java.util.Map ; 9 10 import javax.wsdl.Binding; 11 import javax.wsdl.Definition; 12 import javax.wsdl.Input; 13 import javax.wsdl.Message; 14 import javax.wsdl.Operation; 15 import javax.wsdl.OperationType; 16 import javax.wsdl.Output; 17 import javax.wsdl.Port; 18 import javax.wsdl.PortType; 19 import javax.wsdl.Service; 20 import javax.wsdl.WSDLException; 21 import javax.wsdl.extensions.ExtensibilityElement; 22 import javax.wsdl.extensions.ExtensionRegistry; 23 import javax.wsdl.extensions.UnknownExtensibilityElement; 24 import javax.xml.namespace.QName ; 25 26 import org.apache.wsif.WSIFConstants; 27 import org.apache.wsif.WSIFException; 28 import org.apache.wsif.WSIFMessage; 29 import org.apache.wsif.WSIFPort; 30 import org.apache.wsif.WSIFService; 31 import org.apache.wsif.base.WSIFClientProxy; 32 import org.apache.wsif.base.WSIFDefaultMessage; 33 import org.apache.wsif.compiler.schema.tools.Schema2Java; 34 import org.apache.wsif.compiler.util.TypeMapping; 35 import org.apache.wsif.compiler.util.Utils; 36 import org.apache.wsif.logging.MessageLogger; 37 import org.apache.wsif.logging.Trc; 38 import org.apache.wsif.providers.WSIFDynamicTypeMap; 39 import org.apache.wsif.spi.WSIFProvider; 40 import org.apache.wsif.util.WSIFPluggableProviders; 41 import org.apache.wsif.util.WSIFUtils; 42 import org.apache.wsif.wsdl.extensions.java.JavaBinding; 43 import org.w3c.dom.Element ; 44 45 import com.ibm.wsdl.util.xml.QNameUtils; 46 47 57 public class CustomServiceImpl implements WSIFService { 58 private static MyPrivateCompositeExtensionRegistry providersExtRegs = 59 new MyPrivateCompositeExtensionRegistry(); 60 private Definition def = null; 61 private Service service; 62 private PortType portType; 63 private Port[] myPortsArr; 64 private Map myPortsMap; 65 private WSIFDynamicTypeMap typeMap = new WSIFDynamicTypeMap(); 66 private boolean typeMapInitialised = false; 67 private String preferredPort = null; 68 private Map typeReg = null; 69 private Port chosenPort = null; 70 private WSIFMessage context; 71 72 84 CustomServiceImpl( 85 String wsdlLoc, 86 String serviceNS, 87 String serviceName, 88 String portTypeNS, 89 String portTypeName) 90 throws WSIFException { 91 Trc.entry(this, wsdlLoc, serviceNS, serviceName, portTypeNS, portTypeName); 92 93 Definition def = null; 95 try { 96 def = WSIFUtils.readWSDL(null, wsdlLoc); 97 checkWSDL(def); 98 } catch (WSDLException ex) { 99 Trc.exception(ex); 100 throw new WSIFException("could not load " + wsdlLoc, ex); 101 } 102 103 Service service = WSIFUtils.selectService(def, serviceNS, serviceName); 105 106 PortType portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName); 108 109 init(def, service, portType); 110 if (Trc.ON) 111 Trc.exit(deep()); 112 } 113 114 127 CustomServiceImpl( 128 String wsdlLoc, 129 ClassLoader cl, 130 String serviceNS, 131 String serviceName, 132 String portTypeNS, 133 String portTypeName) 134 throws WSIFException { 135 Trc.entry(this, wsdlLoc, cl, serviceNS, serviceName, portTypeNS, portTypeName); 136 137 Definition def = null; 139 try { 140 def = WSIFUtils.readWSDL(null, wsdlLoc, cl); 141 checkWSDL(def); 142 } catch (WSDLException ex) { 143 Trc.exception(ex); 144 throw new WSIFException("could not load " + wsdlLoc, ex); 145 } 146 147 Service service = WSIFUtils.selectService(def, serviceNS, serviceName); 149 150 PortType portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName); 152 153 init(def, service, portType); 154 if (Trc.ON) 155 Trc.exit(deep()); 156 } 157 158 164 CustomServiceImpl(Definition def) throws WSIFException { 165 this(def, null); 166 } 167 168 174 CustomServiceImpl(Definition def, Service service) throws WSIFException { 175 this(def, service, null); 176 } 177 178 184 CustomServiceImpl(Definition def, Service service, PortType portType) 185 throws WSIFException { 186 Trc.entry(this, def, service, portType); 187 188 init(def, service, portType); 189 if (Trc.ON) 190 Trc.exit(deep()); 191 } 192 193 199 CustomServiceImpl(Definition def, String serviceNS, String serviceName) 200 throws WSIFException { 201 Trc.entry(this, def, serviceNS, serviceName); 202 203 Service service = WSIFUtils.selectService(def, serviceNS, serviceName); 205 init(def, service, null); 206 if (Trc.ON) 207 Trc.exit(deep()); 208 } 209 210 216 CustomServiceImpl( 217 Definition def, 218 String serviceNS, 219 String serviceName, 220 String portTypeNS, 221 String portTypeName) 222 throws WSIFException { 223 Trc.entry(this, def, serviceNS, serviceName, portTypeNS, portTypeName); 224 225 checkWSDLForWSIF(def); 226 227 Service service = WSIFUtils.selectService(def, serviceNS, serviceName); 229 230 PortType portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName); 232 233 init(def, service, portType); 234 if (Trc.ON) 235 Trc.exit(deep()); 236 } 237 238 241 CustomServiceImpl(CustomServiceImpl wsi) 242 throws WSIFException { 243 Trc.entry(this, wsi); 244 copyInitializedService(wsi); 245 if (Trc.ON) 246 Trc.exit(deep()); 247 } 248 249 252 private void copyInitializedService(CustomServiceImpl svc) { 253 this.def = svc.def; 254 this.service = svc.service; 255 this.portType = svc.portType; 256 this.myPortsArr = new Port[svc.myPortsArr.length]; 257 System.arraycopy(svc.myPortsArr, 0, this.myPortsArr, 0, svc.myPortsArr.length); 258 this.myPortsMap = (Map ) ((Hashtable ) svc.myPortsMap).clone(); 259 this.typeMap = svc.typeMap.copy(); 260 } 261 262 266 public void setPreferredPort(String portName) throws WSIFException { 267 Trc.entry(this, portName); 268 269 if (portName == null) { 270 throw new WSIFException("Preferred port name cannot be null"); 271 } 272 PortType pt = getPortTypeFromPortName(portName); 273 if (pt.getQName().equals(this.portType.getQName())) { 274 this.preferredPort = portName; 275 } else { 276 throw new WSIFException( 277 "Preferred port " 278 + portName 279 + "is not available for the port type " 280 + this.portType.getQName()); 281 } 282 Trc.exit(); 283 } 284 285 291 private PortType getPortTypeFromPortName(String portName) 292 throws WSIFException { 293 if (portName == null) { 294 throw new WSIFException("Unable to find port type from a null port name"); 295 } 296 Port port = (Port) service.getPort(portName); 297 if (port == null) { 298 throw new WSIFException( 299 "Port '" + portName + "' cannot be found in the service"); 300 } 301 Binding binding = port.getBinding(); 302 if (binding == null) { 303 throw new WSIFException("No binding found for port '" + portName + "'"); 304 } 305 PortType pt = binding.getPortType(); 306 if (pt == null) { 307 throw new WSIFException( 308 "No port type found for binding '" + binding.getQName() + "'"); 309 } 310 checkPortTypeInformation(def, pt); 311 return pt; 312 } 313 314 318 public Iterator getAvailablePortNames() throws WSIFException { 319 Trc.entry(this); 320 Iterator it = null; 321 try { 322 it = this.myPortsMap.keySet().iterator(); 323 } catch (NullPointerException ne) { 324 Trc.exception(ne); 325 it = null; 326 } 327 Trc.exit(); 328 return it; 329 } 330 331 334 private WSIFPort createDynamicWSIFPort( 335 Definition def, 336 Service service, 337 Port port) 338 throws WSIFException { 339 checkWSDLForWSIF(def); 340 List bindingExList = port.getBinding().getExtensibilityElements(); 341 ExtensibilityElement bindingFirstEx = 342 (ExtensibilityElement) bindingExList.get(0); 343 String bindingNS = bindingFirstEx.getElementType().getNamespaceURI(); 344 WSIFProvider provider = WSIFPluggableProviders.getProvider(bindingNS); 345 if (provider != null) { 346 return provider.createDynamicWSIFPort(def, service, port, typeMap); 347 } else { 348 throw new WSIFException( 349 "could not find suitable provider for binding namespace '" + bindingNS + "'"); 350 } 351 } 352 353 public WSIFPort getPort() throws WSIFException { 354 Definition definition = getDefinition(); 359 Map services = definition.getServices(); 363 Service service = (Service) services.values().iterator().next(); 364 Iterator ports = service.getPorts().values().iterator(); 365 while (ports.hasNext()) { 366 Port port = (Port) ports.next(); 367 Binding binding = port.getBinding(); 369 if (binding instanceof JavaBinding) 370 return getPort(port.getName()); 371 } 372 Port firstPort = (Port) service.getPorts().values().iterator().next(); 374 return getPort(firstPort.getName()); 375 } 376 377 380 public WSIFPort getPort(String portName) throws WSIFException { 381 Trc.entry(this, portName); 382 Port port = null; 383 384 if (portName == null) { 385 if (myPortsArr.length > 0) { 387 port = myPortsArr[0]; 388 } 389 } else { 390 port = (Port) myPortsMap.get(portName); 391 } 392 if (port == null) { 393 if (portName == null) { 394 throw new WSIFException("Unable to find an available port"); 395 } else { 396 throw new WSIFException( 397 "Port '" 398 + portName 399 + "' is not available and " 400 + " no alternative can be found"); 401 } 402 } 403 404 portName = port.getName(); 405 WSIFPort portInstance = createDynamicWSIFPort(def, service, port); 406 if (portInstance == null) { 407 throw new WSIFException( 408 "Provider was unable to create WSIFPort for port " + portName); 409 } 410 chosenPort = port; 412 413 Trc.exit(portInstance); 414 return portInstance; 415 } 416 417 422 public void mapType(QName xmlType, Class javaType) throws WSIFException { 423 Trc.entry(this, xmlType, javaType); 424 typeMap.mapType(xmlType, javaType); 425 Trc.exit(); 426 } 427 428 435 private void mapType(QName xmlType, Class javaType, boolean force) 436 throws WSIFException { 437 Trc.entry(this, xmlType, javaType, new Boolean (force)); 438 typeMap.mapType(xmlType, javaType, force); 439 Trc.exit(); 440 } 441 442 447 public void mapPackage(String namespace, String packageName) 448 throws WSIFException { 449 Trc.entry(namespace, packageName); 450 typeMap.mapPackage(namespace, packageName); 451 Trc.exit(); 452 } 453 454 458 public static WSIFProvider getDynamicWSIFProvider(String namespaceURI) { 459 Trc.entry(null, namespaceURI); 460 WSIFProvider p = 461 WSIFPluggableProviders.getProvider( namespaceURI ); 462 Trc.exit( p ); 463 return p; 464 } 465 466 470 public static void setDynamicWSIFProvider( 471 String providerNamespaceURI, 472 WSIFProvider provider) { 473 Trc.entry(null, providerNamespaceURI, provider); 474 475 WSIFPluggableProviders.overrideDefaultProvider( 476 providerNamespaceURI, provider ); 477 478 Trc.exit(); 479 } 480 481 485 public static void setAutoLoadProviders(boolean b) { 486 Trc.entry(null, b); 487 WSIFPluggableProviders.setAutoLoadProviders( b ); 488 Trc.exit(); 489 } 490 491 495 public Object getStub(String portName, Class iface) throws WSIFException { 496 Trc.entry(this, portName, iface); 497 498 if (!typeMapInitialised) { 506 initialiseTypeMappings(); 507 typeMapInitialised = true; 508 } 509 510 WSIFPort wsifPort = getPort(portName); 513 514 PortType pt = getPortTypeFromPortName(portName); 516 517 WSIFClientProxy clientProxy = 522 WSIFClientProxy.newInstance( 523 iface, 524 def, 525 service.getQName().getNamespaceURI(), 526 service.getQName().getLocalPart(), 527 portType.getQName().getNamespaceURI(), 528 portType.getQName().getLocalPart(), 529 typeMap); 530 531 clientProxy.setPort(wsifPort); 532 Object proxy = clientProxy.getProxy(); 533 534 Trc.exit(); 536 return proxy; 537 } 538 539 542 public Object getStub(Class iface) throws WSIFException { 543 Trc.entry(this, iface); 544 545 if (!typeMapInitialised) { 553 initialiseTypeMappings(); 554 typeMapInitialised = true; 555 } 556 557 WSIFPort wsifPort = getPort(); 560 561 String portName = chosenPort.getName(); 563 PortType pt = getPortTypeFromPortName(portName); 564 565 WSIFClientProxy clientProxy = 570 WSIFClientProxy.newInstance( 571 iface, 572 def, 573 service.getQName().getNamespaceURI(), 574 service.getQName().getLocalPart(), 575 pt.getQName().getNamespaceURI(), 576 pt.getQName().getLocalPart(), 577 typeMap); 578 579 clientProxy.setPort(wsifPort); 580 Object proxy = clientProxy.getProxy(); 581 582 Trc.exit(); 584 return proxy; 585 } 586 587 591 public static void addExtensionRegistry(ExtensionRegistry reg) { 592 Trc.entry(null, reg); 593 providersExtRegs.addExtensionRegistry(reg); 594 Trc.exit(); 595 } 596 597 605 public static ExtensionRegistry getCompositeExtensionRegistry() { 606 Trc.entry(null); 607 Trc.exit(providersExtRegs); 608 return providersExtRegs; 609 } 610 611 private void init(Definition def, Service service, PortType portType) 612 throws WSIFException { 613 if (def == null) 614 throw new IllegalArgumentException ("WSDL definition can not be null"); 615 checkWSDLForWSIF(def); 616 617 if (service == null) { 618 Map services = WSIFUtils.getAllItems(def, "Service"); 619 620 service = (Service) WSIFUtils.getNamedItem(services, null, "Service"); 621 } 622 623 if (portType == null) { 624 Map ports = service.getPorts(); 626 if (ports.size() == 0) { 627 throw new WSIFException( 628 "WSDL must contain at least one port in " + service.getQName()); 629 } 630 631 for (Iterator i = ports.values().iterator(); i.hasNext();) { 632 Port port = (Port) i.next(); 633 if (portType == null) { 634 portType = port.getBinding().getPortType(); 635 } else { 636 PortType pt = port.getBinding().getPortType(); 637 if (!pt.getQName().equals(portType.getQName())) { 638 throw new WSIFException( 639 "when no port type was specified all ports " 640 + "must have the same port type in WSDL service " 641 + service.getQName()); 642 } 643 } 644 } 645 if (portType == null) { 646 throw new IllegalArgumentException ( 647 "WSDL more than one portType in service " + service); 648 649 } 650 } 651 this.def = def; 652 this.service = service; 653 this.portType = portType; 654 655 checkPortTypeInformation(def, portType); 659 660 662 Map ports = service.getPorts(); 663 if (ports.size() == 0) { 665 throw new WSIFException( 666 "WSDL must contain at least one port in " + service.getQName()); 667 } 668 669 myPortsMap = new Hashtable (); 670 for (Iterator i = ports.values().iterator(); i.hasNext();) { 671 Port port = (Port) i.next(); 672 673 Binding binding = port.getBinding(); 674 if (binding == null) 675 continue; 677 try { 678 List bindingExList = port.getBinding().getExtensibilityElements(); 680 ExtensibilityElement bindingFirstEx = 681 (ExtensibilityElement) bindingExList.get(0); 682 String bindingNS = bindingFirstEx.getElementType().getNamespaceURI(); 683 String addressNS = bindingNS; 684 try { 685 List addressExList = port.getExtensibilityElements(); 686 ExtensibilityElement addressFirstEx = 687 (ExtensibilityElement) addressExList.get(0); 688 addressNS = addressFirstEx.getElementType().getNamespaceURI(); 689 } catch (NullPointerException npe) { 690 Trc.ignoredException(npe); 691 } catch (ArrayIndexOutOfBoundsException aie) { 693 Trc.ignoredException(aie); 694 } 697 if (WSIFPluggableProviders.isProviderAvailable(bindingNS, addressNS) ) { 699 if (binding.getPortType().getQName().equals(portType.getQName())) { 701 String portName = port.getName(); 702 myPortsMap.put(portName, port); 703 } 704 } 705 } catch (NullPointerException e) { 706 Trc.ignoredException(e); 707 } catch (ArrayIndexOutOfBoundsException aie) { 711 Trc.ignoredException(aie); 712 } 714 } 715 int size = myPortsMap.size(); 716 myPortsArr = new Port[size]; 717 int count = 0; 718 for (Iterator i = myPortsMap.values().iterator(); i.hasNext();) { 719 Port port = (Port) i.next(); 721 myPortsArr[count++] = port; 722 } 723 724 typeMap.setAllTypes(getAllCustomTypes()); 727 } 728 729 732 private ArrayList getAllCustomTypes() { 733 ArrayList types = new ArrayList (); 734 Iterator typeMappingIterator = getDefaultTypeMappings(); 735 if (typeMappingIterator != null) { 736 while (typeMappingIterator.hasNext()) { 737 TypeMapping tm = (TypeMapping) typeMappingIterator.next(); 738 if (tm != null) { 739 String namespaceURI = tm.elementType.getNamespaceURI(); 740 if (!namespaceURI.equals(WSIFConstants.NS_URI_1999_SCHEMA_XSD) 741 && !namespaceURI.equals(WSIFConstants.NS_URI_2000_SCHEMA_XSD) 742 && !namespaceURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD)) { 743 QName element = tm.elementType; 744 if (element != null) { 745 types.add(element); 746 } 747 } 748 } 749 } 750 } 751 return types; 752 } 753 754 758 private Iterator getDefaultTypeMappings() { 759 if (typeReg != null) { 760 return typeReg.values().iterator(); 761 } 762 typeReg = new HashMap (); 763 List typesElList = Utils.getAllTypesElements(def); 764 if (typesElList.size() > 0) { 765 String schemaURI1999 = WSIFConstants.NS_URI_1999_SCHEMA_XSD; 766 Schema2Java s2j1999 = new Schema2Java(schemaURI1999); 767 QName qElemSchema1999 = new QName (schemaURI1999, "schema"); 768 String schemaURI2000 = WSIFConstants.NS_URI_2000_SCHEMA_XSD; 769 Schema2Java s2j2000 = new Schema2Java(schemaURI2000); 770 QName qElemSchema2000 = new QName (schemaURI2000, "schema"); 771 String schemaURI2001 = WSIFConstants.NS_URI_2001_SCHEMA_XSD; 772 Schema2Java s2j2001 = new Schema2Java(schemaURI2001); 773 QName qElemSchema2001 = new QName (schemaURI2001, "schema"); 774 775 Iterator typesElIterator = typesElList.iterator(); 776 while (typesElIterator.hasNext()) { 777 UnknownExtensibilityElement unknExEl = 778 (UnknownExtensibilityElement) typesElIterator.next(); 779 Element schemaEl = unknExEl.getElement(); 780 try { 781 if (QNameUtils.matches(qElemSchema1999, schemaEl) 782 || QNameUtils.matches(qElemSchema2000, schemaEl) 783 || QNameUtils.matches(qElemSchema2001, schemaEl)) { 784 if (QNameUtils.matches(qElemSchema1999, schemaEl)) 786 s2j1999.createJavaMapping(schemaEl, typeReg); 787 else if (QNameUtils.matches(qElemSchema2000, schemaEl)) 788 s2j2000.createJavaMapping(schemaEl, typeReg); 789 else 790 s2j2001.createJavaMapping(schemaEl, typeReg); 791 } 792 } catch (Exception e) { 793 Trc.ignoredException(e); 794 } 796 } 797 } 798 return typeReg.values().iterator(); 799 } 800 801 805 private void initialiseTypeMappings() throws WSIFException { 806 Iterator typeMappingIterator = getDefaultTypeMappings(); 807 if (typeMappingIterator != null) { 808 while (typeMappingIterator.hasNext()) { 809 TypeMapping tm = (TypeMapping) typeMappingIterator.next(); 810 811 if (tm.elementType != null && tm.elementType.getNamespaceURI() != null) { 812 String namespaceURI = tm.elementType.getNamespaceURI(); 813 if (namespaceURI != null 814 && !namespaceURI.equals(WSIFConstants.NS_URI_1999_SCHEMA_XSD) 815 && !namespaceURI.equals(WSIFConstants.NS_URI_2000_SCHEMA_XSD) 816 && !namespaceURI.equals(WSIFConstants.NS_URI_2001_SCHEMA_XSD) 817 && !namespaceURI.equals(WSIFConstants.NS_URI_SOAP_ENC) 818 && tm.javaType != null) { 819 String packageName = Utils.getPackageName(tm.javaType); 820 if (packageName != null && !packageName.equals("")) { 821 packageName += "."; 822 } 823 String className = packageName + Utils.getClassName(tm.javaType); 824 Class clazz = null; 825 826 try { 827 clazz = 828 Class.forName(className, true, Thread.currentThread().getContextClassLoader()); 829 } catch (ClassNotFoundException e) { 830 Trc.ignoredException(e); 832 } 833 if (clazz != null) { 835 mapType(tm.elementType, clazz, false); 836 } 837 } 838 } 839 } } 841 } 842 843 847 private void checkPortTypeInformation(Definition def, PortType portType) 848 throws WSIFException { 849 List operationList = portType.getOperations(); 850 851 for (Iterator i = operationList.iterator(); i.hasNext();) { 853 Operation op = (Operation) i.next(); 854 String name = op.getName(); 855 if (op.isUndefined()) { 856 throw new WSIFException("operation " + name + " is undefined!"); 857 } 858 OperationType opType = op.getStyle(); 859 if (opType == null) { 860 throw new WSIFException("operation " + name + " has no type!"); 861 } 862 if (opType.equals(OperationType.REQUEST_RESPONSE)) { 863 Input input = op.getInput(); 864 Output output = op.getOutput(); 865 if (input == null) { 866 throw new WSIFException("missing input message for operation " + name); 867 } 868 if (output == null) { 869 throw new WSIFException("missing output message for operation " + name); 870 } 871 } else if (opType.equals(OperationType.ONE_WAY)) { 872 Input input = op.getInput(); 873 if (input == null) { 874 throw new WSIFException("missing input message for operation " + name); 875 } 876 } else { 877 MessageLogger.log( 879 "WSIF.0004E", 880 opType, 881 portType.getQName().getLocalPart()); 882 883 throw new WSIFException( 885 "operation type " 886 + opType 887 + " is not supported in port instance for " 888 + portType.getQName()); 889 } 890 } 891 } 892 893 private void checkWSDLForWSIF(Definition def) throws WSIFException { 894 try { 895 checkWSDL(def); 896 } catch (WSDLException ex) { 897 Trc.exception(ex); 898 throw new WSIFException("invalid WSDL defintion " + def.getQName(), ex); 899 } 900 } 901 902 909 private void checkWSDL(Definition def) throws WSDLException { 910 for (Iterator i = def.getMessages().values().iterator(); i.hasNext();) { 911 Message v = (Message) i.next(); 912 if (v.isUndefined()) { 913 throw new WSDLException( 914 WSDLException.INVALID_WSDL, 915 "referencing undefined message " + v); 916 } 917 } 918 for (Iterator i = def.getPortTypes().values().iterator(); i.hasNext();) { 919 PortType v = (PortType) i.next(); 920 if (v.isUndefined()) { 921 throw new WSDLException( 922 WSDLException.INVALID_WSDL, 923 "referencing undefined portType " + v); 924 } 925 } 926 for (Iterator i = def.getBindings().values().iterator(); i.hasNext();) { 927 Binding v = (Binding) i.next(); 928 if (v.isUndefined()) { 929 throw new WSDLException( 930 WSDLException.INVALID_WSDL, 931 "referencing undefined binding " + v); 932 } 933 } 934 } 935 936 940 public Definition getDefinition() { 941 Trc.entry(this); 942 Trc.exit(def); 943 return def; 944 } 945 946 950 public WSIFMessage getContext() throws WSIFException { 951 Trc.entry(this); 952 WSIFMessage contextCopy; 953 if (this.context == null) { 954 contextCopy = new WSIFDefaultMessage(); 955 } else { 956 try { 957 contextCopy = (WSIFMessage) this.context.clone(); 958 } catch (CloneNotSupportedException e) { 959 throw new WSIFException( 960 "CloneNotSupportedException cloning context", e); 961 } 962 } 963 Trc.exit(contextCopy); 964 return contextCopy; 965 } 966 967 971 public void setContext(WSIFMessage context) { 972 Trc.entry(this, context); 973 if (context == null) { 974 throw new IllegalArgumentException ("context must not be null"); 975 } 976 this.context = context; 977 Trc.exit(); 978 } 979 980 public String deep() { 981 String buff = ""; 982 try { 983 buff = new String (this.toString()); 984 buff += "\nprovidersExtRegs:" 985 + (providersExtRegs == null ? "null" : providersExtRegs.toString()); 986 buff += "\ndef:" + Trc.brief(def); 987 buff += "\nservice:" + Trc.brief(service); 988 buff += "\nportType:" + Trc.brief(portType); 989 buff += "\nmyPortsArr:" + (myPortsArr == null ? "null" : myPortsArr.toString()); 990 buff += "\nmyPortsMap:" + Trc.brief(myPortsMap); 991 buff += "\ntypeMap:" + (typeMap == null ? "null" : typeMap.toString()); 992 buff += "\ntypeMapInitialised:" + typeMapInitialised; 993 buff += "\npreferredPort:" + (preferredPort == null ? "null" : preferredPort); 994 buff += "\nchosenPort:" + Trc.brief(chosenPort); 995 buff += "\ncontext:" + context; 996 } catch (Exception e) { 997 Trc.exceptionInTrace(e); 998 } 999 return buff; 1000 } 1001} 1002 1003 | Popular Tags |