KickJava   Java API By Example, From Geeks To Geeks.

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


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 Micro//Systems, Inc. Portions Copyright 1997-2006 Sun
17  * Micro//Systems, Inc. All Rights Reserved.
18  */

19 /*
20  * Ejb.java
21  *
22  * Created on May 24, 2005, 6:01 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
36 /**
37  *
38  * @author jungi
39  */

40 public final class Ejb extends AbstractJ2eeFile {
41
42     static final String JavaDoc IMPL = "Bean";
43     static final String JavaDoc INTF = "Business";
44     static final String JavaDoc HOME = "Home";
45     static final String JavaDoc LOCAL = "Local";
46     static final String JavaDoc REMOTE = "Remote";
47     private boolean isLocal;
48     private boolean isRemote;
49     //private boolean isStateles;
50
private String JavaDoc beanImpl;
51     
52     /** Creates a new instance of Ejb */
53     public Ejb(String JavaDoc fqName, Project p, boolean local, boolean remote) {
54         super(fqName, p);
55         isLocal = local;
56         isRemote = remote;
57         beanImpl = name + IMPL;
58     }
59     
60     public Ejb(String JavaDoc fqName, Project p, boolean local,
61             boolean remote, String JavaDoc srcRoot) {
62         super(fqName, p, srcRoot);
63         isLocal = local;
64         isRemote = remote;
65         beanImpl = name + IMPL;
66     }
67     
68     public String JavaDoc[] checkExistingFiles() {
69         List JavaDoc l = new ArrayList JavaDoc();
70         if (!implClassExists()) {
71             l.add(MESSAGE.replaceAll("\\$0", "Bean impl class"));
72         }
73         if (isLocal) {
74             if (!localIntfExists()) {
75                 l.add(MESSAGE.replaceAll("\\$0", "Local interface class"));
76             }
77             if (!localBusIntfExists()) {
78                 l.add(MESSAGE.replaceAll("\\$0", "Local business interface class"));
79             }
80             if (!localHomeIntfExists()) {
81                 l.add(MESSAGE.replaceAll("\\$0", "Local home interface class"));
82             }
83         }
84         if (isRemote) {
85             if (!remoteIntfExists()) {
86                 l.add(MESSAGE.replaceAll("\\$0", "Remote interface class"));
87             }
88             if (!remoteBusIntfExists()) {
89                 l.add(MESSAGE.replaceAll("\\$0", "Remote business interface class"));
90             }
91             if (!remoteHomeIntfExists()) {
92                 l.add(MESSAGE.replaceAll("\\$0", "Remote home interface class"));
93             }
94         }
95         return (String JavaDoc[]) l.toArray(new String JavaDoc[l.size()]);
96     }
97     
98     private boolean implClassExists() {
99         String JavaDoc res = pkgName.replace('.', File.separatorChar) + beanImpl + ".java";
100         //System.err.println("name: " + name);
101
//System.err.println("impl: " + res);
102
return srcFileExist(res);
103     }
104     
105     private boolean localIntfExists() {
106         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + LOCAL + ".java";
107         //System.err.println("intf: " + res);
108
return srcFileExist(res);
109     }
110     
111     private boolean localBusIntfExists() {
112         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + LOCAL + INTF + ".java";
113         //System.err.println("intf: " + res);
114
return srcFileExist(res);
115     }
116     
117     private boolean localHomeIntfExists() {
118         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + LOCAL + HOME + ".java";
119         //System.err.println("intf: " + res);
120
return srcFileExist(res);
121     }
122     
123     private boolean remoteIntfExists() {
124         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + REMOTE + ".java";
125         //System.err.println("intf: " + res);
126
return srcFileExist(res);
127     }
128     
129     private boolean remoteBusIntfExists() {
130         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + REMOTE + INTF + ".java";
131         //System.err.println("intf: " + res);
132
return srcFileExist(res);
133     }
134     
135     private boolean remoteHomeIntfExists() {
136         String JavaDoc res = pkgName.replace('.', File.separatorChar) + name + REMOTE + HOME + ".java";
137         //System.err.println("intf: " + res);
138
return srcFileExist(res);
139     }
140 }
141
Popular Tags