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.api.webservices;
043:
044: import java.util.Iterator;
045: import java.util.List;
046: import org.netbeans.api.java.classpath.ClassPath;
047: import org.netbeans.modules.websvc.webservices.WebServicesSupportAccessor;
048: import org.netbeans.modules.websvc.spi.webservices.*;
049: import org.openide.filesystems.FileObject;
050: import org.openide.util.Lookup;
051: import org.netbeans.spi.project.support.ant.AntProjectHelper;
052: import org.netbeans.api.project.Project;
053: import org.netbeans.modules.j2ee.dd.api.webservices.ServiceImplBean;
054: import org.netbeans.spi.java.classpath.support.ClassPathSupport;
055: import org.netbeans.spi.project.support.ant.ReferenceHelper;
056:
057: /** WebServicesSupport should be used to manipulate a projects representation
058: * of a web service implementation.
059: * <p>
060: * A client may obtain a WebServicesSupport instance using
061: * <code>WebServicesSupport.getWebServicesSupport(fileObject)</code> static
062: * method, for any FileObject in the project directory structure.
063: *
064: * @author Peter Williams
065: */
066: public final class WebServicesSupport {
067:
068: private WebServicesSupportImpl impl;
069: private static final Lookup.Result implementations = Lookup
070: .getDefault().lookup(
071: new Lookup.Template(
072: WebServicesSupportProvider.class));
073:
074: static {
075: WebServicesSupportAccessor.DEFAULT = new WebServicesSupportAccessor() {
076: public WebServicesSupport createWebServicesSupport(
077: WebServicesSupportImpl spiWebServicesSupport) {
078: return new WebServicesSupport(spiWebServicesSupport);
079: }
080:
081: public WebServicesSupportImpl getWebServicesSupportImpl(
082: WebServicesSupport wss) {
083: return wss == null ? null : wss.impl;
084: }
085: };
086: }
087:
088: private WebServicesSupport(WebServicesSupportImpl impl) {
089: if (impl == null)
090: throw new IllegalArgumentException();
091: this .impl = impl;
092: }
093:
094: /** Find the WebServicesSupport for given file or null if the file does not belong
095: * to any module support web services.
096: */
097: public static WebServicesSupport getWebServicesSupport(FileObject f) {
098: if (f == null) {
099: throw new NullPointerException(
100: "Passed null to WebServicesSupport.getWebServicesSupport(FileObject)"); // NOI18N
101: }
102: Iterator it = implementations.allInstances().iterator();
103: while (it.hasNext()) {
104: WebServicesSupportProvider impl = (WebServicesSupportProvider) it
105: .next();
106: WebServicesSupport wss = impl.findWebServicesSupport(f);
107: if (wss != null) {
108: return wss;
109: }
110: }
111: return null;
112: }
113:
114: // Delegated methods from WebServicesSupportImpl
115:
116: public void addServiceImpl(String serviceName,
117: FileObject configFile, boolean fromWSDL) {
118: impl.addServiceImpl(serviceName, configFile, fromWSDL);
119: }
120:
121: public void addServiceEntriesToDD(String serviceName,
122: String serviceEndpointInterface, String servantClassName) {
123: impl.addServiceEntriesToDD(serviceName,
124: serviceEndpointInterface, servantClassName);
125: }
126:
127: public FileObject getWebservicesDD() {
128: return impl.getWebservicesDD();
129: }
130:
131: public FileObject getWsDDFolder() {
132: return impl.getWsDDFolder();
133: }
134:
135: public String getArchiveDDFolderName() {
136: return impl.getArchiveDDFolderName();
137: }
138:
139: public String getImplementationBean(String linkName) {
140: return impl.getImplementationBean(linkName);
141: }
142:
143: public void removeServiceEntry(String linkName) {
144: impl.removeServiceEntry(linkName);
145: }
146:
147: public void removeProjectEntries(String serviceName) {
148: impl.removeProjectEntries(serviceName);
149: }
150:
151: public AntProjectHelper getAntProjectHelper() {
152: return impl.getAntProjectHelper();
153: }
154:
155: public String generateImplementationBean(String name,
156: FileObject pkg, Project project, String delegateData)
157: throws java.io.IOException {
158: return impl.generateImplementationBean(name, pkg, project,
159: delegateData);
160: }
161:
162: public void addServiceImplLinkEntry(
163: ServiceImplBean serviceImplBean, String wsName) {
164: impl.addServiceImplLinkEntry(serviceImplBean, wsName);
165: }
166:
167: public ReferenceHelper getReferenceHelper() {
168: return impl.getReferenceHelper();
169: }
170:
171: public List/*WsCompileEditorSupport.ServiceSettings*/getServices() {
172: return impl.getServices();
173: }
174:
175: public void addInfrastructure(String implBeanClass, FileObject pkg) {
176: impl.addInfrastructure(implBeanClass, pkg);
177: }
178:
179: public boolean isFromWSDL(String serviceName) {
180: return impl.isFromWSDL(serviceName);
181: }
182:
183: public void addServiceImpl(String serviceName,
184: FileObject configFile, boolean fromWSDL,
185: String[] wscompileFeatures) {
186: impl.addServiceImpl(serviceName, configFile, fromWSDL,
187: wscompileFeatures);
188: }
189:
190: }
|