1 19 20 package org.netbeans.modules.java.j2seproject.wsclient; 21 import java.io.File ; 22 import java.net.UnknownHostException ; 23 import org.netbeans.modules.java.j2seproject.J2SEProject; 24 import org.netbeans.modules.java.j2seproject.J2SEProjectType; 25 import org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties; 26 import org.netbeans.modules.websvc.api.client.ClientStubDescriptor; 27 import org.netbeans.modules.websvc.api.client.WebServicesClientConstants; 28 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 29 import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportImpl; 30 import java.io.IOException ; 31 import java.util.Arrays ; 32 import java.util.ArrayList ; 33 import java.util.HashSet ; 34 import java.util.List ; 35 import org.netbeans.api.project.Project; 36 import org.netbeans.api.project.ProjectManager; 37 import org.netbeans.api.project.ui.OpenProjects; 38 import org.netbeans.spi.project.support.ant.AntProjectHelper; 39 import org.netbeans.spi.project.support.ant.EditableProperties; 40 import org.netbeans.spi.project.support.ant.PropertyUtils; 41 import org.openide.DialogDisplayer; 42 import org.openide.NotifyDescriptor; 43 import org.openide.filesystems.FileObject; 44 import org.openide.filesystems.FileUtil; 45 import org.openide.util.NbBundle; 46 import org.w3c.dom.Document ; 47 import org.w3c.dom.Element ; 48 import org.w3c.dom.NodeList ; 49 import org.netbeans.spi.project.support.ant.ReferenceHelper; 50 51 52 57 public class J2SEProjectWebServicesClientSupport implements WebServicesClientSupportImpl{ 58 59 private J2SEProject project; 60 private AntProjectHelper helper; 61 private ReferenceHelper referenceHelper; 62 private String proxyHost,proxyPort; 63 64 public static final String WSDL_FOLDER = "wsdl"; 66 67 public J2SEProjectWebServicesClientSupport(J2SEProject project, AntProjectHelper helper, ReferenceHelper referenceHelper) { 68 this.project = project; 69 this.helper = helper; 70 this.referenceHelper = referenceHelper; 71 } 72 73 public AntProjectHelper getAntProjectHelper() { 74 return helper; 75 } 76 77 public ReferenceHelper getReferenceHelper(){ 78 return referenceHelper; 79 } 80 81 public void addServiceClient(String serviceName, String packageName, String sourceUrl, FileObject configFile, ClientStubDescriptor stubDescriptor) { 83 this.addServiceClient(serviceName, packageName, sourceUrl, configFile, stubDescriptor, null); 84 } 85 86 public void addServiceClient(String serviceName, String packageName, String sourceUrl, FileObject configFile, ClientStubDescriptor stubDescriptor, String [] wscompileFeatures) { 88 boolean needsSave = false; 94 boolean modifiedProjectProperties = false; 95 boolean modifiedPrivateProperties = false; 96 97 100 Element data = helper.getPrimaryConfigurationData(true); 101 Document doc = data.getOwnerDocument(); 102 NodeList nodes = data.getElementsByTagName(WebServicesClientConstants.WEB_SERVICE_CLIENTS); 103 Element clientElements = null; 104 105 if(nodes.getLength() == 0) { 106 clientElements = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENTS); 109 NodeList srcRoots = data.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots"); assert srcRoots.getLength() == 1 : "Invalid project.xml."; data.insertBefore(clientElements, srcRoots.item(0)); 112 } else { 113 clientElements = (Element ) nodes.item(0); 114 } 115 116 118 boolean serviceAlreadyAdded = false; 119 NodeList clientNameList = clientElements.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT_NAME); 120 for(int i = 0; i < clientNameList.getLength(); i++ ) { 121 Element clientNameElement = (Element ) clientNameList.item(i); 122 NodeList nl = clientNameElement.getChildNodes(); 123 if(nl.getLength() >= 1) { 124 org.w3c.dom.Node n = nl.item(0); 125 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 126 if(serviceName.equalsIgnoreCase(n.getNodeValue())) { 127 serviceAlreadyAdded = true; 128 129 } 133 } 134 } 135 } 136 137 139 if(!serviceAlreadyAdded) { 140 Element clientElement = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT); 141 clientElements.appendChild(clientElement); 142 Element clientElementName = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT_NAME); 143 clientElement.appendChild(clientElementName); 144 clientElementName.appendChild(doc.createTextNode(serviceName)); 145 Element clientElementStubType = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_STUB_TYPE); 146 clientElement.appendChild(clientElementStubType); 147 clientElementStubType.appendChild(doc.createTextNode(stubDescriptor.getName())); 148 Element clientElementSourceUrl = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.CLIENT_SOURCE_URL); 149 clientElement.appendChild(clientElementSourceUrl); 150 clientElementSourceUrl.appendChild(doc.createTextNode(sourceUrl)); 151 helper.putPrimaryConfigurationData(data, true); 152 needsSave = true; 153 } 154 155 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 156 EditableProperties privateProperties = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); 157 { 159 String featurePropertyName = "wscompile.client." + serviceName + ".features"; String defaultFeatures = "wsi, strict"; if(stubDescriptor instanceof JAXRPCClientStubDescriptor) { 162 JAXRPCClientStubDescriptor stubDesc = (JAXRPCClientStubDescriptor) stubDescriptor; 163 if (wscompileFeatures!=null) stubDesc.setDefaultFeatures(wscompileFeatures); 164 defaultFeatures = stubDesc.getDefaultFeaturesAsArgument(); 165 } else { 166 } 168 String oldFeatures = projectProperties.getProperty(featurePropertyName); 169 if(!defaultFeatures.equals(oldFeatures)) { 170 projectProperties.put(featurePropertyName, defaultFeatures); 171 modifiedProjectProperties = true; 172 } 173 } 174 175 { 177 String packagePropertyName = "wscompile.client." + serviceName + ".package"; String oldPackageName = projectProperties.getProperty(packagePropertyName); 179 if(!packageName.equals(oldPackageName)) { 180 projectProperties.put(packagePropertyName, packageName); 181 modifiedProjectProperties = true; 182 } 183 } 184 185 if (proxyHost!=null && proxyHost.length()>0) { 188 boolean modif = addJVMProxyOptions(projectProperties,proxyHost,proxyPort); 189 if (modif) modifiedProjectProperties = true; 190 String proxyProperty = "wscompile.client." + serviceName + ".proxy"; String oldProxyProperty = privateProperties.getProperty(proxyProperty); 192 if(!proxyProperty.equals(oldProxyProperty)) { 193 privateProperties.put(proxyProperty, proxyHost+":"+(proxyPort==null?"8080":proxyPort)); modifiedPrivateProperties = true; 195 } 196 } 197 198 if(modifiedProjectProperties) { 199 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, projectProperties); 200 needsSave = true; 201 } 202 if(modifiedPrivateProperties) { 203 helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, privateProperties); 204 needsSave = true; 205 } 206 207 if(updateWsCompileProperties(serviceName)) { 210 needsSave = true; 211 } 212 213 if(needsSave) { 216 try { 217 ProjectManager.getDefault().saveProject(project); 218 } catch(IOException ex) { 219 NotifyDescriptor desc = new NotifyDescriptor.Message( 220 NbBundle.getMessage(J2SEProjectWebServicesClientSupport.class,"MSG_ErrorSavingOnWSClientAdd", serviceName, ex.getMessage()), NotifyDescriptor.ERROR_MESSAGE); 222 DialogDisplayer.getDefault().notify(desc); 223 } 224 } 225 } 226 227 public void addInfrastructure(String implBeanClass, FileObject pkg) { 228 } 230 231 public FileObject getDeploymentDescriptor() { 232 return null; 233 } 234 235 private FileObject getFileObject(String propname) { 236 String prop = helper.getStandardPropertyEvaluator().getProperty(propname); 237 if (prop != null) { 238 return helper.resolveFileObject(prop); 239 } else { 240 return null; 241 } 242 } 243 244 private boolean updateWsCompileProperties(String serviceName) { 245 257 boolean globalPropertiesChanged = false; 258 259 EditableProperties globalProperties = PropertyUtils.getGlobalProperties(); 260 if(globalProperties.getProperty(WebServicesClientConstants.WSCOMPILE_TOOLS_CLASSPATH) == null) { 261 globalProperties.setProperty(WebServicesClientConstants.WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); 263 try { 264 PropertyUtils.putGlobalProperties(globalProperties); 265 } catch(IOException ex) { 266 NotifyDescriptor desc = new NotifyDescriptor.Message( 267 NbBundle.getMessage(J2SEProjectWebServicesClientSupport.class,"MSG_ErrorSavingGlobalProperties", serviceName, ex.getMessage()), NotifyDescriptor.ERROR_MESSAGE); 269 DialogDisplayer.getDefault().notify(desc); 270 } 271 272 globalPropertiesChanged = true; 273 } 274 275 276 boolean projectPropertiesChanged = false; 277 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 278 279 { HashSet wscJars = new HashSet (); 281 boolean newWscJars = false; 282 String wscClientClasspath = projectProperties.getProperty(WebServicesClientConstants.WSCOMPILE_CLASSPATH); 283 if (wscClientClasspath == null) { 284 wscClientClasspath = "${" + WebServicesClientConstants.WSCOMPILE_TOOLS_CLASSPATH + "}" + ":${javac.classpath}"; 285 projectProperties.put(WebServicesClientConstants.WSCOMPILE_CLASSPATH, wscClientClasspath); 286 projectPropertiesChanged = true; 287 } 288 289 296 } 308 309 if(projectProperties.getProperty(WebServicesClientConstants.WSCOMPILE_TOOLS_CLASSPATH) == null) { 311 projectProperties.setProperty(WebServicesClientConstants.WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); projectPropertiesChanged = true; 313 } 314 315 if(projectPropertiesChanged) { 316 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, projectProperties); 317 } 318 319 return globalPropertiesChanged || projectPropertiesChanged; 320 } 321 322 public void removeServiceClient(String serviceName) { 323 boolean needsSave = false; 327 boolean needsSave1 = false; 328 329 331 String featureProperty = "wscompile.client." + serviceName + ".features"; String packageProperty = "wscompile.client." + serviceName + ".package"; String proxyProperty = "wscompile.client." + serviceName + ".proxy"; 335 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 336 EditableProperties ep1 = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); 337 338 if(ep.getProperty(featureProperty) != null) { 339 ep.remove(featureProperty); 340 needsSave = true; 341 } 342 343 if(ep.getProperty(packageProperty) != null) { 344 ep.remove(packageProperty); 345 needsSave = true; 346 } 347 348 if(ep1.getProperty(proxyProperty) != null) { 349 ep1.remove(proxyProperty); 350 needsSave1 = true; 351 } 352 353 if(needsSave) { 354 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 355 } 356 357 if(needsSave1) { 358 helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep1); 359 } 360 361 363 Element data = helper.getPrimaryConfigurationData(true); 364 Document doc = data.getOwnerDocument(); 365 NodeList nodes = data.getElementsByTagName(WebServicesClientConstants.WEB_SERVICE_CLIENTS); 366 Element clientElements = null; 367 368 371 if(nodes.getLength() >= 1) { 372 clientElements = (Element ) nodes.item(0); 373 NodeList clientNameList = clientElements.getElementsByTagNameNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT_NAME); 374 for(int i = 0; i < clientNameList.getLength(); i++ ) { 375 Element clientNameElement = (Element ) clientNameList.item(i); 376 NodeList nl = clientNameElement.getChildNodes(); 377 if(nl.getLength() == 1) { 378 org.w3c.dom.Node n = nl.item(0); 379 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 380 if(serviceName.equalsIgnoreCase(n.getNodeValue())) { 381 org.w3c.dom.Node serviceNode = clientNameElement.getParentNode(); 383 clientElements.removeChild(serviceNode); 384 helper.putPrimaryConfigurationData(data, true); 385 needsSave = true; 386 } 387 } 388 } 389 } 390 } 391 392 if(needsSave || needsSave1) { 395 try { 396 ProjectManager.getDefault().saveProject(project); 397 } catch(IOException ex) { 398 NotifyDescriptor desc = new NotifyDescriptor.Message( 399 NbBundle.getMessage(J2SEProjectWebServicesClientSupport.class,"MSG_ErrorSavingOnWSClientRemove", serviceName, ex.getMessage()), NotifyDescriptor.ERROR_MESSAGE); 401 DialogDisplayer.getDefault().notify(desc); 402 } 403 } 404 } 405 406 public FileObject getWsdlFolder(boolean create) throws IOException { 407 408 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 409 String metaInfStr = helper.getStandardPropertyEvaluator().getProperty("meta.inf.dir"); 410 String wsdlFolderStr = metaInfStr + "/" + WSDL_FOLDER; FileObject wsdlFolder = project.getProjectDirectory().getFileObject(wsdlFolderStr); 412 if (wsdlFolder == null && create) { 413 wsdlFolder = FileUtil.createFolder(project.getProjectDirectory(), wsdlFolderStr); 414 } 415 416 return wsdlFolder; 417 } 418 419 public List getStubDescriptors() { 420 ArrayList stubs = new ArrayList (2); 421 stubs.add(jaxrpcClientStub); 422 return stubs; 423 } 424 425 private boolean isProjectOpened() { 426 Project[] projects = OpenProjects.getDefault().getOpenProjects(); 427 for (int i = 0; i < projects.length; i++) { 428 if (projects[i].equals(project)) 429 return true; 430 } 431 return false; 432 } 433 434 442 private static final String [] WSCOMPILE_CLIENT_FEATURES = { 443 "datahandleronly", "explicitcontext", 447 "jaxbenumtype", 449 "nodatabinding", "noencodedtypes", 451 "nomultirefs", 452 "norpcstructures", "novalidation", "resolveidref", 455 "searchschema", "serializeinterfaces", 457 "strict", "wsi", "unwrap", "donotoverride", "donotunwrap", }; 464 465 private static final List allClientFeatures = Arrays.asList(WSCOMPILE_CLIENT_FEATURES); 466 467 private static final String [] WSCOMPILE_KEY_CLIENT_FEATURES = { 468 "wsi", 469 "strict", 470 "norpcstructures", 471 "unwrap", 472 "donotunwrap", 473 "donotoverride", 474 "datahandleronly", 475 "nodatabinding", 476 "novalidation", 477 "searchschema", 478 }; 479 480 private static final List importantClientFeatures = Arrays.asList(WSCOMPILE_KEY_CLIENT_FEATURES); 481 482 public List getServiceClients() { 483 List serviceNames = new ArrayList (); 484 485 Element data = helper.getPrimaryConfigurationData(true); 486 NodeList nodes = data.getElementsByTagName(WebServicesClientConstants.WEB_SERVICE_CLIENTS); 487 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 488 489 if(nodes.getLength() != 0) { 490 Element clientElements = (Element ) nodes.item(0); 491 NodeList clientNameList = clientElements.getElementsByTagNameNS( 492 J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT_NAME); 493 for(int i = 0; i < clientNameList.getLength(); i++ ) { 494 Element clientNameElement = (Element ) clientNameList.item(i); 495 NodeList nl = clientNameElement.getChildNodes(); 496 if(nl.getLength() == 1) { 497 org.w3c.dom.Node n = nl.item(0); 498 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 499 String serviceName = n.getNodeValue(); 500 String currentFeatures = projectProperties.getProperty("wscompile.client." + serviceName + ".features"); if(currentFeatures == null) { 502 currentFeatures = "wsi, strict"; 510 } 511 ClientStubDescriptor stubType = getClientStubDescriptor(clientNameElement.getParentNode()); 512 boolean propVerbose = "true".equalsIgnoreCase( projectProperties.getProperty("wscompile.client." + serviceName + ".verbose")); boolean propDebug = "true".equalsIgnoreCase( projectProperties.getProperty("wscompile.client." + serviceName + ".debug")); boolean propPrintStackTrace = "true".equalsIgnoreCase( projectProperties.getProperty("wscompile.client." + serviceName + ".xPrintStackTrace")); boolean propExtensible = "true".equalsIgnoreCase( projectProperties.getProperty("wscompile.client." + serviceName + ".xSerializable")); boolean propOptimize = "true".equalsIgnoreCase( projectProperties.getProperty("wscompile.client." + serviceName + ".optimize")); boolean[] options = new boolean[] { propVerbose,propDebug,propPrintStackTrace,propExtensible,propOptimize 524 }; 525 WsCompileClientEditorSupport.ServiceSettings settings = new WsCompileClientEditorSupport.ServiceSettings( 526 serviceName, stubType, options, currentFeatures, allClientFeatures, importantClientFeatures); 527 serviceNames.add(settings); 528 } else { 529 } 531 } else { 532 } 534 } 535 } 536 537 return serviceNames; 538 } 539 540 private ClientStubDescriptor getClientStubDescriptor(org.w3c.dom.Node parentNode) { 541 ClientStubDescriptor result = null; 542 543 if(parentNode instanceof Element ) { 544 Element parentElement = (Element ) parentNode; 545 NodeList clientNameList = parentElement.getElementsByTagNameNS( 546 J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_STUB_TYPE); 547 if(clientNameList.getLength() == 1) { 548 Element clientStubElement = (Element ) clientNameList.item(0); 549 NodeList nl = clientStubElement.getChildNodes(); 550 if(nl.getLength() == 1) { 551 org.w3c.dom.Node n = nl.item(0); 552 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 553 String stubName = n.getNodeValue(); 554 if (ClientStubDescriptor.JAXRPC_CLIENT_STUB.equals(stubName)) { 555 result = jaxrpcClientStub; 556 } 557 } 558 } 559 } 560 } 561 562 return result; 563 } 564 565 public String getWsdlSource(String serviceName) { 566 Element data = helper.getPrimaryConfigurationData(true); 567 Document doc = data.getOwnerDocument(); 568 String wsdlSource = null; 569 570 Element clientElement = getWebServiceClientNode(data, serviceName); 571 if(clientElement != null) { 572 NodeList fromWsdlList = clientElement.getElementsByTagNameNS( 573 J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.CLIENT_SOURCE_URL); 574 if(fromWsdlList.getLength() == 1) { 575 Element fromWsdlElement = (Element ) fromWsdlList.item(0); 576 NodeList nl = fromWsdlElement.getChildNodes(); 577 if(nl.getLength() == 1) { 578 org.w3c.dom.Node n = nl.item(0); 579 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 580 wsdlSource = n.getNodeValue(); 581 } 582 } 583 } 584 } 585 586 return wsdlSource; 587 } 588 589 public void setWsdlSource(String serviceName, String wsdlSource) { 590 Element data = helper.getPrimaryConfigurationData(true); 591 Document doc = data.getOwnerDocument(); 592 boolean needsSave = false; 593 594 Element clientElement = getWebServiceClientNode(data, serviceName); 595 if(clientElement != null) { 596 NodeList fromWsdlList = clientElement.getElementsByTagNameNS( 597 J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.CLIENT_SOURCE_URL); 598 if(fromWsdlList.getLength() > 0) { 599 Element fromWsdlElement = (Element ) fromWsdlList.item(0); 600 NodeList nl = fromWsdlElement.getChildNodes(); 601 if(nl.getLength() > 0) { 602 org.w3c.dom.Node n = nl.item(0); 603 n.setNodeValue(wsdlSource); 604 } else { 605 fromWsdlElement.appendChild(doc.createTextNode(wsdlSource)); 606 } 607 } else { 608 Element clientElementSourceUrl = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.CLIENT_SOURCE_URL); 609 clientElement.appendChild(clientElementSourceUrl); 610 clientElementSourceUrl.appendChild(doc.createTextNode(wsdlSource)); 611 } 612 613 needsSave = true; 614 } 615 616 if(needsSave) { 618 try { 619 ProjectManager.getDefault().saveProject(project); 620 } catch(IOException ex) { 621 NotifyDescriptor desc = new NotifyDescriptor.Message( 622 NbBundle.getMessage(J2SEProjectWebServicesClientSupport.class,"MSG_ErrorSavingOnWSClientAdd", serviceName, ex.getMessage()), NotifyDescriptor.ERROR_MESSAGE); 624 DialogDisplayer.getDefault().notify(desc); 625 } 626 } 627 } 628 629 private Element getWebServiceClientNode(Element data, String serviceName) { 630 Element clientElement = null; 631 NodeList nodes = data.getElementsByTagName(WebServicesClientConstants.WEB_SERVICE_CLIENTS); 632 633 if(nodes.getLength() != 0) { 634 Element clientElements = (Element ) nodes.item(0); 635 NodeList clientNameList = clientElements.getElementsByTagNameNS( 636 J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENT_NAME); 637 for(int i = 0; i < clientNameList.getLength(); i++ ) { 638 Element clientNameElement = (Element ) clientNameList.item(i); 639 NodeList nl = clientNameElement.getChildNodes(); 640 if(nl.getLength() == 1) { 641 org.w3c.dom.Node n = nl.item(0); 642 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 643 String name = n.getNodeValue(); 644 if(serviceName.equals(name)) { 645 org.w3c.dom.Node node = clientNameElement.getParentNode(); 646 clientElement = (node instanceof Element ) ? (Element ) node : null; 647 break; 648 } 649 } else { 650 } 652 } 653 } 654 } 655 656 return clientElement; 657 } 658 659 private static final JAXRPCClientStubDescriptor jaxrpcClientStub = new JAXRPCClientStubDescriptor( 660 ClientStubDescriptor.JAXRPC_CLIENT_STUB, 661 NbBundle.getMessage(J2SEProjectWebServicesClientSupport.class,"LBL_JAXRPCStaticClientStub"), 662 new String [] { "wsi", "strict" }); 663 664 public void addServiceClientReference(String serviceName, String fqServiceName, String relativeWsdlPath, String relativeMappingPath, String [] portSEIInfo) { 665 } 667 668 670 private static class JAXRPCClientStubDescriptor extends ClientStubDescriptor { 671 672 private String [] defaultFeatures; 673 674 public JAXRPCClientStubDescriptor(String name, String displayName, String [] defaultFeatures) { 675 super(name, displayName); 676 677 this.defaultFeatures = defaultFeatures; 678 } 679 680 public String [] getDefaultFeatures() { 681 return defaultFeatures; 682 } 683 684 public String getDefaultFeaturesAsArgument() { 685 StringBuffer buf = new StringBuffer (defaultFeatures.length*32); 686 for(int i = 0; i < defaultFeatures.length; i++) { 687 if(i > 0) { 688 buf.append(","); 689 } 690 691 buf.append(defaultFeatures[i]); 692 } 693 return buf.toString(); 694 } 695 696 void setDefaultFeatures(String [] defaultFeatures) { 697 this.defaultFeatures=defaultFeatures; 698 } 699 } 700 701 public void setProxyJVMOptions(String proxyHost, String proxyPort) { 702 this.proxyHost=proxyHost; 703 this.proxyPort=proxyPort; 704 } 705 706 private static final String PROXY_HOST_OPTION="-Dhttp.proxyHost"; private static final String PROXY_PORT_OPTION="-Dhttp.proxyPort"; private static final String NON_PROXY_HOSTS_OPTION="-Dhttp.nonProxyHosts"; 710 private boolean addJVMProxyOptions(EditableProperties prop, String proxyHost, String proxyPort) { 711 String jvmOptions = prop.getProperty(J2SEProjectProperties.RUN_JVM_ARGS); 712 boolean modif=false; 713 String localHosts = "localhost"; try { 715 localHosts = java.net.InetAddress.getLocalHost().getCanonicalHostName(); 716 } catch (java.net.UnknownHostException ex) {} 717 if (!"localhost".equals(localHosts)) localHosts="\""+localHosts+"|localhost\""; if (jvmOptions==null || jvmOptions.length()==0) { 719 jvmOptions = PROXY_HOST_OPTION+"="+proxyHost+ " "+PROXY_PORT_OPTION+"="+proxyPort+ " "+NON_PROXY_HOSTS_OPTION+"="+localHosts; modif=true; 723 } else { 724 if (jvmOptions.indexOf(PROXY_HOST_OPTION)<0) { 725 jvmOptions+=" "+PROXY_HOST_OPTION+"="+proxyHost; modif=true; 727 } 728 if (jvmOptions.indexOf(PROXY_PORT_OPTION)<0) { 729 jvmOptions+=" "+PROXY_PORT_OPTION+"="+proxyPort; modif=true; 731 } 732 if (jvmOptions.indexOf(NON_PROXY_HOSTS_OPTION)<0) { 733 jvmOptions+=" "+NON_PROXY_HOSTS_OPTION+"="+localHosts; modif=true; 735 } 736 } 737 if (modif) prop.setProperty(J2SEProjectProperties.RUN_JVM_ARGS,jvmOptions); 738 return modif; 739 } 740 741 public String getServiceRefName(String serviceName) { 742 return null; 744 } 745 746 } 747 | Popular Tags |