KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > jaxws > api > JAXWSSupport


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.jaxws.api;
21
22 import java.io.IOException JavaDoc;
23 import java.net.URL JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import org.netbeans.modules.websvc.jaxws.JAXWSSupportAccessor;
27 import org.netbeans.modules.websvc.jaxws.spi.JAXWSSupportImpl;
28 import org.netbeans.modules.websvc.jaxws.spi.JAXWSSupportProvider;
29 import org.netbeans.spi.project.support.ant.AntProjectHelper;
30 import org.openide.filesystems.FileObject;
31 import org.openide.util.Lookup;
32
33 /** JAXWSSupport should be used to manipulate projects representations
34  * of JAX-WS services.
35  * <p>
36  * A client may obtain a JAXWSSupport instance using
37  * <code>JAXWSSupport.getJAXWSSupport(fileObject)</code> static
38  * method, for any FileObject in the project directory structure.
39  *
40  * @author Peter Williams, Milan Kuchtiak
41  */

42 public final class JAXWSSupport {
43     
44     private JAXWSSupportImpl impl;
45     private static final Lookup.Result<JAXWSSupportProvider> implementations =
46     Lookup.getDefault().lookup(new Lookup.Template<JAXWSSupportProvider>(JAXWSSupportProvider.class));
47     
48     static {
49         JAXWSSupportAccessor.DEFAULT = new JAXWSSupportAccessor() {
50             public JAXWSSupport createJAXWSSupport(JAXWSSupportImpl spiWebServicesSupport) {
51                 return new JAXWSSupport(spiWebServicesSupport);
52             }
53             
54             public JAXWSSupportImpl getJAXWSSupportImpl(JAXWSSupport wss) {
55                 return wss == null ? null : wss.impl;
56             }
57         };
58     }
59     
60     private JAXWSSupport(JAXWSSupportImpl impl) {
61         if (impl == null)
62             throw new IllegalArgumentException JavaDoc();
63         this.impl = impl;
64     }
65     
66     /** Find the JAXWSSupport for given file or null if the file does not belong
67      * to any module support web services.
68      */

69     public static JAXWSSupport getJAXWSSupport(FileObject f) {
70         if (f == null) {
71             throw new NullPointerException JavaDoc("Passed null to WebServicesSupport.getWebServicesSupport(FileObject)"); // NOI18N
72
}
73         Iterator JavaDoc it = implementations.allInstances().iterator();
74         while (it.hasNext()) {
75             JAXWSSupportProvider supportProvider = (JAXWSSupportProvider)it.next();
76             JAXWSSupport wss = supportProvider.findJAXWSSupport(f);
77             if (wss != null) {
78                 return wss;
79             }
80         }
81         return null;
82     }
83     
84     // Delegated methods from WebServicesSupportImpl
85

86     /**
87      * Add web service to jax-ws.xml intended for web services from java
88      * @param serviceName service display name (name of the node ws will be presented in Netbeans), e.g. "SearchService"
89      * @param serviceImpl package name of the implementation class, e.g. "org.netbeans.SerchServiceImpl"
90      * @param isJsr109 Indicates if the web service is being created in a project that supports a JSR 109 container
91      */

92     public void addService(String JavaDoc serviceName, String JavaDoc serviceImpl, boolean isJsr109) {
93         impl.addService(serviceName, serviceImpl, isJsr109);
94     }
95     
96     /** Add web service to jax-ws.xml
97      * intended for web services from wsdl
98      * @param name service display name (name of the node ws will be presented in Netbeans), e.g. "SearchService"
99      * @param serviceImpl package name of the implementation class, e.g. "org.netbeans.SerchServiceImpl"
100      * @param wsdlUrl url of the local wsdl file, e.g. file:/home/userXY/documents/wsdl/SearchService.wsdl"
101      * @param serviceName service name (from service wsdl element), e.g. SearchService
102      * @param portName port name (from service:port element), e.g. SearchServicePort
103      * @param packageName package name where java artifacts will be generated
104      * @param isJsr109 Indicates if the web service is being created in a project that supports a JSR 109 container
105      * @return returns the unique IDE service name
106      */

107     public String JavaDoc addService(String JavaDoc name, String JavaDoc serviceImpl, String JavaDoc wsdlUrl,
108             String JavaDoc serviceName, String JavaDoc portName, String JavaDoc packageName, boolean isJsr109) {
109         return impl.addService(name, serviceImpl, wsdlUrl, serviceName, portName, packageName, isJsr109);
110     }
111     
112     /**
113      * Returns the list of web services in the project
114      * @return list of web services
115      */

116     public List JavaDoc getServices() {
117         return impl.getServices();
118     }
119   
120     /**
121      * Remove the web service entries from the project properties
122      * @param serviceName service IDE name
123      * project.xml files
124      */

125     public void removeService(String JavaDoc serviceName) {
126         impl.removeService(serviceName);
127     }
128     
129     /**
130      * Notification when Service (created from java) is removed from jax-ws.xml
131      * (JAXWSSupport needs to react when @WebService annotation is removed
132      * or when impl.class is removed (manually from project)
133      * @param serviceName service IDE name
134      */

135     public void serviceFromJavaRemoved(String JavaDoc serviceName) {
136         impl.serviceFromJavaRemoved(serviceName);
137     }
138     
139     /** Get the name of the implementation class
140      * given the service (ide) name
141      * @param serviceName service IDE name
142      * @return service implementation class package name
143      */

144     public String JavaDoc getServiceImpl(String JavaDoc serviceName) {
145         return impl.getServiceImpl(serviceName);
146     }
147     
148     /** Determine if the web service was created from WSDL
149      * @param serviceName service name
150      */

151     public boolean isFromWSDL(String JavaDoc serviceName) {
152         return impl.isFromWSDL(serviceName);
153     }
154     
155     /** Get WSDL folder for the project (folder containing wsdl files)
156      * The folder is used to save remote or local wsdl files to be available within the jar/war files.
157      * it is usually META-INF/wsdl folder (or WEB-INF/wsdl for web application)
158      * @param createFolder if (createFolder==true) the folder will be created (if not created before)
159      * @return the file object (folder) where wsdl files are located in project
160      */

161     public FileObject getWsdlFolder(boolean create) throws java.io.IOException JavaDoc {
162         return impl.getWsdlFolder(create);
163     }
164     
165     /** Get folder for local WSDL and XML artifacts for given service
166      * This is the location where wsdl/xml files are downloaded to the project.
167      * JAX-WS java artifacts will be generated from these local files instead of remote.
168      * @param serviceName service IDE name (the web service node display name)
169      * @param createFolder if (createFolder==true) the folder will be created (if not created before)
170      * @return the file object (folder) where wsdl files are located in project
171      */

172     public FileObject getLocalWsdlFolderForService(String JavaDoc serviceName, boolean createFolder) {
173         return impl.getLocalWsdlFolderForService(serviceName,createFolder);
174     }
175     
176     /** Get folder for local jaxb binding (xml) files for given service
177      * This is the location where external jaxb binding files are downloaded to the project.
178      * JAX-WS java artifacts will be generated using these local binding files instead of remote.
179      * @param serviceName service IDE name (the web service node display name)
180      * @param createFolder if (createFolder==true) the folder will be created (if not created before)
181      * @return the file object (folder) where jaxb binding files are located in project
182      */

183     public FileObject getBindingsFolderForService(String JavaDoc serviceName, boolean createFolder) {
184         return impl.getBindingsFolderForService(serviceName,createFolder);
185     }
186     
187     /**
188      * Get the AntProjectHelper from the project
189      */

190     public AntProjectHelper getAntProjectHelper() {
191         return impl.getAntProjectHelper();
192     }
193     
194     /** Get EntityCatalog for local copies of wsdl and schema files
195      */

196     public URL JavaDoc getCatalog() {
197         return impl.getCatalog();
198     }
199     
200     /** Get wsdlLocation information
201      * Useful for web service from wsdl (the @WebService wsdlLocation attribute)
202      * @param serviceName service "display" name
203      */

204     public String JavaDoc getWsdlLocation(String JavaDoc serviceName) {
205         return impl.getWsdlLocation(serviceName);
206     }
207     
208     /**
209      * Remove all entries associated with a non-JSR 109 entries
210      * This may include entries in the module's deployment descriptor,
211      * and entries in the implementation-specific descriptor file, sun-jaxws.xml.
212      * This is provided as a service so that the node can also use it for cleanup.
213      */

214     public void removeNonJsr109Entries(String JavaDoc serviceName) throws IOException JavaDoc{
215         impl.removeNonJsr109Entries(serviceName);
216     }
217     /**
218      * Returns the directory that contains the deployment descriptor in the project
219      */

220     public FileObject getDeploymentDescriptorFolder(){
221         return impl.getDeploymentDescriptorFolder();
222     }
223 }
224
Popular Tags