KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > archive > EarPlan


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  * Paul Mahar
22  *
23  */

24 package org.enhydra.tool.archive;
25
26 // Toolbox Imports
27
import org.enhydra.tool.common.FileUtil;
28 import org.enhydra.tool.common.PathHandle;
29 import org.enhydra.tool.common.ResUtil;
30
31 // Standard imports
32
import java.io.File JavaDoc;
33 import java.io.FileFilter JavaDoc;
34 import java.util.ResourceBundle JavaDoc;
35 import java.util.Arrays JavaDoc;
36 import java.util.ArrayList JavaDoc;
37
38 //
39
public class EarPlan extends JarPlan {
40
41     //
42
private String JavaDoc appName = new String JavaDoc();
43     private String JavaDoc appDesc = "Application description"; // default
44
private String JavaDoc[] eModules = new String JavaDoc[0];
45     private WebApplication[] webApps = new WebApplication[0];
46     private boolean alt = false;
47     private boolean copyClient = true;
48
49     public EarPlan() {}
50
51     public boolean isAlt() {
52         return alt;
53     }
54
55     public void setAlt(boolean a) {
56         alt = a;
57     }
58
59     public boolean isCopyClient() {
60         return copyClient;
61     }
62
63     public void setCopyClient(boolean c) {
64         copyClient = c;
65     }
66
67     public String JavaDoc getAppName() {
68         return appName;
69     }
70
71     public void setAppName(String JavaDoc n) {
72         appName = n;
73     }
74
75     public String JavaDoc getDescription() {
76         return appDesc;
77     }
78
79     public void setDescription(String JavaDoc d) {
80         appDesc = d.replace('\n', ' ');
81     }
82
83     public String JavaDoc[] getEnterpriseModules() {
84         return eModules;
85     }
86
87     public void setEnterpriseModules(String JavaDoc[] in) {
88         eModules = in;
89     }
90
91     public WebApplication[] getWebApplications() {
92         return webApps;
93     }
94
95     public void setWebApplications(WebApplication[] apps) {
96         webApps = apps;
97     }
98
99     public void addWebApplication(String JavaDoc war) {
100         ArrayList JavaDoc list = null;
101
102         list = new ArrayList JavaDoc(Arrays.asList(webApps));
103         list.add(new WebApplication(war));
104         list.trimToSize();
105         webApps = new WebApplication[list.size()];
106         webApps = (WebApplication[]) list.toArray(webApps);
107         list.clear();
108     }
109
110     public void addEnterpriseModule(String JavaDoc mod) {
111         ArrayList JavaDoc list = null;
112
113         list = new ArrayList JavaDoc(Arrays.asList(eModules));
114         list.add(mod);
115         list.trimToSize();
116         eModules = new String JavaDoc[list.size()];
117         eModules = (String JavaDoc[]) list.toArray(eModules);
118         list.clear();
119     }
120
121     public Module[] getAllModules() {
122         ArrayList JavaDoc list = new ArrayList JavaDoc();
123         String JavaDoc[] ePaths = getEnterpriseModules();
124         Module[] mods = new Module[ePaths.length];
125
126         for (int i = 0; i < mods.length; i++) {
127             mods[i] = new Module(ePaths[i]);
128         }
129         list.addAll(Arrays.asList(mods));
130         list.addAll(Arrays.asList(getWebApplications()));
131         list.trimToSize();
132         mods = new Module[list.size()];
133         mods = (Module[]) list.toArray(mods);
134         list.clear();
135         return mods;
136     }
137
138     public boolean equals(Object JavaDoc comp) {
139         EarPlan plan = null;
140         boolean equal = false;
141
142         if (comp instanceof EarPlan) {
143             plan = (EarPlan) comp;
144             equal = super.equals(comp);
145         }
146         if (equal) {
147             if (plan.getAppName() == null && getAppName() == null) {}
148             else if (plan.getAppName().equals(getAppName())) {}
149             else {
150                 equal = false;
151             }
152         }
153         if (equal) {
154             if (plan.getDescription() == null && getDescription() == null) {}
155             else if (plan.getDescription().equals(getDescription())) {}
156             else {
157                 equal = false;
158             }
159         }
160         if (equal) {
161             if (!(plan.isAlt() == isAlt())) {
162                 equal = false;
163             }
164         }
165         if (equal) {
166             if (!(plan.isCopyClient() == isCopyClient())) {
167                 equal = false;
168             }
169         }
170         if (equal) {
171             if (!Arrays.equals(plan.getWebApplications(),
172                                getWebApplications())) {
173                 equal = false;
174             }
175         }
176         if (equal) {
177             if (!Arrays.equals(plan.getEnterpriseModules(),
178                                getEnterpriseModules())) {
179                 equal = false;
180             }
181         }
182         return equal;
183     }
184
185 }
186
Popular Tags