KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > clientproject > wsclient > AppClientProjectJAXWSClientSupport


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

37 public class AppClientProjectJAXWSClientSupport extends ProjectJAXWSClientSupport /*implements JAXWSClientSupportImpl*/ {
38     AppClientProject project;
39     
40     /**
41      * Creates a new instance of AppClientProjectJAXWSClientSupport
42      */

43     public AppClientProjectJAXWSClientSupport(AppClientProject project, AntProjectHelper antProjectHelper) {
44         super(project);
45         this.project=project;
46     }
47
48     public FileObject getWsdlFolder(boolean create) throws IOException JavaDoc {
49         JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class);
50         Car carModule = Car.getCar(project.getProjectDirectory());
51         if (carModule!=null) {
52             FileObject webInfFo = carModule.getMetaInf();
53             if (webInfFo!=null) {
54                 FileObject wsdlFo = webInfFo.getFileObject("wsdl"); //NOI18N
55
if (wsdlFo!=null) {
56                     return wsdlFo;
57                 } else if (create) {
58                     return webInfFo.createFolder("wsdl"); //NOI18N
59
}
60             }
61         }
62         return null;
63     }
64
65     protected void addJaxWs20Library() throws Exception JavaDoc {
66     }
67     
68     /** return root folder for xml artifacts
69      */

70     protected FileObject getXmlArtifactsRoot() {
71         return project.getCarModule().getMetaInf();
72     }
73
74     public String JavaDoc addServiceClient(String JavaDoc clientName, String JavaDoc wsdlUrl, String JavaDoc packageName, boolean isJsr109) {
75         // create jax-ws.xml if necessary
76
FileObject fo = project.findJaxWsFileObject();
77         if (fo==null) {
78             try {
79                 project.createJaxWsFileObject();
80             } catch (IOException JavaDoc ex) {
81                 ErrorManager.getDefault().notify(ex);
82             }
83         }
84         String JavaDoc finalClientName = super.addServiceClient(clientName, wsdlUrl, packageName, isJsr109);
85         
86         // copy resources to META-INF/wsdl/client/${clientName}
87
// this will be done only for local wsdl files
88
JaxWsModel jaxWsModel = (JaxWsModel)project.getLookup().lookup(JaxWsModel.class);
89         Client client = jaxWsModel.findClientByName(finalClientName);
90         if (client!=null && client.getWsdlUrl().startsWith("file:")) //NOI18N
91
try {
92                 FileObject wsdlFolder = getWsdlFolderForClient(finalClientName);
93                 FileObject xmlResorcesFo = getLocalWsdlFolderForClient(finalClientName,false);
94                 if (xmlResorcesFo!=null) WSUtils.copyFiles(xmlResorcesFo, wsdlFolder);
95             } catch (IOException JavaDoc ex) {
96                 ErrorManager.getDefault().notify(ex);
97             }
98         return finalClientName;
99     }
100     
101 }
102
Popular Tags