示例#1
0
  /**
   * Executes this Ant task. The build flow is being stopped until Jetty server stops.
   *
   * @throws BuildException
   */
  public void execute() throws BuildException {
    TaskLog.setTask(this);
    TaskLog.log("Configuring Jetty for project: " + getProject().getName());
    WebApplicationProxyImpl.setBaseTempDirectory(tempDirectory);
    setSystemProperties();

    List connectorsList = null;

    if (connectors != null) {
      connectorsList = connectors.getConnectors();
    } else {
      connectorsList = new Connectors(jettyPort, 30000).getDefaultConnectors();
    }

    List loginServicesList =
        (loginServices != null ? loginServices.getLoginServices() : new ArrayList());
    ServerProxy server =
        new ServerProxyImpl(connectorsList, loginServicesList, requestLog, jettyXml);

    try {
      Iterator iterator = webapps.iterator();
      while (iterator.hasNext()) {
        WebApp webAppConfiguration = (WebApp) iterator.next();
        WebApplicationProxyImpl webApp = new WebApplicationProxyImpl(webAppConfiguration.getName());
        webApp.setSourceDirectory(webAppConfiguration.getWarFile());
        webApp.setContextPath(webAppConfiguration.getContextPath());
        webApp.setWebXml(webAppConfiguration.getWebXmlFile());
        webApp.setJettyEnvXml(webAppConfiguration.getJettyEnvXml());
        webApp.setClassPathFiles(webAppConfiguration.getClassPathFiles());
        webApp.setLibrariesConfiguration(webAppConfiguration.getLibrariesConfiguration());
        webApp.setExtraScanTargetsConfiguration(webAppConfiguration.getScanTargetsConfiguration());
        webApp.setContextHandlers(webAppConfiguration.getContextHandlers());
        webApp.setWebDefaultXmlFile(webAppConfiguration.getWebDefaultXmlFile());

        server.addWebApplication(webApp, webAppConfiguration.getScanIntervalSeconds());
      }
    } catch (Exception e) {
      throw new BuildException(e);
    }

    server.start();
  }