1 package com
.google
.apphosting
.utils
.config
;
3 import com
.google
.common
.collect
.ImmutableList
;
4 import com
.google
.common
.collect
.ImmutableMap
;
9 import java
.util
.logging
.Logger
;
12 * Holder for information from an EAR directory.
15 public class EarInfo
{
16 private static final Logger LOGGER
= Logger
.getLogger(EarInfo
.class.getName());
18 private final File earDirectory
;
19 private final AppEngineApplicationXml appEngineApplicationXml
;
20 private final ApplicationXml applicationXml
;
21 private final List
<WebModule
> webModules
;
22 private final Map
<String
, WebModule
> moduleMap
;
24 EarInfo(File earDirectory
, AppEngineApplicationXml appEngineApplicationXml
,
25 ApplicationXml applicationXml
, List
<WebModule
> webModules
)
26 throws AppEngineConfigException
{
27 this.earDirectory
= earDirectory
;
28 this.appEngineApplicationXml
= appEngineApplicationXml
;
29 this.applicationXml
= applicationXml
;
30 this.webModules
= ImmutableList
.copyOf(webModules
.iterator());
32 ImmutableMap
.Builder
<String
, WebModule
> builder
= ImmutableMap
.builder();
33 for (WebModule webModule
: webModules
) {
34 builder
.put(webModule
.getModuleName(), webModule
);
37 moduleMap
= builder
.build();
38 } catch (IllegalArgumentException iae
) {
39 if (iae
.getMessage().startsWith("duplicate key: ")) {
40 String msg
= "Invalid EAR - Duplicate module name";
42 throw new AppEngineConfigException(msg
, iae
);
49 public File
getEarDirectory() {
53 public ApplicationXml
getApplicationXml() {
54 return applicationXml
;
57 public AppEngineApplicationXml
getAppengineApplicationXml() {
58 return appEngineApplicationXml
;
61 public List
<WebModule
> getWebModules() {
65 WebModule
getWebModule(String moduleName
) {
66 return moduleMap
.get(moduleName
);
70 public int hashCode() {
73 result
= prime
* result
74 + ((appEngineApplicationXml
== null) ?
0 : appEngineApplicationXml
.hashCode());
75 result
= prime
* result
+ ((applicationXml
== null) ?
0 : applicationXml
.hashCode());
76 result
= prime
* result
+ ((earDirectory
== null) ?
0 : earDirectory
.hashCode());
77 result
= prime
* result
+ ((webModules
== null) ?
0 : webModules
.hashCode());
82 public boolean equals(Object obj
) {
89 if (getClass() != obj
.getClass()) {
92 EarInfo other
= (EarInfo
) obj
;
93 if (appEngineApplicationXml
== null) {
94 if (other
.appEngineApplicationXml
!= null) {
97 } else if (!appEngineApplicationXml
.equals(other
.appEngineApplicationXml
)) {
100 if (applicationXml
== null) {
101 if (other
.applicationXml
!= null) {
104 } else if (!applicationXml
.equals(other
.applicationXml
)) {
107 if (earDirectory
== null) {
108 if (other
.earDirectory
!= null) {
111 } else if (!earDirectory
.equals(other
.earDirectory
)) {
114 if (webModules
== null) {
115 if (other
.webModules
!= null) {
118 } else if (!webModules
.equals(other
.webModules
)) {
125 public String
toString() {
126 return "EarInfo: earDirectory=" + earDirectory
127 + " appEngineApplicationXml=" + appEngineApplicationXml
128 + " applicationXml=" + applicationXml
129 + " webModules=" + webModules
;