KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > instance > ModuleEnvironment


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.instance;
25
26 //iAS imports
27
import com.sun.enterprise.util.StringUtils;
28 import com.sun.enterprise.util.diagnostics.Reminder;
29 import com.sun.enterprise.deployment.backend.DeployableObjectType;
30
31 /**
32     Represents the environment of a standalone module to be deployed to
33     given Server Instance.
34     @author Kedar
35     @version 1.0
36 */

37
38 public class ModuleEnvironment {
39     //public static final int kEJBModule = 0;
40
//public static final int kWebModule = 1;
41
private String JavaDoc mModuleName = null;
42     private String JavaDoc mModulePath = null;
43     private String JavaDoc mModuleBackupPath = null;
44     private String JavaDoc mModuleGeneratedXMLPath = null;
45     private String JavaDoc mJavaWebStartPath = null;
46     private String JavaDoc mModuleStubPath = null;
47     private String JavaDoc mModuleJSPPath = null;
48     private InstanceEnvironment mInstance = null;
49     private DeployableObjectType mType = null;
50 /*
51  *
52     public ModuleEnvironment (InstanceEnvironment instance, String moduleName,
53         int type) {
54         if (instance == null || moduleName == null) {
55             throw new IllegalArgumentException();
56         }
57         if (type!= kEJBModule && type != kWebModule) {
58             throw new IllegalArgumentException();
59         }
60         mInstance = instance;
61         mModuleName = moduleName;
62         createModulePath();
63         createModuleStubPath();
64         
65         if(type == kEJBModule)
66             mType = DeployableObjectType.EJB;
67
68         else if(type == kWebModule)
69             mType = DeployableObjectType.WEB;
70         
71         else
72             throw new IllegalArgumentException();
73         
74         Reminder.message("DEPRECTAED API -- use the other constructor for ModuleEnvironment");
75     }
76
77  */

78     /**
79         Creates new ModuleEnvironment.
80         @param instance InstanceEnvironment representing the Server Instance in which this
81         module is to be deployed.
82         @param moduleName String representing name of this module.
83         @type the type of module - has to be WEB, EJB or RES
84         
85         @throws IllegalArgumentException if instance or moduleName is null or
86         type is not one of the supported ones.
87     */

88     
89     public ModuleEnvironment (InstanceEnvironment instance, String JavaDoc moduleName,
90         DeployableObjectType type) {
91         if (instance == null || moduleName == null) {
92             throw new IllegalArgumentException JavaDoc();
93         }
94         
95         if(type == null) { // impossible to have an invalid module type (except null!!)
96
throw new IllegalArgumentException JavaDoc(Localizer.getValue(ExceptionType.NULL_MODULE_TYPE));
97         }
98         
99         mType = type;
100         mInstance = instance;
101         mModuleName = moduleName;
102         createModulePath();
103         createModuleBackupPath();
104         createModuleStubPath();
105         createModuleJSPPath();
106         createModuleGeneratedXMLPath();
107         createJavaWebStartPath();
108     }
109     
110     private void createModulePath() {
111         String JavaDoc moduleRepositoryDirPath = mInstance.getModuleRepositoryPath ();
112         String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
113             moduleRepositoryDirPath,
114             mModuleName
115             };
116         mModulePath = StringUtils.makeFilePath (onlyFolderNames, false);
117     }
118     
119     /**
120         Returns the absolute path for the all the elements within this module.
121         Note that it does not create/check file/directory with such a path.
122     */

123     
124     public String JavaDoc getModulePath() {
125         return mModulePath;
126     }
127     
128     /**
129         Returns the absolute path for storing all the generated xml of this module.
130         Note that it does not create/check file/directory with such a path.
131     */

132     
133     public void createModuleGeneratedXMLPath() {
134         String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
135             mInstance.getModuleGeneratedXMLPath(),
136             mModuleName
137         };
138         
139         mModuleGeneratedXMLPath = StringUtils.makeFilePath (onlyFolderNames, false);
140     }
141
142     /**
143         Returns the absolute path for the all the generated xml within this module.
144         Note that it does not create/check file/directory with such a path.
145     */

146     
147     public String JavaDoc getModuleGeneratedXMLPath() {
148         return mModuleGeneratedXMLPath;
149     }
150
151
152         /**
153                 Creates the path to this application's java-web-start directory.
154         */

155
156         private void createJavaWebStartPath() {
157                String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
158                        mInstance.getJavaWebStartPath(),
159                        mModuleName
160                };
161
162                mJavaWebStartPath = StringUtils.makeFilePath (onlyFolderNames, false);
163         }
164
165         /**
166                 Returns the absolute path to the Java Web Start directory for this application.
167                 Note that it does not create/check file/directory with such a path.
168         */

169
170         public String JavaDoc getJavaWebStartPath() {
171             return mJavaWebStartPath;
172         }
173
174         /**
175                 Returns the absolute path for storing all the stubs of this module.
176                 Note that it does not create/check file/directory with such a path.
177         */

178
179         public void createModuleStubPath() {
180                 String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
181                         mInstance.getModuleStubPath(),
182                         mModuleName
183                 };
184
185                 mModuleStubPath = StringUtils.makeFilePath (onlyFolderNames, false);
186         }
187         /**
188                 Returns the absolute path for the all the stubs within this module.
189                 Note that it does not create/check file/directory with such a path.
190         */

191
192         public String JavaDoc getModuleStubPath() {
193                 return mModuleStubPath;
194         }
195
196
197     
198     /**
199         Creates the absolute path for storing the generated JSPs of this module.
200         Note that it does not create/check file/directory with such a path.
201     */

202     
203     public void createModuleJSPPath() {
204         String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
205             mInstance.getWebModuleCompileJspPath(),
206             mModuleName
207         };
208         
209         mModuleJSPPath = StringUtils.makeFilePath (onlyFolderNames, false);
210     }
211     /**
212         Returns the absolute path for the generated JSPs from this module.
213     */

214     
215     public String JavaDoc getModuleJSPPath() {
216         return mModuleJSPPath;
217     }
218
219     /**
220         Returns the absolute path for the backup path for this directory-deployed module
221         Note that it does not create/check file/directory with such a path.
222     */

223     
224     public String JavaDoc getModuleBackupPath() {
225         return mModuleBackupPath;
226     }
227     /**
228         Returns the absolute path for the backup path for this directory-deployed module
229         Note that it does not create/check file/directory with such a path.
230     */

231     
232     public void createModuleBackupPath() {
233         String JavaDoc[] onlyFolderNames = new String JavaDoc[] {
234             mInstance.getModuleBackupRepositoryPath(),
235             mModuleName
236         };
237         
238         mModuleBackupPath = StringUtils.makeFilePath (onlyFolderNames, false);
239     }
240
241
242     /** return a String with the error, in English, if the required
243         directories aren't there or have a problem.
244         return null if all is OK
245      */

246     public String JavaDoc verify()
247     {
248             return null;
249     }
250 }
251
Popular Tags