1 package com
.google
.apphosting
.utils
.config
;
3 import com
.google
.common
.base
.StringUtil
;
8 * Holder for information for a web module extracted from the module's
9 * on disk application directory.
12 public class WebModule
{
14 * Default value for a module name.
16 public static final String DEFAULT_MODULE_NAME
= "default";
18 private final File applicationDirectory
;
19 private final AppEngineWebXml appEngineWebXml
;
20 private final File appEngineWebXmlFile
;
21 private final WebXml webXml
;
22 private final File webXmlFile
;
23 private final String contextRoot
;
26 * Returns the server name specified in {@link #getAppEngineWebXml()} or
27 * {@link #DEFAULT_SERVER_NAME} if none is specified.
29 public static String
getModuleName(AppEngineWebXml appEngineWebXml
) {
30 return StringUtil
.isEmptyOrWhitespace(appEngineWebXml
.getModule()) ?
31 "default" : appEngineWebXml
.getModule().trim();
34 WebModule(File applicationDirectory
, AppEngineWebXml appEngineWebXml
, File appEngineWebXmlFile
,
35 WebXml webXml
, File webXmlFile
, String contextRoot
) {
36 this.applicationDirectory
= applicationDirectory
;
37 this.appEngineWebXml
= appEngineWebXml
;
38 this.appEngineWebXmlFile
= appEngineWebXmlFile
;
40 this.webXmlFile
= webXmlFile
;
41 this.contextRoot
= contextRoot
;
44 public File
getApplicationDirectory() {
45 return applicationDirectory
;
48 public AppEngineWebXml
getAppEngineWebXml() {
49 return appEngineWebXml
;
52 public File
getAppEngineWebXmlFile() {
53 return appEngineWebXmlFile
;
56 public WebXml
getWebXml() {
60 public File
getWebXmlFile() {
64 public String
getContextRoot() {
69 * Returns the module name specified in {@link #getAppEngineWebXml()} or
70 * {@link #DEFAULT_MODULE_NAME} if none is specified.
72 public String
getModuleName() {
73 return getModuleName(appEngineWebXml
);
77 public int hashCode() {
80 result
= prime
* result
+ ((appEngineWebXml
== null) ?
0 : appEngineWebXml
.hashCode());
81 result
= prime
* result
+ ((appEngineWebXmlFile
== null) ?
0 : appEngineWebXmlFile
.hashCode());
83 prime
* result
+ ((applicationDirectory
== null) ?
0 : applicationDirectory
.hashCode());
84 result
= prime
* result
+ ((contextRoot
== null) ?
0 : contextRoot
.hashCode());
85 result
= prime
* result
+ ((webXml
== null) ?
0 : webXml
.hashCode());
86 result
= prime
* result
+ ((webXmlFile
== null) ?
0 : webXmlFile
.hashCode());
91 public boolean equals(Object obj
) {
98 if (getClass() != obj
.getClass()) {
101 WebModule other
= (WebModule
) obj
;
102 if (appEngineWebXml
== null) {
103 if (other
.appEngineWebXml
!= null) {
106 } else if (!appEngineWebXml
.equals(other
.appEngineWebXml
)) {
109 if (appEngineWebXmlFile
== null) {
110 if (other
.appEngineWebXmlFile
!= null) {
113 } else if (!appEngineWebXmlFile
.equals(other
.appEngineWebXmlFile
)) {
116 if (applicationDirectory
== null) {
117 if (other
.applicationDirectory
!= null) {
120 } else if (!applicationDirectory
.equals(other
.applicationDirectory
)) {
123 if (contextRoot
== null) {
124 if (other
.contextRoot
!= null) {
127 } else if (!contextRoot
.equals(other
.contextRoot
)) {
130 if (webXml
== null) {
131 if (other
.webXml
!= null) {
134 } else if (!webXml
.equals(other
.webXml
)) {
137 if (webXmlFile
== null) {
138 if (other
.webXmlFile
!= null) {
141 } else if (!webXmlFile
.equals(other
.webXmlFile
)) {
148 public String
toString() {
149 return "WebModule: applicationDirectory=" + applicationDirectory
150 + " appEngineWebXml=" + appEngineWebXml
151 + " appEngineWebXmlFile=" + appEngineWebXmlFile
152 + " webXml=" + webXml
153 + " webXmlFile=" + webXmlFile
154 + " contextRoot=" + contextRoot
;