001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.geronimo.j2ee.deployment; 019 020 import java.util.jar.JarFile; 021 import java.net.URI; 022 023 import org.apache.xmlbeans.XmlObject; 024 import org.apache.geronimo.kernel.config.ConfigurationModuleType; 025 import org.apache.geronimo.kernel.repository.Environment; 026 import org.apache.geronimo.deployment.util.DeploymentUtil; 027 import org.apache.geronimo.gbean.AbstractName; 028 029 /** 030 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 031 */ 032 public abstract class Module { 033 private final boolean standAlone; 034 035 private final AbstractName moduleName; 036 private final String name; 037 private final Environment environment; 038 private final URI moduleURI; 039 private final JarFile moduleFile; 040 private final String targetPath; 041 private final URI targetPathURI; 042 private final XmlObject specDD; 043 private final XmlObject vendorDD; 044 private final String originalSpecDD; 045 private final String namespace; 046 047 private EARContext earContext; 048 private EARContext rootEarContext; 049 050 protected Module(boolean standAlone, AbstractName moduleName, Environment environment, JarFile moduleFile, String targetPath, XmlObject specDD, XmlObject vendorDD, String originalSpecDD, String namespace) { 051 assert targetPath != null: "targetPath is null"; 052 assert moduleName != null: "moduleName is null"; 053 054 this.standAlone = standAlone; 055 this.moduleName = moduleName; 056 this.environment = environment; 057 this.moduleFile = moduleFile; 058 this.targetPath = targetPath; 059 this.specDD = specDD; 060 this.vendorDD = vendorDD; 061 this.originalSpecDD = originalSpecDD; 062 this.namespace = namespace; 063 064 if (standAlone) { 065 name = environment.getConfigId().toString(); 066 moduleURI = URI.create(""); 067 } else { 068 name = targetPath; 069 moduleURI = URI.create(targetPath); 070 } 071 072 targetPathURI = URI.create(targetPath + "/"); 073 } 074 075 public abstract ConfigurationModuleType getType(); 076 077 public String getName() { 078 return name; 079 } 080 081 public boolean isStandAlone() { 082 return standAlone; 083 } 084 085 public AbstractName getModuleName() { 086 return moduleName; 087 } 088 089 public Environment getEnvironment() { 090 return environment; 091 } 092 093 public URI getModuleURI() { 094 return moduleURI; 095 } 096 097 public JarFile getModuleFile() { 098 return moduleFile; 099 } 100 101 public String getTargetPath() { 102 return targetPath; 103 } 104 105 public URI getTargetPathURI() { 106 return targetPathURI; 107 } 108 109 public XmlObject getSpecDD() { 110 return specDD; 111 } 112 113 public XmlObject getVendorDD() { 114 return vendorDD; 115 } 116 117 public String getOriginalSpecDD() { 118 return originalSpecDD; 119 } 120 121 public String getNamespace() { 122 return namespace; 123 } 124 125 public int hashCode() { 126 return name.hashCode(); 127 } 128 129 public boolean equals(Object obj) { 130 if (obj == this) { 131 return true; 132 } 133 if (obj instanceof Module) { 134 Module module = (Module) obj; 135 return name.equals(module.name); 136 } 137 return false; 138 } 139 140 public void close() { 141 DeploymentUtil.close(moduleFile); 142 } 143 144 145 public EARContext getEarContext() { 146 return earContext; 147 } 148 149 public void setEarContext(EARContext earContext) { 150 this.earContext = earContext; 151 } 152 153 public EARContext getRootEarContext() { 154 return rootEarContext; 155 } 156 157 public void setRootEarContext(EARContext rootEarContext) { 158 this.rootEarContext = rootEarContext; 159 } 160 }