KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjarproject > jaxws > EjbProjectJAXWSSupport


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.j2ee.ejbjarproject.jaxws;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
25 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
26 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
27 import org.netbeans.modules.websvc.api.jaxws.project.WSUtils;
28 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
29 import org.netbeans.modules.websvc.jaxws.spi.ProjectJAXWSSupport;
30 import org.netbeans.spi.project.support.ant.AntProjectHelper;
31 import org.openide.ErrorManager;
32 import org.openide.filesystems.FileObject;
33
34 /**
35  *
36  * @author mkuchtiak
37  */

38 public class EjbProjectJAXWSSupport extends ProjectJAXWSSupport /*implements JAXWSSupportImpl*/ {
39     private EjbJarProject project;
40     private AntProjectHelper antProjectHelper;
41     
42     /** Creates a new instance of JAXWSSupport */
43     public EjbProjectJAXWSSupport(EjbJarProject project, AntProjectHelper antProjectHelper) {
44         super(project,antProjectHelper);
45         this.project = project;
46         this.antProjectHelper = antProjectHelper;
47     }
48
49     public FileObject getWsdlFolder(boolean create) throws java.io.IOException JavaDoc {
50         EjbJar ejbModule = EjbJar.getEjbJar(project.getProjectDirectory());
51         if (ejbModule!=null) {
52             FileObject metaInfFo = ejbModule.getMetaInf();
53             if (metaInfFo!=null) {
54                 FileObject wsdlFo = metaInfFo.getFileObject("wsdl"); //NOI18N
55
if (wsdlFo!=null) return wsdlFo;
56                 else if (create) {
57                     return metaInfFo.createFolder("wsdl"); //NOI18N
58
}
59             }
60         }
61         return null;
62     }
63     
64     /** Get wsdlLocation information
65      * Useful for web service from wsdl
66      * @param name service "display" name
67      */

68     public String JavaDoc getWsdlLocation(String JavaDoc serviceName) {
69         String JavaDoc localWsdl = serviceName+".wsdl"; //NOI18N
70
JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class);
71         if (jaxWsModel!=null) {
72             Service service = jaxWsModel.findServiceByName(serviceName);
73             if (service!=null) {
74                 String JavaDoc localWsdlFile = service.getLocalWsdlFile();
75                 if (localWsdlFile!=null) localWsdl=localWsdlFile;
76             }
77         }
78         String JavaDoc prefix = "META-INF/wsdl/"; //NOI18N
79
return prefix+serviceName+"/"+localWsdl; //NOI18N
80
}
81
82     public FileObject getDeploymentDescriptorFolder() {
83         EjbJar ejbModule = EjbJar.getEjbJar(project.getProjectDirectory());
84         if (ejbModule!=null) {
85             return ejbModule.getMetaInf();
86         }
87         return null;
88     }
89
90     protected void addJaxwsArtifacts(Project project, String JavaDoc wsName, String JavaDoc serviceImpl) throws Exception JavaDoc {
91     }
92     
93     /** return root folder for xml artifacts
94      */

95     protected FileObject getXmlArtifactsRoot() {
96         return project.getAPIEjbJar().getMetaInf();
97     }
98
99     public void removeNonJsr109Entries(String JavaDoc serviceName) throws IOException JavaDoc {
100         //noop since nonJSR 109 web services are not supported in the EJB module
101
}
102
103     public String JavaDoc addService(String JavaDoc name, String JavaDoc serviceImpl, String JavaDoc wsdlUrl, String JavaDoc serviceName, String JavaDoc portName, String JavaDoc packageName, boolean isJsr109) {
104         // create jax-ws.xml if necessary
105
FileObject fo = project.findJaxWsFileObject();
106         if (fo==null) {
107             try {
108                 project.createJaxWsFileObject();
109             } catch (IOException JavaDoc ex) {
110                 ErrorManager.getDefault().notify(ex);
111             }
112         }
113         return super.addService(name, serviceImpl, wsdlUrl, serviceName, portName, packageName, isJsr109);
114     }
115
116     public void addService(String JavaDoc serviceName, String JavaDoc serviceImpl, boolean isJsr109) {
117         // create jax-ws.xml if necessary
118
FileObject fo = project.findJaxWsFileObject();
119         if (fo==null) {
120             try {
121                 project.createJaxWsFileObject();
122             } catch (IOException JavaDoc ex) {
123                 ErrorManager.getDefault().notify(ex);
124             }
125         }
126         super.addService(serviceName, serviceImpl, isJsr109);
127     }
128     
129 }
130
Popular Tags