1 25 26 package org.objectweb.jonas_lib.genbase.modifier; 27 28 import java.io.File ; 29 30 import org.objectweb.jonas_lib.genbase.GenBaseException; 31 import org.objectweb.jonas_lib.genbase.archive.Archive; 32 import org.objectweb.jonas_lib.genbase.archive.FileArchive; 33 import org.objectweb.jonas_lib.genbase.archive.J2EEArchive; 34 import org.objectweb.jonas_lib.genbase.archive.JarArchive; 35 import org.objectweb.jonas_lib.genbase.generator.Config; 36 import org.objectweb.jonas_lib.genbase.utils.ArchiveStorer; 37 import org.objectweb.jonas_lib.genbase.utils.DirStorer; 38 import org.objectweb.jonas_lib.genbase.utils.JarStorer; 39 40 import org.objectweb.jonas.common.Log; 41 42 import org.objectweb.util.monolog.api.BasicLevel; 43 import org.objectweb.util.monolog.api.Logger; 44 45 49 public abstract class ArchiveModifier { 50 51 54 private J2EEArchive archive; 55 56 57 private static Logger logger = Log.getLogger(Log.JONAS_GENBASE_PREFIX); 58 59 63 public ArchiveModifier(J2EEArchive archive) { 64 this.archive = archive; 65 } 66 67 72 public abstract Archive modify() throws GenBaseException; 73 74 82 protected static Archive save(Config config, String outname, J2EEArchive archive) throws GenBaseException { 83 ArchiveStorer storer = null; 84 File endfile = new File (config.getOut(), outname); 85 Archive out = null; 86 87 if (config.getSaveMode() == Config.PACKED) { 88 if (logger.isLoggable(BasicLevel.DEBUG)) { 89 logger.log(BasicLevel.DEBUG, "Saving '" + endfile + "' in packed form..."); 90 } 91 storer = new JarStorer(archive, endfile); 92 storer.store(); 93 out = new JarArchive(endfile); 94 } else { 95 if (logger.isLoggable(BasicLevel.DEBUG)) { 96 logger.log(BasicLevel.DEBUG, "Saving '" + endfile + "' in unpacked form..."); 97 } 98 storer = new DirStorer(archive, endfile); 99 storer.store(); 100 out = new FileArchive(endfile); 101 } 102 103 return out; 104 105 } 106 107 114 protected Archive save(Config config, String outname) throws GenBaseException { 115 return save(config, outname, archive); 116 } 117 118 121 public static Logger getLogger() { 122 return logger; 123 } 124 } | Popular Tags |