01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.j2ee.deployment;
17:
18: import java.util.jar.JarFile;
19:
20: import org.apache.geronimo.gbean.AbstractName;
21: import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
22: import org.apache.geronimo.kernel.config.ConfigurationModuleType;
23: import org.apache.geronimo.kernel.repository.Environment;
24: import org.apache.xmlbeans.XmlObject;
25:
26: /**
27: * @version $Rev: 539957 $ $Date: 2007-05-20 14:55:49 -0700 (Sun, 20 May 2007) $
28: */
29: public class WebModule extends Module {
30: private final String contextRoot;
31: public static final String WEB_APP_DATA = "WEB_APP_DATA";
32:
33: public WebModule(boolean standAlone, AbstractName moduleName,
34: Environment environment, JarFile moduleFile,
35: String targetPath, XmlObject specDD, XmlObject vendorDD,
36: String originalSpecDD, String contextRoot,
37: String namespace, AnnotatedWebApp annotatedWebApp) {
38: super (standAlone, moduleName, environment, moduleFile,
39: targetPath, specDD, vendorDD, originalSpecDD,
40: namespace, annotatedWebApp);
41: this .contextRoot = contextRoot;
42: }
43:
44: public String getContextRoot() {
45: return contextRoot;
46: }
47:
48: public ConfigurationModuleType getType() {
49: return ConfigurationModuleType.WAR;
50: }
51:
52: public String getRelativePath(String path) {
53: if (isStandAlone()) {
54: return path;
55: }
56: if (path.startsWith(getTargetPath())) {
57: //in the war, remove war path and leading '/'
58: path = path.substring(getTargetPath().length() + 1);
59: } else {
60: //outside war, add enough '../' to get to ear root
61: for (int j = 0; j < getTargetPath().split("/").length; j++) {
62: path = "../" + path;
63: }
64: }
65: return path;
66: }
67:
68: }
|