1 19 20 package org.netbeans.modules.web.project.jaxws; 21 22 import java.io.IOException ; 23 import org.netbeans.api.java.classpath.ClassPath; 24 import org.netbeans.api.java.project.JavaProjectConstants; 25 import org.netbeans.api.project.ProjectUtils; 26 import org.netbeans.api.project.SourceGroup; 27 import org.netbeans.api.project.libraries.Library; 28 import org.netbeans.api.project.libraries.LibraryManager; 29 import org.netbeans.modules.web.api.webmodule.WebModule; 30 import org.netbeans.modules.web.project.WebProject; 31 import org.netbeans.modules.websvc.api.jaxws.project.WSUtils; 32 import org.netbeans.modules.websvc.api.jaxws.project.config.Client; 33 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 34 import org.netbeans.modules.websvc.spi.jaxws.client.ProjectJAXWSClientSupport; 35 import org.netbeans.spi.java.project.classpath.ProjectClassPathExtender; 36 import org.openide.ErrorManager; 37 import org.openide.filesystems.FileObject; 38 39 43 public class WebProjectJAXWSClientSupport extends ProjectJAXWSClientSupport { 44 WebProject project; 45 46 47 public WebProjectJAXWSClientSupport(WebProject project) { 48 super(project); 49 this.project=project; 50 } 51 52 public FileObject getWsdlFolder(boolean create) throws IOException { 53 WebModule webModule = WebModule.getWebModule(project.getProjectDirectory()); 54 if (webModule!=null) { 55 FileObject webInfFo = webModule.getWebInf(); 56 if (webInfFo!=null) { 57 FileObject wsdlFo = webInfFo.getFileObject("wsdl"); if (wsdlFo!=null) return wsdlFo; 59 else if (create) { 60 return webInfFo.createFolder("wsdl"); } 62 } 63 } 64 return null; 65 } 66 67 protected void addJaxWs20Library() throws Exception { 68 69 SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 70 ClassPath classPath = ClassPath.getClassPath(sgs[0].getRootFolder(),ClassPath.COMPILE); 71 FileObject wsimportFO = classPath.findResource("com/sun/tools/ws/ant/WsImport.class"); 73 if (wsimportFO == null) { 74 ProjectClassPathExtender pce = (ProjectClassPathExtender)project.getLookup().lookup(ProjectClassPathExtender.class); 76 Library jaxws20_ext = LibraryManager.getDefault().getLibrary("jaxws20"); if ((pce!=null) && (jaxws20_ext != null)) { 78 try{ 79 pce.addLibrary(jaxws20_ext); 80 }catch(IOException e){ 81 throw new Exception ("Unable to add JAXWS 2.0 library", e.getCause()); 82 } 83 } else { 84 throw new Exception ("Unable to add JAXWS 2.0 Library. " + 85 "ProjectClassPathExtender or library not found"); 86 } 87 } 88 } 89 90 92 protected FileObject getXmlArtifactsRoot() { 93 return project.getWebModule().getConfDir(); 94 } 95 96 public String addServiceClient(String clientName, String wsdlUrl, String packageName, boolean isJsr109) { 97 FileObject fo = project.findJaxWsFileObject(); 99 if (fo==null) { 100 try { 101 project.createJaxWsFileObject(); 102 } catch (IOException ex) { 103 ErrorManager.getDefault().notify(ex); 104 } 105 } 106 String finalClientName = super.addServiceClient(clientName, wsdlUrl, packageName, isJsr109); 107 108 JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class); 111 Client client = jaxWsModel.findClientByName(finalClientName); 112 if (client!=null && client.getWsdlUrl().startsWith("file:")) try { 114 FileObject wsdlFolder = getWsdlFolderForClient(finalClientName); 115 FileObject xmlResorcesFo = getLocalWsdlFolderForClient(finalClientName,false); 116 if (xmlResorcesFo!=null) WSUtils.copyFiles(xmlResorcesFo, wsdlFolder); 117 } catch (IOException ex) { 118 ErrorManager.getDefault().notify(ex); 119 } 120 121 return finalClientName; 122 } 123 124 } 125 | Popular Tags |