001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: /*
042: * PlatformUtil.java
043: *
044: * Created on April 18, 2006, 2:19 PM
045: *
046: * To change this template, choose Tools | Template Manager
047: * and open the template in the editor.
048: */
049:
050: package org.netbeans.modules.websvc.core.dev.wizard;
051:
052: import org.netbeans.api.java.classpath.ClassPath;
053: import org.netbeans.api.java.project.JavaProjectConstants;
054: import org.netbeans.api.project.Project;
055: import org.netbeans.api.project.ProjectUtils;
056: import org.netbeans.api.project.SourceGroup;
057: import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
058: import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
059: import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
060: import org.openide.filesystems.FileObject;
061:
062: /**
063: *
064: * @author rico
065: */
066: public class PlatformUtil {
067:
068: /** Creates a new instance of PlatformUtil */
069: public PlatformUtil() {
070: }
071:
072: //Factor these methods out and put in a common Util class
073: public static J2eePlatform getJ2eePlatform(Project project) {
074: J2eeModuleProvider provider = (J2eeModuleProvider) project
075: .getLookup().lookup(J2eeModuleProvider.class);
076: if (provider != null) {
077: String serverInstanceID = provider.getServerInstanceID();
078: if (serverInstanceID != null
079: && serverInstanceID.length() > 0) {
080: return Deployment.getDefault().getJ2eePlatform(
081: serverInstanceID);
082: }
083: }
084: return null;
085: }
086:
087: public static boolean isJWSDPSupported(Project project) {
088: J2eePlatform j2eePlatform = getJ2eePlatform(project);
089: if (j2eePlatform != null) {
090: return j2eePlatform
091: .isToolSupported(J2eePlatform.TOOL_JWSDP);
092: }
093: return false;
094: }
095:
096: public static boolean isWsitSupported(Project project) {
097: J2eePlatform j2eePlatform = getJ2eePlatform(project);
098: if (j2eePlatform != null) {
099: return j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSIT);
100: }
101: return false;
102: }
103:
104: public static boolean isJsr109Supported(Project project) {
105: J2eePlatform j2eePlatform = getJ2eePlatform(project);
106: if (j2eePlatform != null) {
107: return j2eePlatform
108: .isToolSupported(J2eePlatform.TOOL_JSR109);
109: }
110: return false;
111: }
112:
113: public static boolean isJsr109OldSupported(Project project) {
114: J2eePlatform j2eePlatform = getJ2eePlatform(project);
115: if (j2eePlatform != null) {
116: return j2eePlatform
117: .isToolSupported(J2eePlatform.TOOL_WSCOMPILE);
118: }
119: return false;
120: }
121:
122: public static boolean isJaxWsInJ2ee14Supported(Project project) {
123: J2eePlatform j2eePlatform = getJ2eePlatform(project);
124: if (j2eePlatform != null) {
125: return j2eePlatform
126: .isToolSupported("JaxWs-in-j2ee14-supported");
127: }
128: return false;
129: }
130:
131: public static boolean hasJAXWSLibrary(Project project) {
132: SourceGroup[] sgs = ProjectUtils
133: .getSources(project)
134: .getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
135: ClassPath classPath = ClassPath.getClassPath(sgs[0]
136: .getRootFolder(), ClassPath.COMPILE);
137: FileObject wsimportFO = classPath
138: .findResource("com/sun/tools/ws/ant/WsImport.class"); // NOI18N
139: return wsimportFO != null;
140: }
141: }
|