1 17 package org.apache.geronimo.j2ee.deployment; 18 19 import java.util.jar.JarFile ; 20 import java.net.URI ; 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 31 public abstract class Module { 32 private final boolean standAlone; 33 34 private final AbstractName moduleName; 35 private final String name; 36 private final Environment environment; 37 private final URI moduleURI; 38 private final JarFile moduleFile; 39 private final String targetPath; 40 private final URI targetPathURI; 41 private final XmlObject specDD; 42 private final XmlObject vendorDD; 43 private final String originalSpecDD; 44 private final String namespace; 45 46 private EARContext earContext; 47 private EARContext rootEarContext; 48 49 protected Module(boolean standAlone, AbstractName moduleName, Environment environment, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD, String 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 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 getModuleURI() { 93 return moduleURI; 94 } 95 96 public JarFile getModuleFile() { 97 return moduleFile; 98 } 99 100 public String getTargetPath() { 101 return targetPath; 102 } 103 104 public URI 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 getOriginalSpecDD() { 117 return originalSpecDD; 118 } 119 120 public String getNamespace() { 121 return namespace; 122 } 123 124 public int hashCode() { 125 return name.hashCode(); 126 } 127 128 public boolean equals(Object 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 |