1 25 26 package org.objectweb.jonas_lib.genbase.archive; 27 28 import java.io.File ; 29 import java.io.IOException ; 30 import java.io.InputStream ; 31 import java.util.List ; 32 import java.util.Map ; 33 import java.util.jar.Manifest ; 34 35 import org.objectweb.jonas_lib.I18n; 36 import org.objectweb.jonas_lib.genbase.GenBaseException; 37 import org.objectweb.jonas_lib.genbase.generator.Config; 38 import org.objectweb.jonas_lib.genbase.generator.GeneratorFactories; 39 import org.objectweb.jonas_lib.genbase.generator.GeneratorFactory; 40 41 import org.objectweb.jonas.common.Log; 42 43 import org.objectweb.util.monolog.api.Logger; 44 45 46 52 public abstract class J2EEArchive implements Archive { 53 54 private static I18n i18n = I18n.getInstance(J2EEArchive.class); 55 56 57 private static Logger logger = Log.getLogger(Log.JONAS_GENBASE_PREFIX); 58 59 60 private Archive archive; 61 62 63 private ClassLoader moduleClassloader = null; 64 65 70 public J2EEArchive(Archive archive) { 71 this.archive = archive; 72 } 73 74 79 public void addDirectory(File directory) { 80 archive.addDirectory(directory); 81 } 82 83 90 public void addDirectoryIn(String dirName, File directory) { 91 archive.addDirectoryIn(dirName, directory); 92 } 93 94 99 public void addFile(File file) { 100 archive.addFile(file); 101 } 102 103 109 public void addFile(File file, String name) { 110 archive.addFile(file, name); 111 } 112 113 119 public void addFileIn(String dirName, File file) { 120 archive.addFileIn(dirName, file); 121 } 122 123 128 public File getRootFile() { 129 return archive.getRootFile(); 130 } 131 132 137 public Manifest getManifest() { 138 return archive.getManifest(); 139 } 140 141 150 public InputStream getInputStream(String filename) 151 throws IOException { 152 return archive.getInputStream(filename); 153 } 154 155 161 public List getContainedFiles() { 162 return archive.getContainedFiles(); 163 } 164 165 170 public boolean isPacked() { 171 return archive.isPacked(); 172 } 173 174 179 public String getName() { 180 return archive.getName(); 181 } 182 183 189 public abstract Map getDescriptors(); 190 191 198 public abstract boolean omit(String name); 199 200 203 public static I18n getI18n() { 204 return i18n; 205 } 206 209 public static Logger getLogger() { 210 return logger; 211 } 212 215 public Archive getArchive() { 216 return archive; 217 } 218 221 public void setArchive(Archive archive) { 222 this.archive = archive; 223 } 224 225 229 public abstract void initialize() throws GenBaseException; 230 231 234 public ClassLoader getModuleClassloader() { 235 return moduleClassloader; 236 } 237 238 241 public void setModuleClassloader(ClassLoader moduleClassloader) { 242 this.moduleClassloader = moduleClassloader; 243 } 244 245 248 protected boolean isDTDsAllowed() { 249 GeneratorFactory gf = GeneratorFactories.getCurrentFactory(); 250 if (gf == null) { 251 throw new IllegalStateException (i18n.getMessage("J2EEArchive.isDTDsAllowed.noFactory")); 252 } 253 Config config = gf.getConfiguration(); 254 if (config == null) { 255 throw new IllegalStateException (i18n.getMessage("J2EEArchive.isDTDsAllowed.noConfig")); 256 } 257 return config.isDTDsAllowed(); 258 } 259 260 263 public void close() { 264 try { 265 this.archive.close(); 266 } catch (IOException ioe) { 267 throw new RuntimeException ("Cannot close file '" + archive + "'", ioe); 268 } 269 archive = null; 270 } 271 } 272 | Popular Tags |