Beispiel #1
0
  public RunAppServer() throws IOException {
    // set up URL handlers for Wonderland types
    URL.setURLStreamHandlerFactory(new WonderlandURLStreamHandlerFactory());

    // now load the properties
    setupProperties();

    // check if we need to make any changes
    if (Boolean.parseBoolean(System.getProperty(Constants.WEBSERVER_NEWVERSION_PROP))) {
      // replace old versions of modules with newer versions
      updateModules();

      // write the web server's document root
      writeDocumentRoot();

      // write DTDs for local deployments
      writeSchemas();

      // write the updated webapps
      writeWebApps();
    }

    // create and start the appserver -- the hostname will be set
    // as a sideeffect of the start call
    try {
      createAppServer();
      getAppServer().start();
    } catch (LifecycleException le) {
      throw new IOException(le);
    }

    // deploy built-in web apps
    deployWebApps();

    // notify the deployer that we are ready to start deploying other apps
    getAppServer().setDeployable(true);

    // redeploy any other modules, including web modules,
    // that haven't yet been deployed.  This will also
    // install all pending modules
    ModuleManager.getModuleManager().redeployAll();

    // start accepting secure connections to the web server (needed
    // by the services that start when we fire the startup complete
    // event below)
    DefaultSAM.setStarted(true);

    // now that all the modules are deployed, notify anyone waiting
    // for startup
    AppServerMonitor.getInstance().fireStartupComplete();
  }
Beispiel #2
0
  /**
   * Update any system-installed module to be the latest version from the Wonderland.jar file.
   *
   * @throws IOException if there is an error reading or writing modules
   */
  protected void updateModules() throws IOException {
    ModuleManager mm = ModuleManager.getModuleManager();

    // create the directory to extract modules to, if it doesn't already
    // exist
    File moduleDir = RunUtil.createTempDir("module", ".jar");

    // read the list of modules and their checksums from the jar file
    Map<String, String> checksums = FileListUtil.readChecksums("META-INF/modules");

    // get the list of all installed module with the "system-installed"
    // key set.  This is set on all modules installed by the system
    Map<String, Module> installed = mm.getInstalledModulesByKey(ModuleAttributes.SYSTEM_MODULE);

    // get the checksum of any module that has a checksum.  As a
    // side-effect, any module with a checksum is removed from the
    // list of installed modules, so that list can be used to decide
    // which modules to uninstall
    Map<String, String[]> installedChecksums = getChecksums(installed);

    // add all modules remaining in the installed list to the
    // uninstall list.  These are modules that were installed by an
    // old version of Wonderland and do not have a filename or
    // checksum attribute set.
    Collection<String> uninstall = new ArrayList<String>(installed.keySet());

    // now go through the checksums of old and new modules to determine
    // which modules need to be installed and which are unchanged
    List<TaggedModule> install = new ArrayList<TaggedModule>();
    for (Map.Entry<String, String> checksum : checksums.entrySet()) {

      // compare an existing checksum to an old checksum. If the
      // old checksum doesn't exist or is different than the new
      // checksum, install the new file.  This will overwrite the old
      // checksum in the process.
      String[] installedChecksum = installedChecksums.remove(checksum.getKey());
      if (installedChecksum == null || !installedChecksum[0].equals(checksum.getValue())) {
        install.add(createTaggedModule(checksum.getKey(), checksum.getValue(), moduleDir));
      }
    }

    // any modules not removed from the installedChecksums list are
    // old modules that were installed by a previous version of Wonderland
    // (not by the user) and aren't in the new module list.  We need to
    // remove these modules
    for (String[] moduleDesc : installedChecksums.values()) {
      uninstall.add(moduleDesc[1]);
    }

    // uninstall any modules on the uninstall list
    logger.warning("Uninstall: " + uninstall);
    mm.addToUninstall(uninstall);

    // install any modules on the install list
    String installList = "";
    for (TaggedModule tm : install) {
      installList += " " + tm.getFile().getName();
    }
    logger.warning("Install: " + installList);
    mm.addTaggedToInstall(install);
  }