KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > lib > WebSvc


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  * WebSvc.java
21  *
22  * Created on May 12, 2005, 3:45 PM
23  *
24  * To change this template, choose Tools | Options and locate the template under
25  * the Source Creation and Management node. Right-click the template and choose
26  * Open. You can then make changes to the template in the Source Editor.
27  */

28
29 package org.netbeans.test.j2ee.lib;
30
31 import java.io.File JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34 import org.netbeans.api.project.Project;
35 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
36
37
38 /**
39  *
40  * @author jungi
41  */

42 public final class WebSvc extends AbstractJ2eeFile {
43     
44     static final String JavaDoc SEI = "SEI";
45     static final String JavaDoc BEAN_IMPL = "Bean";
46     static final String JavaDoc IMPL = "Impl";
47     static final String JavaDoc CONFIG = "-config.xml";
48     static final String JavaDoc WS_XML = "webservices.xml";
49     private String JavaDoc wsIntf;
50     private String JavaDoc wsImpl;
51     private String JavaDoc wsConfig;
52     
53     /** Creates a new instance of WebSvc */
54     public WebSvc(String JavaDoc fqName, Project p) {
55         super(fqName, p);
56         wsIntf = name + SEI;
57         wsImpl = name + ((isEjbMod) ? BEAN_IMPL : IMPL);
58         wsConfig = name + CONFIG;
59     }
60     
61     public WebSvc(String JavaDoc fqName, Project p, String JavaDoc srcRoot) {
62         super(fqName, p, srcRoot);
63         wsIntf = name + SEI;
64         wsImpl = name + ((isEjbMod) ? BEAN_IMPL : IMPL);
65         wsConfig = name + CONFIG;
66     }
67     
68     private boolean implClassExists() {
69         String JavaDoc res = pkgName.replace('.', File.separatorChar) + wsImpl + ".java";
70         //System.err.println("name: " + name);
71
//System.err.println("impl: " + res);
72
return srcFileExist(res);
73     }
74     
75     private boolean seiClassExists() {
76         String JavaDoc res = pkgName.replace('.', File.separatorChar) + wsIntf + ".java";
77         //System.err.println("intf: " + res);
78
return srcFileExist(res);
79     }
80     
81     private boolean configXmlExists() {
82         String JavaDoc res = pkgName.replace('.', File.separatorChar) + wsConfig;
83         //System.err.println("config: " + res);
84
return srcFileExist(res);
85     }
86     
87     private boolean websvcXmlExists() {
88         //System.err.println("wsxml: " + WS_XML);
89
return confFileExist(WS_XML);
90     }
91
92     public String JavaDoc[] checkExistingFiles() {
93         List JavaDoc l = new ArrayList JavaDoc();
94         if (!implClassExists()) {
95             l.add(MESSAGE.replaceAll("\\$0", "WS impl class"));
96         }
97         if (!seiClassExists()) {
98             l.add(MESSAGE.replaceAll("\\$0", "WS sei class"));
99         }
100         if (!configXmlExists()) {
101             l.add(MESSAGE.replaceAll("\\$0", "WS config file"));
102         }
103         if (!websvcXmlExists()) {
104             l.add(MESSAGE.replaceAll("\\$0", "Webservices.xml file"));
105         }
106         return (String JavaDoc[]) l.toArray(new String JavaDoc[l.size()]);
107     }
108 }
109
Popular Tags