KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > util > ModuleDescriptor


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.deployment.util;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.Vector JavaDoc;
28 import java.util.jar.Manifest JavaDoc;
29 import java.io.IOException JavaDoc;
30
31 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
32
33 import com.sun.enterprise.deployment.Descriptor;
34 import com.sun.enterprise.deployment.BundleDescriptor;
35 import com.sun.enterprise.deployment.DeploymentExtensionDescriptor;
36
37 /**
38  * This class describes a module information for an applicaiton module
39  *
40  * @author Jerome Dochez
41  * @version
42  */

43 public class ModuleDescriptor extends Descriptor {
44
45     /**
46      * type of the module, currently EJB, WEB...
47      */

48     private ModuleType JavaDoc type;
49     
50     /**
51      * path for the module bundle
52      */

53     private String JavaDoc path;
54     
55     /**
56      * alternate descriptor (if any) path
57      */

58     private String JavaDoc altDD;
59     
60     /**
61      * context-root if dealing with a web module
62      */

63     private String JavaDoc contextRoot;
64     
65     /**
66      * loaded deployment descriptor for this module
67      */

68     private BundleDescriptor descriptor;
69     
70     /**
71      * manifest information for this module
72      */

73     private Manifest JavaDoc manifest;
74     
75     /**
76      * is it a standalone module, or part of a J2EE Application
77      */

78     private boolean standalone=false;
79     
80     /** Creates new ModuleDescriptor */
81     public ModuleDescriptor() {
82     }
83
84     public void setModuleType(ModuleType JavaDoc type) {
85         this.type = type;
86     }
87     
88     
89     /**
90      * @return the module type for this module
91      */

92     public ModuleType JavaDoc getModuleType() {
93         if (descriptor!=null) {
94             return descriptor.getModuleType();
95         }
96         return type;
97     }
98     
99     /**
100      * Sets the archive uri as defined in the application xml
101      * or the full archive path for standalone modules
102      * @path the module path
103      */

104     public void setArchiveUri(String JavaDoc path) {
105         this.path = path;
106     }
107     
108     /**
109      * @return the archive uri for this module
110      */

111     public String JavaDoc getArchiveUri() {
112         return path;
113     }
114     
115     /**
116      * Sets the path to the alternate deployment descriptors
117      * in the application archive
118      * @param altDD the uri for the deployment descriptors
119      */

120     public void setAlternateDescriptor(String JavaDoc altDD) {
121         this.altDD = altDD;
122     }
123     
124     /**
125      * @return the alternate deployment descriptor path
126      * or null if this module does not use alternate
127      * deployment descriptors
128      */

129     public String JavaDoc getAlternateDescriptor() {
130         return altDD;
131     }
132     
133     /**
134      * Sets the @see BundleDescriptor descriptor for this
135      * module
136      * @param descriptor the module descriptor
137      */

138     public void setDescriptor(BundleDescriptor descriptor) {
139         descriptor.setModuleDescriptor(this);
140         this.descriptor = descriptor;
141     }
142     
143     /**
144      * @return the @see BundleDescriptor module descriptor
145      */

146     public BundleDescriptor getDescriptor() {
147         return descriptor;
148     }
149     
150     /**
151      * Sets the context root for Web module
152      * @param contextRoot the contextRoot
153      */

154     public void setContextRoot(String JavaDoc contextRoot) {
155         this.contextRoot = contextRoot;
156     }
157     
158     /**
159      * @return the context root for a web module
160      */

161     public String JavaDoc getContextRoot() {
162         return contextRoot;
163     }
164     
165     /**
166      * @return the @see Manifest manifest information
167      * for this module
168      */

169     public Manifest JavaDoc getManifest() {
170         return manifest;
171     }
172     
173     /**
174      * Sets the @see Manifest manifest information for this
175      * module
176      */

177     public void setManifest(Manifest JavaDoc m) {
178         manifest = m;
179     }
180     
181     /**
182      * @return true if this module is a standalone module
183      */

184     public boolean isStandalone() {
185         return standalone;
186     }
187     
188     /**
189      * Sets the standalone flag
190      */

191     public void setStandalone(boolean standalone) {
192         this.standalone = standalone;
193     }
194     
195     /**
196      * Add a new deployment-extension for this descriptor
197      * @param deployment-extension descriptor to add
198      */

199     public void addWebDeploymentExtension(DeploymentExtensionDescriptor de) {
200         Vector JavaDoc extensions = (Vector JavaDoc) getExtraAttribute("web-deployment-extension");
201         if (extensions==null) {
202             extensions = new Vector JavaDoc();
203             addExtraAttribute("web-deployment-extension", extensions);
204         }
205         extensions.add(de);
206     }
207     
208     /**
209      * @return an iterator on the deployment-extension
210      */

211     public Iterator JavaDoc getWebDeploymentExtensions() {
212         Vector JavaDoc extensions = (Vector JavaDoc) getExtraAttribute("web-deployment-extension");
213         if (extensions!=null) {
214             return extensions.iterator();
215         }
216         return null;
217     }
218     
219     
220     /**
221      * @return a meaningful string about myself
222      */

223     public void print(StringBuffer JavaDoc toStringBuffer) {
224         toStringBuffer.append(type + " ModuleDescriptor: [ " + path + " ] , altDD = " + altDD);
225         if (contextRoot!=null) {
226             toStringBuffer.append(" , ContextRoot = " + contextRoot);
227         }
228     }
229     
230     
231     /**
232      * Implementation of the serializable interface since ModuleType is not
233      * serializable
234      */

235     private void writeObject(java.io.ObjectOutputStream JavaDoc out)
236      throws IOException JavaDoc {
237                  
238          // just write this intance fields...
239
out.writeObject(path);
240          out.writeObject(altDD);
241          out.writeObject(contextRoot);
242          out.writeObject(descriptor);
243          out.writeObject(manifest);
244          out.writeBoolean(standalone);
245     }
246     
247     private void readObject(java.io.ObjectInputStream JavaDoc in)
248      throws IOException JavaDoc, ClassNotFoundException JavaDoc {
249                 
250          // just read this intance fields...
251
path = (String JavaDoc) in.readObject();
252          altDD = (String JavaDoc) in.readObject();
253          contextRoot = (String JavaDoc) in.readObject();
254          descriptor = (BundleDescriptor) in.readObject();
255          manifest = (Manifest JavaDoc) in.readObject();
256          standalone = in.readBoolean();
257     }
258 }
259
Popular Tags