KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > dev > wizard > PlatformUtil


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * PlatformUtil.java
21  *
22  * Created on April 18, 2006, 2:19 PM
23  *
24  * To change this template, choose Tools | Template Manager
25  * and open the template in the editor.
26  */

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 /**
41  *
42  * @author rico
43  */

44 public class PlatformUtil {
45     
46     /** Creates a new instance of PlatformUtil */
47     public PlatformUtil() {
48     }
49     
50     //Factor these methods out and put in a common Util class
51
public static J2eePlatform getJ2eePlatform(Project project){
52         J2eeModuleProvider provider = (J2eeModuleProvider) project.getLookup().lookup(J2eeModuleProvider.class);
53         if(provider != null){
54             String JavaDoc 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"); // NOI18N
90
return wsimportFO != null;
91     }
92 }
93
94
95
Popular Tags