1 19 20 package org.netbeans.modules.j2ee.ejbjarproject; 21 22 import java.util.ArrayList ; 23 import java.util.Arrays ; 24 import java.util.HashSet ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.io.IOException ; 28 import org.netbeans.api.java.classpath.ClassPath; 29 import org.netbeans.modules.j2ee.metadata.ClassPathSupport; 30 import org.netbeans.modules.websvc.api.client.WebServicesClientConstants; 31 import org.w3c.dom.Document ; 32 import org.w3c.dom.Element ; 33 import org.w3c.dom.Node ; 34 import org.w3c.dom.NodeList ; 35 import org.netbeans.spi.project.support.ant.AntProjectHelper; 36 import org.netbeans.modules.websvc.spi.webservices.WebServicesSupportImpl; 37 import org.netbeans.spi.project.support.ant.EditableProperties; 38 import org.netbeans.spi.project.support.ant.PropertyUtils; 39 import org.netbeans.modules.j2ee.dd.api.ejb.DDProvider; 40 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 41 import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans; 42 import org.netbeans.modules.j2ee.dd.api.ejb.Session; 43 import org.netbeans.api.project.Project; 44 import org.netbeans.api.project.ProjectManager; 45 import org.netbeans.api.project.ProjectUtils; 46 import org.netbeans.api.project.SourceGroup; 47 import org.netbeans.api.project.Sources; 48 import org.openide.ErrorManager; 49 import org.openide.DialogDisplayer; 50 import org.openide.NotifyDescriptor; 51 import org.openide.filesystems.FileObject; 52 import org.openide.filesystems.FileUtil; 53 import org.openide.util.NbBundle; 54 import org.netbeans.modules.j2ee.dd.api.webservices.ServiceImplBean; 55 import org.netbeans.api.java.project.JavaProjectConstants; 56 import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants; 57 import org.netbeans.modules.websvc.api.webservices.WsCompileEditorSupport; 58 import org.netbeans.modules.websvc.api.webservices.StubDescriptor; 59 import org.netbeans.spi.project.support.ant.ReferenceHelper; 60 import static org.netbeans.modules.websvc.spi.webservices.WebServicesConstants.*; 61 import org.netbeans.modules.j2ee.ejbjarproject.classpath.ClassPathProviderImpl; 62 63 68 public class EjbJarWebServicesSupport implements WebServicesSupportImpl{ 69 70 private EjbJarProject project; 71 private AntProjectHelper helper; 72 private ReferenceHelper referenceHelper; 73 private ClassPath projectSourcesClassPath; 74 75 76 public EjbJarWebServicesSupport(EjbJarProject project, AntProjectHelper helper, ReferenceHelper referenceHelper) { 77 this.project = project; 78 this.helper = helper; 79 this.referenceHelper = referenceHelper; 80 } 81 82 public String generateImplementationBean(String wsName, FileObject pkg, Project project, String delegateData)throws java.io.IOException { 84 return null; 88 } 89 90 public void addServiceImpl(String serviceName, FileObject configFile, boolean fromWSDL) { 91 this.addServiceImpl(serviceName, configFile, fromWSDL,null); 92 } 93 94 public void addServiceImpl(String serviceName, FileObject configFile, boolean fromWSDL, String [] wscompileFeatures) { 95 96 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 98 String packageName = getPackageName(configFile); 99 ep.put(serviceName + CONFIG_PROP_SUFFIX, packageName + 100 (packageName.equals("") ? "" : "/") + configFile.getNameExt()); ep.put(serviceName + MAPPING_PROP_SUFFIX, serviceName + MAPPING_FILE_SUFFIX); String featurePropertyName = "wscompile.service." + serviceName + ".features"; JAXRPCStubDescriptor stubDesc = null; 105 if (fromWSDL) { 106 if (wscompileFeatures!=null) 107 stubDesc = new JAXRPCStubDescriptor(StubDescriptor.WSDL_SERVICE_STUB, 108 NbBundle.getMessage(EjbJarWebServicesSupport.class,"LBL_WSDLServiceStub"), 109 wscompileFeatures); 110 else stubDesc = wsdlServiceStub; 111 } else { 112 stubDesc = seiServiceStub; 113 } 114 String defaultFeatures = stubDesc.getDefaultFeaturesAsArgument(); 115 ep.put(featurePropertyName, defaultFeatures); 116 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 117 118 Element data = helper.getPrimaryConfigurationData(true); 120 Document doc = data.getOwnerDocument(); 121 NodeList nodes = data.getElementsByTagName(WEB_SERVICES); Element webservices = null; 123 if(nodes.getLength() == 0){ 124 webservices = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICES); NodeList insertBefore = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesClientConstants.WEB_SERVICE_CLIENTS); 126 if (insertBefore.getLength() <= 0) { 127 insertBefore = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots"); assert insertBefore.getLength() == 1 : "Invalid project.xml file."; } 130 data.insertBefore(webservices, insertBefore.item(0)); 131 } 132 else{ 133 webservices = (Element )nodes.item(0); 134 } 135 Element webservice = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE); webservices.appendChild(webservice); 137 Element webserviceName = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE_NAME); webservice.appendChild(webserviceName); 139 webserviceName.appendChild(doc.createTextNode(serviceName)); 140 if(fromWSDL) { 141 Element fromWSDLElem = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "from-wsdl"); 142 webservice.appendChild(fromWSDLElem); 143 } 144 helper.putPrimaryConfigurationData(data, true); 145 146 updateWsCompileProperties(serviceName); 149 150 try { 151 ProjectManager.getDefault().saveProject(project); 152 }catch(java.io.IOException ioe){ 153 throw new RuntimeException (ioe.getMessage()); 154 } 155 } 156 157 public void addServiceEntriesToDD(String serviceName, String serviceEndpointInterface, String servantClassName) { 158 DDProvider provider = DDProvider.getDefault(); 160 org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbJarModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJars(project)[0]; 161 org.netbeans.modules.j2ee.dd.api.ejb.EjbJar ejbJar = null; 162 try { 163 ejbJar = provider.getMergedDDRoot(ejbJarModule.getMetadataUnit()); 164 } 165 catch(java.io.IOException e) { 166 throw new RuntimeException (e.getMessage()); 168 } 169 170 if (ejbJar == null) { 171 ErrorManager.getDefault().log(ErrorManager.USER, 172 NbBundle.getMessage(EjbJarWebServicesSupport.class, "MSG_MissingMetadata")); 173 return; 174 } 175 176 EjbJarProvider pwm = (EjbJarProvider) project.getLookup().lookup(EjbJarProvider.class); 177 pwm.getConfigSupport().ensureConfigurationReady(); 178 EnterpriseBeans beans = ejbJar.getEnterpriseBeans(); 179 Session s = null; 180 if(beans == null) { 181 beans = ejbJar.newEnterpriseBeans(); 182 ejbJar.setEnterpriseBeans(beans); 183 } 184 s = beans.newSession(); 185 s.setEjbName(serviceName); 186 s.setDisplayName(serviceName + "SB"); s.setEjbClass(servantClassName); 188 try { 189 s.setServiceEndpoint(serviceEndpointInterface); 190 } 191 catch(org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException e) { 192 throw new RuntimeException (e.getMessage()); 194 } 195 s.setSessionType("Stateless"); s.setTransactionType("Container"); beans.addSession(s); 198 try { 199 ejbJar.write(ejbJarModule.getDeploymentDescriptor()); 201 } 202 catch(java.io.IOException e) { 203 throw new RuntimeException (e.getMessage()); 205 } 206 } 207 208 public void addServiceImplLinkEntry(ServiceImplBean serviceImplBean, String wsName) { 209 serviceImplBean.setEjbLink(wsName); 210 } 211 212 215 public FileObject getWebservicesDD() { 216 FileObject metaInfFo = getMetaInf(); 217 if (metaInfFo==null) { 218 return null; 219 } 220 return getMetaInf().getFileObject(WEBSERVICES_DD, "xml"); 221 } 222 223 226 public FileObject getWsDDFolder() { 227 return getMetaInf(); 228 } 229 230 234 public String getArchiveDDFolderName() { 235 return "META-INF"; } 237 238 242 public String getImplementationBean(String linkName) { 243 EjbJar ejbJar = getEjbJar(); 244 EnterpriseBeans beans = ejbJar.getEnterpriseBeans(); 245 Session[] sessionBeans = beans.getSession(); 246 for(int i = 0; i < sessionBeans.length; i++) { 247 Session sessionBean = sessionBeans[i]; 248 if(sessionBean.getEjbName().equals(linkName)) { 249 return sessionBean.getEjbClass(); 250 } 251 252 } 253 return null; 254 } 255 256 public boolean isFromWSDL(String serviceName) { 257 Element data = helper.getPrimaryConfigurationData(true); 258 NodeList nodes = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 259 WEB_SERVICES); Element webservices = null; 261 Element wsNameNode = null; 262 if(nodes.getLength() == 1){ 263 webservices = (Element )nodes.item(0); 264 NodeList wsNodes = webservices.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 265 WEB_SERVICE); for(int j = 0; j < wsNodes.getLength(); j++) { 267 Element wsNode = (Element )wsNodes.item(j); 268 NodeList wsNameNodes = wsNode.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 269 WEB_SERVICE_NAME); if(wsNameNodes.getLength() == 1) { 271 wsNameNode = (Element )wsNameNodes.item(0); 272 NodeList nl = wsNameNode.getChildNodes(); 273 if(nl.getLength() == 1) { 274 Node n = nl.item(0); 275 if(n.getNodeType() == Node.TEXT_NODE) { 276 if(serviceName.equals(n.getNodeValue())) { 277 NodeList fromWSDLNodes = wsNode.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 278 WebServicesConstants.WEB_SERVICE_FROM_WSDL); if(fromWSDLNodes.getLength() == 1) { 280 return true; 281 } 282 } 283 } 284 } 285 } 286 } 287 } 288 return false; 289 } 290 291 public void removeProjectEntries(String serviceName) { 292 boolean needsSave = false; 293 294 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 297 String configProperty = serviceName + CONFIG_PROP_SUFFIX; 298 String mappingProperty = serviceName + MAPPING_PROP_SUFFIX; 299 if(ep.getProperty(configProperty) != null) { 300 ep.remove(configProperty); 301 needsSave = true; 302 } 303 if(ep.getProperty(mappingProperty) != null) { 304 ep.remove(mappingProperty); 305 needsSave = true; 306 } 307 String featureProperty = "wscompile.service." + serviceName + ".features"; if(ep.getProperty(featureProperty) != null) { 309 ep.remove(featureProperty); 310 needsSave = true; 311 } 312 if(needsSave){ 313 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 314 } 315 Element data = helper.getPrimaryConfigurationData(true); 317 NodeList nodes = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 318 WEB_SERVICES); Element webservices = null; 320 Element wsNameNode = null; 321 if(nodes.getLength() == 1){ 322 webservices = (Element )nodes.item(0); 323 NodeList wsNodes = webservices.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 324 WEB_SERVICE); for(int j = 0; j < wsNodes.getLength(); j++) { 326 Element wsNode = (Element )wsNodes.item(j); 327 NodeList wsNameNodes = wsNode.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, 328 WEB_SERVICE_NAME); if(wsNameNodes.getLength() == 1) { 330 wsNameNode = (Element )wsNameNodes.item(0); 331 NodeList nl = wsNameNode.getChildNodes(); 332 if(nl.getLength() == 1) { 333 Node n = nl.item(0); 334 if(n.getNodeType() == Node.TEXT_NODE) { 335 if(serviceName.equals(n.getNodeValue())) { 336 webservices.removeChild(wsNode); 337 NodeList children = webservices.getChildNodes(); 339 if(children.getLength() == 0) { 340 data.removeChild(webservices); 341 } 342 needsSave = true; 343 break; 344 } 345 } 346 } 347 } 348 } 349 } 350 if(needsSave) { 351 helper.putPrimaryConfigurationData(data, true); 352 try { 353 ProjectManager.getDefault().saveProject(project); 354 } catch(java.io.IOException ex) { 355 String mes = NbBundle.getMessage(this.getClass(), "MSG_ErrorSavingOnWSRemove") + serviceName + "'\r\n" + ex.getMessage(); NotifyDescriptor desc = new NotifyDescriptor. 358 Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); 359 DialogDisplayer.getDefault().notify(desc); } 360 } 361 } 362 363 public void removeServiceEntry(String linkName) { 364 org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbJarModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJars(project)[0]; 366 EjbJar ejbJar = getEjbJar(); 367 EnterpriseBeans beans = ejbJar.getEnterpriseBeans(); 368 Session[] sessionBeans = beans.getSession(); 369 for(int i = 0; i < sessionBeans.length; i++) { 370 Session sessionBean = sessionBeans[i]; 371 if(sessionBean.getEjbName().equals(linkName)) { 372 EjbJarProvider pwm = (EjbJarProvider) project.getLookup().lookup(EjbJarProvider.class); 373 pwm.getConfigSupport().ensureConfigurationReady(); 374 beans.removeSession(sessionBean); 375 break; 376 } 377 } 378 try { 379 ejbJar.write(ejbJarModule.getDeploymentDescriptor()); 380 } 381 catch(java.io.IOException e) { 382 NotifyDescriptor ndd = 383 new NotifyDescriptor.Message(NbBundle.getMessage(this.getClass(), "MSG_Unable_WRITE_EJB_DD"), NotifyDescriptor.ERROR_MESSAGE); 385 DialogDisplayer.getDefault().notify(ndd); 386 } 387 } 388 389 public AntProjectHelper getAntProjectHelper() { 390 return helper; 391 } 392 393 public ReferenceHelper getReferenceHelper(){ 394 return referenceHelper; 395 } 396 397 405 private static final String [] WSCOMPILE_SEI_SERVICE_FEATURES = { 406 "documentliteral", "rpcliteral", "noencodedtypes", 414 "nomultirefs", 415 "serializeinterfaces", 420 "strict", "useonewayoperations", "donotoverride", }; 427 428 private static final List allSeiServiceFeatures = Arrays.asList(WSCOMPILE_SEI_SERVICE_FEATURES); 429 430 private static final String [] WSCOMPILE_KEY_SEI_SERVICE_FEATURES = { 431 "documentliteral", 432 "rpcliteral", 433 "strict", 434 "useonewayoperations", 435 "donotoverride" 436 }; 437 438 private static final List importantSeiServiceFeatures = Arrays.asList(WSCOMPILE_KEY_SEI_SERVICE_FEATURES); 439 440 private static final String [] WSCOMPILE_WSDL_SERVICE_FEATURES = { 441 "datahandleronly", "explicitcontext", "jaxbenumtype", "nodatabinding", "noencodedtypes", 449 "nomultirefs", 450 "norpcstructures", "novalidation", "resolveidref", "searchschema", "serializeinterfaces", 455 "strict", "wsi", "unwrap", "donotoverride", "donotunwrap", }; 462 463 private static final List allWsdlServiceFeatures = Arrays.asList(WSCOMPILE_WSDL_SERVICE_FEATURES); 464 465 private static final String [] WSCOMPILE_KEY_WSDL_SERVICE_FEATURES = { 466 "datahandleronly", 467 "explicitcontext", 468 "nodatabinding", 469 "novalidation", 470 "searchschema", 471 "strict", 472 "wsi", 473 "unwrap", 474 "donotoverride", 475 "donotunwrap" 476 }; 477 478 private static final List importantWsdlServiceFeatures = Arrays.asList(WSCOMPILE_KEY_WSDL_SERVICE_FEATURES); 479 480 public List getServices() { 481 List serviceList = new ArrayList (); 482 483 Element data = helper.getPrimaryConfigurationData(true); 485 NodeList nodes = data.getElementsByTagName(WebServicesConstants.WEB_SERVICES); 486 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 487 488 if(nodes.getLength() != 0) { 489 Element serviceElements = (Element ) nodes.item(0); 490 NodeList serviceNameList = serviceElements.getElementsByTagNameNS( 491 EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesConstants.WEB_SERVICE_NAME); 492 for(int i = 0; i < serviceNameList.getLength(); i++ ) { 493 Element serviceNameElement = (Element ) serviceNameList.item(i); 494 NodeList nl = serviceNameElement.getChildNodes(); 495 if(nl.getLength() == 1) { 496 org.w3c.dom.Node n = nl.item(0); 497 if(n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) { 498 String serviceName = n.getNodeValue(); 499 String currentFeatures = projectProperties.getProperty("wscompile.service." + serviceName + ".features"); StubDescriptor stubType = getServiceStubDescriptor(serviceNameElement.getParentNode()); 501 WsCompileEditorSupport.ServiceSettings settings; 502 503 if(seiServiceStub == stubType) { 505 if(currentFeatures == null) { 506 currentFeatures = seiServiceStub.getDefaultFeaturesAsArgument(); 508 } 509 settings = new WsCompileEditorSupport.ServiceSettings( 510 serviceName, stubType, currentFeatures, allSeiServiceFeatures, importantSeiServiceFeatures); 511 } else { 512 if(currentFeatures == null) { 513 currentFeatures = wsdlServiceStub.getDefaultFeaturesAsArgument(); 515 } 516 settings = new WsCompileEditorSupport.ServiceSettings( 517 serviceName, stubType, currentFeatures, allWsdlServiceFeatures, importantWsdlServiceFeatures); 518 } 519 serviceList.add(settings); 520 } else { 521 } 523 } else { 524 } 526 } 527 } 528 529 return serviceList; 530 } 531 532 private StubDescriptor getServiceStubDescriptor(org.w3c.dom.Node parentNode) { 533 StubDescriptor result = null; 534 535 if(parentNode instanceof Element ) { 536 Element parentElement = (Element ) parentNode; 537 NodeList fromWsdlList = parentElement.getElementsByTagNameNS( 538 EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, WebServicesConstants.WEB_SERVICE_FROM_WSDL); 539 if(fromWsdlList.getLength() == 1) { 540 result = wsdlServiceStub; 541 } else { 542 result = seiServiceStub; 543 } 544 } 545 546 return result; 547 } 548 549 private boolean updateWsCompileProperties(String serviceName) { 550 562 boolean globalPropertiesChanged = false; 563 564 EditableProperties globalProperties = PropertyUtils.getGlobalProperties(); 565 if(globalProperties.getProperty(WSCOMPILE_TOOLS_CLASSPATH) == null) { 566 globalProperties.setProperty(WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); 567 568 try { 569 PropertyUtils.putGlobalProperties(globalProperties); 570 } catch(java.io.IOException ex) { 571 String mes = "Error saving global properties when adding wscompile.tools.classpath for service '" + serviceName + "'\r\n" + ex.getMessage(); 572 NotifyDescriptor desc = new NotifyDescriptor.Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); 573 DialogDisplayer.getDefault().notify(desc); 574 } 575 576 globalPropertiesChanged = true; 577 } 578 579 boolean projectPropertiesChanged = false; 580 EditableProperties projectProperties = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 581 582 { HashSet wscJars = new HashSet (); 584 boolean newWscJars = false; 585 String wscClientClasspath = projectProperties.getProperty(WSCOMPILE_CLASSPATH); 586 if(wscClientClasspath != null) { 587 String [] libs = PropertyUtils.tokenizePath(wscClientClasspath); 588 for(int i = 0; i < libs.length; i++) { 589 wscJars.add(libs[i]); 590 } 591 } 592 593 for(int i = 0; i < WSCOMPILE_JARS.length; i++) { 594 if(!wscJars.contains(WSCOMPILE_JARS[i])) { 595 wscJars.add(WSCOMPILE_JARS[i]); 596 newWscJars = true; 597 } 598 } 599 600 if(newWscJars) { 601 StringBuffer newClasspathBuf = new StringBuffer (256); 602 for(Iterator iter = wscJars.iterator(); iter.hasNext(); ) { 603 newClasspathBuf.append(iter.next().toString()); 604 if(iter.hasNext()) { 605 newClasspathBuf.append(":"); 606 } 607 } 608 projectProperties.put(WSCOMPILE_CLASSPATH, newClasspathBuf.toString()); 609 projectPropertiesChanged = true; 610 } 611 } 612 613 if(projectProperties.getProperty(WSCOMPILE_TOOLS_CLASSPATH) == null) { 615 projectProperties.setProperty(WSCOMPILE_TOOLS_CLASSPATH, "${java.home}\\..\\lib\\tools.jar"); projectPropertiesChanged = true; 617 } 618 619 if(projectPropertiesChanged) { 620 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, projectProperties); 621 } 622 return globalPropertiesChanged || projectPropertiesChanged; 623 } 624 625 public void addInfrastructure(String implBeanClass, FileObject pkg){ 626 } 716 717 private EjbJar getEjbJar() { 718 try { 719 return DDProvider.getDefault().getMergedDDRoot(org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJars(project)[0].getMetadataUnit()); 721 } catch (java.io.IOException e) { 722 org.openide.ErrorManager.getDefault().log(e.getLocalizedMessage()); 723 } 724 return null; 725 } 726 727 public FileObject getMetaInf() { 728 EjbJarProvider provider = (EjbJarProvider)project.getLookup().lookup(EjbJarProvider.class); 729 return provider.getMetaInf(); 730 } 731 732 public FileObject getDeploymentDescriptor() { 733 FileObject metaInfFo = getMetaInf(); 734 if (metaInfFo==null) { 735 return null; 736 } 737 return metaInfFo.getFileObject(EjbJarProvider.FILE_DD); 738 } 739 740 private String getPackageName(FileObject file){ 741 FileObject parent = file.getParent(); 742 Sources sources = ProjectUtils.getSources(project); 743 SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 744 String packageName = null; 745 for (int i = 0; i < groups.length && packageName == null; i++) { 746 packageName = FileUtil.getRelativePath(groups[i].getRootFolder(), parent); 747 if (packageName != null) { 748 packageName = groups[i].getName() + "/" + packageName; 749 } 750 } 751 return packageName + ""; 752 } 753 754 private FileObject getFileObject(String propname) { 755 String prop = helper.getStandardPropertyEvaluator().getProperty(propname); 756 if (prop != null) { 757 return helper.resolveFileObject(prop); 758 } 759 760 return null; 761 } 762 763 public FileObject getWsdlFolder(boolean create) throws IOException { 764 FileObject wsdlFolder = null; 765 FileObject metaInf = getMetaInf(); 766 767 if(metaInf != null) { 768 wsdlFolder = metaInf.getFileObject(WSDL_FOLDER); 769 if(wsdlFolder == null && create) { 770 wsdlFolder = metaInf.createFolder(WSDL_FOLDER); 771 } 772 } else if(create) { 773 ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, 776 NbBundle.getMessage(EjbJarWebServicesSupport.class, "MSG_MetaInfNotFoundForWsdlFolder")); 777 } 778 779 return wsdlFolder; 780 } 781 782 public ClassPath getClassPath() { 783 synchronized (this) { 784 if (projectSourcesClassPath == null) { 785 ClassPathProviderImpl cpProvider = (ClassPathProviderImpl)project.getLookup().lookup(ClassPathProviderImpl.class); 786 projectSourcesClassPath = ClassPathSupport.createWeakProxyClassPath(new ClassPath[] { 787 cpProvider.getProjectSourcesClassPath(ClassPath.SOURCE), 788 cpProvider.getJ2eePlatformClassPath(), 789 }); 790 } 791 return projectSourcesClassPath; 792 } 793 } 794 795 private static final JAXRPCStubDescriptor seiServiceStub = new JAXRPCStubDescriptor( 797 StubDescriptor.SEI_SERVICE_STUB, 798 NbBundle.getMessage(EjbJarWebServicesSupport.class,"LBL_SEIServiceStub"), new String [] {"documentliteral", "strict", "useonewayoperations"}); 800 801 private static final JAXRPCStubDescriptor wsdlServiceStub = new JAXRPCStubDescriptor( 802 StubDescriptor.WSDL_SERVICE_STUB, 803 NbBundle.getMessage(EjbJarWebServicesSupport.class,"LBL_WSDLServiceStub"), new String [] { "wsi", "strict" }); 806 808 private static class JAXRPCStubDescriptor extends StubDescriptor { 809 810 private String [] defaultFeatures; 811 812 public JAXRPCStubDescriptor(String name, String displayName, String [] defaultFeatures) { 813 super(name, displayName); 814 815 this.defaultFeatures = defaultFeatures; 816 } 817 818 public String [] getDefaultFeatures() { 819 return defaultFeatures; 820 } 821 822 public String getDefaultFeaturesAsArgument() { 823 StringBuffer buf = new StringBuffer (defaultFeatures.length*32); 824 for(int i = 0; i < defaultFeatures.length; i++) { 825 if(i > 0) { 826 buf.append(","); 827 } 828 829 buf.append(defaultFeatures[i]); 830 } 831 return buf.toString(); 832 } 833 } 834 } 835 | Popular Tags |