Exemple #1
0
  protected void writeWebApps() throws IOException {
    // write to a subdirectory of the default temp directory
    File deployDir = new File(RunUtil.getRunDir(), getWebappDir());
    deployDir.mkdirs();

    // figure out the set of files to add or remove
    List<String> addFiles = new ArrayList<String>();
    List<String> removeFiles = new ArrayList<String>();
    FileListUtil.compareDirs("META-INF/" + getWebappDir(), deployDir, addFiles, removeFiles);

    // remove the files to remove
    for (String removeFile : removeFiles) {
      File remove = new File(deployDir, removeFile);

      // files have been extracted into directories
      if (remove.isDirectory()) {
        RunUtil.deleteDir(remove);
      }
    }

    for (String addFile : addFiles) {
      String fullPath = "/" + getWebappDir() + "/" + addFile;

      // make sure to clear the directory before we write to it
      File existingDir = new File(deployDir, addFile);
      if (existingDir.exists() && existingDir.isDirectory()) {
        RunUtil.deleteDir(existingDir);
      }

      RunUtil.extractJar(getClass(), fullPath, deployDir);
    }

    // write the updated checksum list
    RunUtil.extract(getClass(), "/META-INF/" + getWebappDir() + "/files.list", deployDir);
  }
Exemple #2
0
  protected void writeDocumentRoot() throws IOException {
    File docDir = new File(RunUtil.getRunDir(), "docRoot");
    docDir.mkdirs();

    // figure out the set of files to add or remove
    List<String> addFiles = new ArrayList<String>();
    List<String> removeFiles = new ArrayList<String>();
    FileListUtil.compareDirs("META-INF/docroot", docDir, addFiles, removeFiles);

    for (String removeFile : removeFiles) {
      File file = new File(docDir, removeFile);
      file.delete();
    }

    for (String addFile : addFiles) {
      String fullPath = "/docroot/" + addFile;
      InputStream fileIs = WebServerLauncher.class.getResourceAsStream(fullPath);

      RunUtil.writeToFile(fileIs, new File(docDir, addFile));
      fileIs.close();
    }

    // write the updated checksum list
    RunUtil.extract(getClass(), "/META-INF/docroot/files.list", docDir);
  }
Exemple #3
0
  private TaggedModule createTaggedModule(String file, String checksum, File moduleDir)
      throws IOException {
    // extract the file
    String fullPath = "/modules/" + file;
    File extracted = RunUtil.extract(getClass(), fullPath, moduleDir);

    // now generate the attributes
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put(ModuleAttributes.SYSTEM_MODULE, String.valueOf(true));
    attributes.put(ModuleAttributes.FILENAME, file);
    attributes.put(ModuleAttributes.CHECKSUM, checksum);

    // create the tagged module
    return new TaggedModule(extracted, attributes);
  }
Exemple #4
0
  static synchronized void createAppServer() throws IOException {
    if (appServer != null) {
      throw new IllegalStateException("App server already created.");
    }

    File install_dir = new File(RunUtil.getRunDir(), "web_install");
    File instance_dir = new File(RunUtil.getRunDir(), "web_run");
    File module_dir = new File(install_dir, "modules");
    File docroot_dir = new File(RunUtil.getRunDir(), "docRoot");

    File logDir = new File(SystemPropertyUtil.getProperty("wonderland.log.dir"));
    File logFile = new File(logDir, "web_server.log");

    // set environment variables that will be substituted into
    // domain.xml
    System.setProperty("org.jdesktop.wonderland.docRoot", docroot_dir.toString());

    // make directories
    install_dir.mkdirs();
    instance_dir.mkdirs();
    module_dir.mkdirs();

    // extract the domain.xml file
    File domainXml = RunUtil.extract(RunAppServer.class, "/domain.xml", install_dir);

    EmbeddedFileSystem.Builder efsBuilder = new EmbeddedFileSystem.Builder();
    efsBuilder.installRoot(install_dir);
    efsBuilder.instanceRoot(instance_dir);
    efsBuilder.configurationFile(domainXml);

    Server.Builder serverBuilder = new Server.Builder("test");
    serverBuilder.embeddedFileSystem(efsBuilder.build());
    // serverBuilder.setLogFile(logFile);

    Server server = serverBuilder.build();

    String portStr = System.getProperty(Constants.WEBSERVER_PORT_PROP).trim();
    int port = Integer.parseInt(portStr);
    server.createPort(port);
    server.addContainer(ContainerBuilder.Type.all);

    // setup and launch
    appServer = new WonderlandAppServer(server);
  }