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: package org.netbeans.modules.websvc.core;
043:
044: import java.util.Map;
045: import org.netbeans.api.project.Project;
046: import org.netbeans.modules.j2ee.api.ejbjar.Car;
047: import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
048: import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
049: import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
050: import org.netbeans.modules.web.api.webmodule.WebModule;
051: import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport;
052:
053: /**
054: *
055: * @author radko, mkuchtiak
056: */
057: public class ProjectInfo {
058:
059: private Project project;
060: private int projectType;
061:
062: public static final int JSE_PROJECT_TYPE = 0;
063: public static final int WEB_PROJECT_TYPE = 1;
064: public static final int EJB_PROJECT_TYPE = 2;
065: public static final int CAR_PROJECT_TYPE = 3;
066:
067: private boolean jwsdpSupported = false;
068: private boolean jsr109Supported = false;
069: private boolean jsr109oldSupported = false;
070: private boolean jaxWsInJ2ee14Supported = false;
071:
072: /** Creates a new instance of ProjectInfo */
073:
074: public ProjectInfo(Project project) {
075: this .project = project;
076: JAXWSSupport wss = JAXWSSupport.getJAXWSSupport(project
077: .getProjectDirectory());
078: if (wss != null) {
079: Map properties = wss.getAntProjectHelper()
080: .getStandardPropertyEvaluator().getProperties();
081: String serverInstance = (String) properties
082: .get("j2ee.server.instance"); //NOI18N
083: if (serverInstance != null) {
084: J2eePlatform j2eePlatform = Deployment.getDefault()
085: .getJ2eePlatform(serverInstance);
086: if (j2eePlatform != null) {
087: jwsdpSupported = j2eePlatform
088: .isToolSupported(J2eePlatform.TOOL_JWSDP);
089: jsr109Supported = j2eePlatform
090: .isToolSupported(J2eePlatform.TOOL_JSR109);
091: jsr109oldSupported = j2eePlatform
092: .isToolSupported(J2eePlatform.TOOL_WSCOMPILE);
093: jaxWsInJ2ee14Supported = j2eePlatform
094: .isToolSupported("JaxWs-in-j2ee14-supported");
095: }
096: }
097: }
098:
099: WebModule wm = WebModule.getWebModule(project
100: .getProjectDirectory());
101: EjbJar em = EjbJar.getEjbJar(project.getProjectDirectory());
102: Car car = Car.getCar(project.getProjectDirectory());
103: if (em != null)
104: projectType = EJB_PROJECT_TYPE;
105: else if (wm != null)
106: projectType = WEB_PROJECT_TYPE;
107: else if (car != null)
108: projectType = CAR_PROJECT_TYPE;
109: else
110: projectType = JSE_PROJECT_TYPE;
111: }
112:
113: public int getProjectType() {
114: return projectType;
115: }
116:
117: public Project getProject() {
118: return project;
119: }
120:
121: public boolean isJwsdpSupported() {
122: return jwsdpSupported;
123: }
124:
125: public boolean isJsr109Supported() {
126: return jsr109Supported;
127: }
128:
129: public boolean isJsr109oldSupported() {
130: return jsr109oldSupported;
131: }
132:
133: public boolean isJaxWsInJ2ee14Supported() {
134: return jaxWsInJ2ee14Supported;
135: }
136: }
|