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.jar.Attributes ; 33 import java.util.jar.Manifest ; 34 35 import org.objectweb.jonas_lib.files.FileUtils; 36 import org.objectweb.jonas_lib.files.FileUtilsException; 37 import org.objectweb.jonas_lib.genbase.GenBaseException; 38 import org.objectweb.jonas_lib.genbase.utils.TempRepository; 39 40 41 46 public class DummyWebApp extends WebApp { 47 48 49 private String name; 50 51 59 public DummyWebApp(Application app, String name) throws GenBaseException { 60 super(createFileArchive(), app); 61 this.name = name; 62 } 63 64 71 private static Archive createFileArchive() throws GenBaseException { 72 TempRepository tr = TempRepository.getInstance(); 73 74 try { 75 File tmp = tr.createDir(); 76 File meta = new File (tmp, "META-INF"); 77 meta.mkdirs(); 78 79 File web = new File (tmp, "WEB-INF"); 80 web.mkdirs(); 81 82 File manifest = new File (meta, "MANIFEST.MF"); 83 84 Manifest mf = new Manifest (); 85 mf.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0"); 86 87 OutputStream os = new FileOutputStream (manifest); 88 mf.write(os); 89 os.close(); 90 91 String jonasRoot = System.getProperty("install.root"); 92 File webTemplate = new File (new File (jonasRoot), "templates" + File.separator + "wsgen" + File.separator 93 + "web.xml"); 94 FileUtils.copyFile(webTemplate, web); 95 96 File contextTemplate = new File (new File (jonasRoot), "templates" 98 + File.separator + "wsgen" + File.separator + "context.xml"); 99 FileUtils.copyFile(contextTemplate, meta); 100 101 File webjettyTemplate = new File (new File (jonasRoot), "templates" 103 + File.separator + "wsgen" + File.separator + "web-jetty.xml"); 104 FileUtils.copyFile(webjettyTemplate, web); 105 106 return new FileArchive(tmp); 107 } catch (IOException ioe) { 108 throw new GenBaseException(ioe); 109 } catch (FileUtilsException fue) { 110 throw new GenBaseException(fue); 111 } 112 } 113 114 117 public String getName() { 118 return name; 119 } 120 121 } | Popular Tags |