1 package com
.google
.apphosting
.utils
.config
;
3 import com
.google
.common
.base
.CharMatcher
;
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 String module
= appEngineWebXml
.getModule();
32 module
= appEngineWebXml
.getService();
34 if (module
== null || CharMatcher
.WHITESPACE
.matchesAllOf(module
)){
41 WebModule(File applicationDirectory
, AppEngineWebXml appEngineWebXml
, File appEngineWebXmlFile
,
42 WebXml webXml
, File webXmlFile
, String contextRoot
) {
43 this.applicationDirectory
= applicationDirectory
;
44 this.appEngineWebXml
= appEngineWebXml
;
45 this.appEngineWebXmlFile
= appEngineWebXmlFile
;
47 this.webXmlFile
= webXmlFile
;
48 this.contextRoot
= contextRoot
;
51 public File
getApplicationDirectory() {
52 return applicationDirectory
;
55 public AppEngineWebXml
getAppEngineWebXml() {
56 return appEngineWebXml
;
59 public File
getAppEngineWebXmlFile() {
60 return appEngineWebXmlFile
;
63 public WebXml
getWebXml() {
67 public File
getWebXmlFile() {
71 public String
getContextRoot() {
76 * Returns the module name specified in {@link #getAppEngineWebXml()} or
77 * {@link #DEFAULT_MODULE_NAME} if none is specified.
79 public String
getModuleName() {
80 return getModuleName(appEngineWebXml
);
84 public int hashCode() {
87 result
= prime
* result
+ ((appEngineWebXml
== null) ?
0 : appEngineWebXml
.hashCode());
88 result
= prime
* result
+ ((appEngineWebXmlFile
== null) ?
0 : appEngineWebXmlFile
.hashCode());
90 prime
* result
+ ((applicationDirectory
== null) ?
0 : applicationDirectory
.hashCode());
91 result
= prime
* result
+ ((contextRoot
== null) ?
0 : contextRoot
.hashCode());
92 result
= prime
* result
+ ((webXml
== null) ?
0 : webXml
.hashCode());
93 result
= prime
* result
+ ((webXmlFile
== null) ?
0 : webXmlFile
.hashCode());
98 public boolean equals(Object obj
) {
105 if (getClass() != obj
.getClass()) {
108 WebModule other
= (WebModule
) obj
;
109 if (appEngineWebXml
== null) {
110 if (other
.appEngineWebXml
!= null) {
113 } else if (!appEngineWebXml
.equals(other
.appEngineWebXml
)) {
116 if (appEngineWebXmlFile
== null) {
117 if (other
.appEngineWebXmlFile
!= null) {
120 } else if (!appEngineWebXmlFile
.equals(other
.appEngineWebXmlFile
)) {
123 if (applicationDirectory
== null) {
124 if (other
.applicationDirectory
!= null) {
127 } else if (!applicationDirectory
.equals(other
.applicationDirectory
)) {
130 if (contextRoot
== null) {
131 if (other
.contextRoot
!= null) {
134 } else if (!contextRoot
.equals(other
.contextRoot
)) {
137 if (webXml
== null) {
138 if (other
.webXml
!= null) {
141 } else if (!webXml
.equals(other
.webXml
)) {
144 if (webXmlFile
== null) {
145 if (other
.webXmlFile
!= null) {
148 } else if (!webXmlFile
.equals(other
.webXmlFile
)) {
155 public String
toString() {
156 return "WebModule: applicationDirectory=" + applicationDirectory
157 + " appEngineWebXml=" + appEngineWebXml
158 + " appEngineWebXmlFile=" + appEngineWebXmlFile
159 + " webXml=" + webXml
160 + " webXmlFile=" + webXmlFile
161 + " contextRoot=" + contextRoot
;