DummyWebApp.java

00001 
00026 package org.objectweb.jonas_lib.genbase.archive;
00027 
00028 import java.io.File;
00029 import java.io.FileOutputStream;
00030 import java.io.IOException;
00031 import java.io.OutputStream;
00032 import java.util.jar.Attributes;
00033 import java.util.jar.Manifest;
00034 
00035 import org.objectweb.jonas_lib.genbase.GenBaseException;
00036 import org.objectweb.jonas_lib.genbase.utils.FileUtils;
00037 import org.objectweb.jonas_lib.genbase.utils.TempRepository;
00038 
00039 
00045 public class DummyWebApp extends WebApp {
00046 
00048     private String name;
00049 
00058     public DummyWebApp(Application app, String name) throws GenBaseException {
00059         super(createFileArchive(), app);
00060         this.name = name;
00061     }
00062 
00070     private static Archive createFileArchive() throws GenBaseException {
00071         TempRepository tr = TempRepository.getInstance();
00072 
00073         try {
00074             File tmp = tr.createDir();
00075             File meta = new File(tmp, "META-INF");
00076             meta.mkdirs();
00077 
00078             File web = new File(tmp, "WEB-INF");
00079             web.mkdirs();
00080 
00081             File manifest = new File(meta, "MANIFEST.MF");
00082 
00083             Manifest mf = new Manifest();
00084             mf.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
00085 
00086             OutputStream os = new FileOutputStream(manifest);
00087             mf.write(os);
00088             os.close();
00089 
00090             String jonasRoot = System.getProperty("install.root");
00091             File webTemplate = new File(new File(jonasRoot), "templates" + File.separator + "wsgen" + File.separator
00092                     + "web.xml");
00093             FileUtils.copy(webTemplate, web);
00094 
00095             return new FileArchive(tmp);
00096         } catch (IOException ioe) {
00097             throw new GenBaseException(ioe);
00098         }
00099     }
00100 
00104     public String getName() {
00105         return name;
00106     }
00107 
00108 }

Generated on Tue Feb 15 15:05:51 2005 for JOnAS by  doxygen 1.3.9.1