KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > api > webservices > WebServicesSupport


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 package org.netbeans.modules.websvc.api.webservices;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import org.netbeans.api.java.classpath.ClassPath;
25 import org.netbeans.modules.j2ee.metadata.MetadataUnit;
26 import org.netbeans.modules.websvc.webservices.WebServicesSupportAccessor;
27 import org.netbeans.modules.websvc.spi.webservices.*;
28 import org.openide.filesystems.FileObject;
29 import org.openide.util.Lookup;
30 import org.netbeans.spi.project.support.ant.AntProjectHelper;
31 import org.netbeans.api.project.Project;
32 import org.netbeans.modules.j2ee.dd.api.webservices.ServiceImplBean;
33 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
34 import org.netbeans.spi.project.support.ant.ReferenceHelper;
35
36 /** WebServicesSupport should be used to manipulate a projects representation
37  * of a web service implementation.
38  * <p>
39  * A client may obtain a WebServicesSupport instance using
40  * <code>WebServicesSupport.getWebServicesSupport(fileObject)</code> static
41  * method, for any FileObject in the project directory structure.
42  *
43  * @author Peter Williams
44  */

45 public final class WebServicesSupport implements MetadataUnit {
46     
47     private WebServicesSupportImpl impl;
48     private static final Lookup.Result implementations =
49     Lookup.getDefault().lookup(new Lookup.Template(WebServicesSupportProvider.class));
50     
51     static {
52         WebServicesSupportAccessor.DEFAULT = new WebServicesSupportAccessor() {
53             public WebServicesSupport createWebServicesSupport(WebServicesSupportImpl spiWebServicesSupport) {
54                 return new WebServicesSupport(spiWebServicesSupport);
55             }
56             
57             public WebServicesSupportImpl getWebServicesSupportImpl(WebServicesSupport wss) {
58                 return wss == null ? null : wss.impl;
59             }
60         };
61     }
62     
63     private WebServicesSupport(WebServicesSupportImpl impl) {
64         if (impl == null)
65             throw new IllegalArgumentException JavaDoc();
66         this.impl = impl;
67     }
68     
69     /** Find the WebServicesSupport for given file or null if the file does not belong
70      * to any module support web services.
71      */

72     public static WebServicesSupport getWebServicesSupport(FileObject f) {
73         if (f == null) {
74             throw new NullPointerException JavaDoc("Passed null to WebServicesSupport.getWebServicesSupport(FileObject)"); // NOI18N
75
}
76         Iterator JavaDoc it = implementations.allInstances().iterator();
77         while (it.hasNext()) {
78             WebServicesSupportProvider impl = (WebServicesSupportProvider)it.next();
79             WebServicesSupport wss = impl.findWebServicesSupport(f);
80             if (wss != null) {
81                 return wss;
82             }
83         }
84         return null;
85     }
86     
87     // Delegated methods from WebServicesSupportImpl
88

89     public void addServiceImpl(String JavaDoc serviceName, FileObject configFile, boolean fromWSDL) {
90         impl.addServiceImpl(serviceName, configFile, fromWSDL);
91     }
92     
93     public void addServiceEntriesToDD(String JavaDoc serviceName, String JavaDoc serviceEndpointInterface, String JavaDoc servantClassName){
94         impl.addServiceEntriesToDD(serviceName, serviceEndpointInterface, servantClassName);
95     }
96     
97     public FileObject getWebservicesDD() {
98         return impl.getWebservicesDD();
99     }
100     
101     public FileObject getWsDDFolder() {
102         return impl.getWsDDFolder();
103     }
104     
105     public String JavaDoc getArchiveDDFolderName() {
106         return impl.getArchiveDDFolderName();
107     }
108     
109     public String JavaDoc getImplementationBean(String JavaDoc linkName) {
110         return impl.getImplementationBean(linkName);
111     }
112     
113     public void removeServiceEntry(String JavaDoc linkName) {
114         impl.removeServiceEntry(linkName);
115     }
116     
117     public void removeProjectEntries(String JavaDoc serviceName){
118         impl.removeProjectEntries(serviceName);
119     }
120     
121     public AntProjectHelper getAntProjectHelper() {
122         return impl.getAntProjectHelper();
123     }
124     
125     public String JavaDoc generateImplementationBean(String JavaDoc name, FileObject pkg, Project project, String JavaDoc delegateData) throws java.io.IOException JavaDoc {
126         return impl.generateImplementationBean(name, pkg, project, delegateData);
127     }
128     
129     public void addServiceImplLinkEntry(ServiceImplBean serviceImplBean, String JavaDoc wsName) {
130         impl.addServiceImplLinkEntry(serviceImplBean, wsName);
131     }
132     
133     public ReferenceHelper getReferenceHelper(){
134         return impl.getReferenceHelper();
135     }
136     
137     public List JavaDoc/*WsCompileEditorSupport.ServiceSettings*/ getServices() {
138         return impl.getServices();
139     }
140     
141     public void addInfrastructure(String JavaDoc implBeanClass, FileObject pkg) {
142         impl.addInfrastructure(implBeanClass, pkg);
143     }
144     
145     public boolean isFromWSDL(String JavaDoc serviceName) {
146         return impl.isFromWSDL(serviceName);
147     }
148     
149     public void addServiceImpl(String JavaDoc serviceName, FileObject configFile, boolean fromWSDL, String JavaDoc[] wscompileFeatures) {
150         impl.addServiceImpl(serviceName, configFile, fromWSDL,wscompileFeatures);
151     }
152
153     public FileObject getDeploymentDescriptor() {
154         return getWebservicesDD();
155     }
156
157     public ClassPath getClassPath() {
158         return impl.getClassPath();
159     }
160     
161 }
162
Popular Tags