1 19 27 28 package org.netbeans.modules.websvc.dev.wizard; 29 30 import org.netbeans.api.java.classpath.ClassPath; 31 import org.netbeans.api.java.project.JavaProjectConstants; 32 import org.netbeans.api.project.Project; 33 import org.netbeans.api.project.ProjectUtils; 34 import org.netbeans.api.project.SourceGroup; 35 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 36 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 37 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 38 import org.openide.filesystems.FileObject; 39 40 44 public class PlatformUtil { 45 46 47 public PlatformUtil() { 48 } 49 50 public static J2eePlatform getJ2eePlatform(Project project){ 52 J2eeModuleProvider provider = (J2eeModuleProvider) project.getLookup().lookup(J2eeModuleProvider.class); 53 if(provider != null){ 54 String serverInstanceID = provider.getServerInstanceID(); 55 if(serverInstanceID != null && serverInstanceID.length() > 0) { 56 return Deployment.getDefault().getJ2eePlatform(serverInstanceID); 57 } 58 } 59 return null; 60 } 61 62 public static boolean isJWSDPSupported(Project project){ 63 J2eePlatform j2eePlatform = getJ2eePlatform(project); 64 if(j2eePlatform != null){ 65 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_JWSDP); 66 } 67 return false; 68 } 69 70 public static boolean isJsr109Supported(Project project){ 71 J2eePlatform j2eePlatform = getJ2eePlatform(project); 72 if(j2eePlatform != null){ 73 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_JSR109); 74 } 75 return false; 76 } 77 78 public static boolean isJsr109OldSupported(Project project){ 79 J2eePlatform j2eePlatform = getJ2eePlatform(project); 80 if(j2eePlatform != null){ 81 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSCOMPILE); 82 } 83 return false; 84 } 85 86 public static boolean hasJAXWSLibrary(Project project){ 87 SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 88 ClassPath classPath = ClassPath.getClassPath(sgs[0].getRootFolder(),ClassPath.COMPILE); 89 FileObject wsimportFO = classPath.findResource("com/sun/tools/ws/ant/WsImport.class"); return wsimportFO != null; 91 } 92 } 93 94 95 | Popular Tags |