1 25 26 package org.objectweb.jonas_lib.genbase.archive; 27 28 import java.io.File ; 29 import java.io.FileOutputStream ; 30 import java.io.IOException ; 31 import java.io.OutputStream ; 32 import java.util.Vector ; 33 import java.util.jar.Attributes ; 34 import java.util.jar.Manifest ; 35 36 import org.objectweb.jonas_lib.files.FileUtils; 37 import org.objectweb.jonas_lib.files.FileUtilsException; 38 import org.objectweb.jonas_lib.genbase.GenBaseException; 39 import org.objectweb.jonas_lib.genbase.utils.TempRepository; 40 import org.objectweb.jonas_lib.genbase.utils.XMLUtils; 41 42 47 public class DummyApplication extends Application { 48 49 50 private String name; 51 52 59 public DummyApplication(String name) throws GenBaseException { 60 super(createFileArchive()); 61 this.name = name; 62 init(); 63 } 64 65 72 private static Archive createFileArchive() throws GenBaseException { 73 TempRepository tr = TempRepository.getInstance(); 74 75 try { 76 File tmp = tr.createDir(); 77 File meta = new File (tmp, "META-INF"); 78 meta.mkdirs(); 79 80 File manifest = new File (meta, "MANIFEST.MF"); 81 82 Manifest mf = new Manifest (); 83 mf.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0"); 84 85 OutputStream os = new FileOutputStream (manifest); 86 mf.write(os); 87 os.close(); 88 89 String jonasRoot = System.getProperty("install.root"); 90 File appTemplate = new File (new File (jonasRoot), "templates" + File.separator + "wsgen" + File.separator 91 + "application.xml"); 92 FileUtils.copyFile(appTemplate, meta); 93 94 return new FileArchive(tmp); 95 } catch (IOException ioe) { 96 throw new GenBaseException(ioe); 97 } catch (FileUtilsException fue) { 98 throw new GenBaseException(fue); 99 } 100 } 101 102 108 protected void init() throws GenBaseException { 109 setEjbjars(new Vector ()); 111 setWebapps(new Vector ()); 112 setClients(new Vector ()); 113 114 loadDescriptors(); 115 116 XMLUtils.cleanDummyApplication(getApp()); 117 118 } 119 120 123 public String getName() { 124 return name; 125 } 126 127 } | Popular Tags |