KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > j2ee > deployment > Module


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.j2ee.deployment;
18
19 import java.util.jar.JarFile JavaDoc;
20 import java.net.URI JavaDoc;
21
22 import org.apache.xmlbeans.XmlObject;
23 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
24 import org.apache.geronimo.kernel.repository.Environment;
25 import org.apache.geronimo.deployment.util.DeploymentUtil;
26 import org.apache.geronimo.gbean.AbstractName;
27
28 /**
29  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
30  */

31 public abstract class Module {
32     private final boolean standAlone;
33
34     private final AbstractName moduleName;
35     private final String JavaDoc name;
36     private final Environment environment;
37     private final URI JavaDoc moduleURI;
38     private final JarFile JavaDoc moduleFile;
39     private final String JavaDoc targetPath;
40     private final URI JavaDoc targetPathURI;
41     private final XmlObject specDD;
42     private final XmlObject vendorDD;
43     private final String JavaDoc originalSpecDD;
44     private final String JavaDoc namespace;
45
46     private EARContext earContext;
47     private EARContext rootEarContext;
48
49     protected Module(boolean standAlone, AbstractName moduleName, Environment environment, JarFile JavaDoc moduleFile, String JavaDoc targetPath, XmlObject specDD, XmlObject vendorDD, String JavaDoc originalSpecDD, String JavaDoc namespace) {
50         assert targetPath != null: "targetPath is null";
51         assert moduleName != null: "moduleName is null";
52
53         this.standAlone = standAlone;
54         this.moduleName = moduleName;
55         this.environment = environment;
56         this.moduleFile = moduleFile;
57         this.targetPath = targetPath;
58         this.specDD = specDD;
59         this.vendorDD = vendorDD;
60         this.originalSpecDD = originalSpecDD;
61         this.namespace = namespace;
62
63         if (standAlone) {
64             name = environment.getConfigId().toString();
65             moduleURI = URI.create("");
66         } else {
67             name = targetPath;
68             moduleURI = URI.create(targetPath);
69         }
70
71         targetPathURI = URI.create(targetPath + "/");
72     }
73
74     public abstract ConfigurationModuleType getType();
75
76     public String JavaDoc getName() {
77         return name;
78     }
79
80     public boolean isStandAlone() {
81         return standAlone;
82     }
83
84     public AbstractName getModuleName() {
85         return moduleName;
86     }
87
88     public Environment getEnvironment() {
89         return environment;
90     }
91
92     public URI JavaDoc getModuleURI() {
93         return moduleURI;
94     }
95
96     public JarFile JavaDoc getModuleFile() {
97         return moduleFile;
98     }
99
100     public String JavaDoc getTargetPath() {
101         return targetPath;
102     }
103
104     public URI JavaDoc getTargetPathURI() {
105         return targetPathURI;
106     }
107
108     public XmlObject getSpecDD() {
109         return specDD;
110     }
111
112     public XmlObject getVendorDD() {
113         return vendorDD;
114     }
115
116     public String JavaDoc getOriginalSpecDD() {
117         return originalSpecDD;
118     }
119
120     public String JavaDoc getNamespace() {
121         return namespace;
122     }
123
124     public int hashCode() {
125         return name.hashCode();
126     }
127
128     public boolean equals(Object JavaDoc obj) {
129         if (obj == this) {
130             return true;
131         }
132         if (obj instanceof Module) {
133             Module module = (Module) obj;
134             return name.equals(module.name);
135         }
136         return false;
137     }
138
139     public void close() {
140         DeploymentUtil.close(moduleFile);
141     }
142
143
144     public EARContext getEarContext() {
145         return earContext;
146     }
147
148     public void setEarContext(EARContext earContext) {
149         this.earContext = earContext;
150     }
151
152     public EARContext getRootEarContext() {
153         return rootEarContext;
154     }
155
156     public void setRootEarContext(EARContext rootEarContext) {
157         this.rootEarContext = rootEarContext;
158     }
159 }
160
Popular Tags