1 25 26 package org.objectweb.jonas_lib.genbase.modifier; 27 28 import java.io.File ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Vector ; 32 33 import org.objectweb.jonas_lib.genbase.GenBaseException; 34 import org.objectweb.jonas_lib.genbase.archive.Application; 35 import org.objectweb.jonas_lib.genbase.archive.Archive; 36 import org.objectweb.jonas_lib.genbase.generator.Config; 37 38 import org.objectweb.util.monolog.api.BasicLevel; 39 40 45 public abstract class AbsApplicationModifier extends ArchiveModifier { 46 47 50 private List ejbModifiers = null; 51 52 55 private List webModifiers = null; 56 57 60 private List cltModifiers = null; 61 62 65 private Application app = null; 66 67 70 private Config config = null; 71 72 77 public AbsApplicationModifier(Application archive, Config config) { 78 super(archive); 79 this.config = config; 80 app = archive; 81 initVectors(); 82 init(); 83 } 84 85 88 private void initVectors() { 89 ejbModifiers = new Vector (); 91 webModifiers = new Vector (); 92 cltModifiers = new Vector (); 93 } 94 95 98 protected abstract void init(); 99 100 105 public Archive modify() throws GenBaseException { 106 107 getLogger().log(BasicLevel.INFO, "Processing Application " + app.getName()); 108 109 112 for (Iterator i = webModifiers.iterator(); i.hasNext();) { 113 ArchiveModifier wm = (ArchiveModifier) i.next(); 114 Archive a = wm.modify(); 115 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 116 getLogger().log(BasicLevel.DEBUG, "Modifying WebApp '" + a.getName() + "'"); 117 } 118 app.addFile(a.getRootFile()); 119 } 120 121 for (Iterator i = cltModifiers.iterator(); i.hasNext();) { 122 ArchiveModifier cm = (ArchiveModifier) i.next(); 123 Archive a = cm.modify(); 124 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 125 getLogger().log(BasicLevel.DEBUG, "Modifying Client '" + a.getName() + "'"); 126 } 127 app.addFile(a.getRootFile()); 128 } 129 130 for (Iterator i = ejbModifiers.iterator(); i.hasNext();) { 131 ArchiveModifier em = (ArchiveModifier) i.next(); 132 Archive a = em.modify(); 133 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 134 getLogger().log(BasicLevel.DEBUG, "Modifying EjbJar '" + a.getName() + "'"); 135 } 136 app.addFile(a.getRootFile()); 137 } 138 139 return save(config, "apps" + File.separator + app.getName()); 140 141 } 142 143 146 protected List getCltModifiers() { 147 return cltModifiers; 148 } 149 150 153 protected List getEjbModifiers() { 154 return ejbModifiers; 155 } 156 157 160 protected List getWebModifiers() { 161 return webModifiers; 162 } 163 166 protected Application getApplication() { 167 return app; 168 } 169 } | Popular Tags |