Java Code Examples for org.eclipse.jetty.server.handler.ContextHandler#setHandler()

The following examples show how to use org.eclipse.jetty.server.handler.ContextHandler#setHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyInboundClientTest.java    From knox with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  server = new Server();
  ServerConnector connector = new ServerConnector(server);
  server.addConnector(connector);

  Handler handler = new WebsocketEchoHandler();

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setHandler(handler);
  server.setHandler(context);

  server.start();

  String host = connector.getHost();
  if (host == null) {
    host = "localhost";
  }
  int port = connector.getLocalPort();
  serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/",host,port));
}
 
Example 2
Source File: BadBackendTest.java    From knox with Apache License 2.0 6 votes vote down vote up
private static void startProxy() throws Exception {
  GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class);
  proxy = new Server();
  proxyConnector = new ServerConnector(proxy);
  proxy.addConnector(proxyConnector);

  /* start Knox with WebsocketAdapter to test */
  final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler(
      new ProxyWebSocketAdapter(new URI(BAD_BACKEND), Executors.newFixedThreadPool(10), gatewayConfig));

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setHandler(wsHandler);
  proxy.setHandler(context);

  // Start Server
  proxy.start();

  String host = proxyConnector.getHost();
  if (host == null) {
    host = "localhost";
  }
  int port = proxyConnector.getLocalPort();
  proxyUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
}
 
Example 3
Source File: WebsocketMultipleConnectionTest.java    From knox with Apache License 2.0 6 votes vote down vote up
/**
 * Start Mock Websocket server that acts as backend.
 * @throws Exception exception on websocket server start
 */
private static void startWebsocketServer() throws Exception {

  backendServer = new Server(new QueuedThreadPool(254));
  ServerConnector connector = new ServerConnector(backendServer);
  backendServer.addConnector(connector);

  final WebsocketEchoHandler handler = new WebsocketEchoHandler();

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setHandler(handler);
  backendServer.setHandler(context);

  // Start Server
  backendServer.start();

  String host = connector.getHost();
  if (host == null) {
    host = "localhost";
  }
  int port = connector.getLocalPort();
  backendServerUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/ws", host, port));
}
 
Example 4
Source File: DocumentStorage.java    From JVoiceXML with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Starts the document storage. Afterwards it will be ready to serve
 * documents.
 * 
 * @throws Exception
 *             error starting the web server
 * 
 * @since 0.7.8
 */
public void start() throws Exception {
    if (storagePort < 0) {
        return;
    }
    server = new Server(storagePort);
    ContextHandler rootContext = new ContextHandler();
    rootContext.setHandler(internalGrammarHandler);
    ContextHandler internalGrammarContext = new ContextHandler(
            InternalGrammarDocumentHandler.CONTEXT_PATH);
    internalGrammarContext.setHandler(internalGrammarHandler);
    ContextHandler builtinGrammarContext = new ContextHandler(
            BuiltinGrammarHandler.CONTEXT_PATH);
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    builtinGrammarContext.setHandler(builtinGrammarHandler);
    ContextHandler[] handlers = new ContextHandler[] { rootContext,
            internalGrammarContext, builtinGrammarContext };
    contexts.setHandlers(handlers);
    server.setHandler(contexts);
    server.start();
    LOGGER.info("document storage started on port " + storagePort);
}
 
Example 5
Source File: VRaptorServer.java    From mamute with Apache License 2.0 6 votes vote down vote up
private ContextHandler systemRestart() {
	AbstractHandler system = new AbstractHandler() {
		@Override
		public void handle(String target, Request baseRequest,
				HttpServletRequest request, HttpServletResponse response)
				throws IOException, ServletException {
			restartContexts();
			response.setContentType("text/html;charset=utf-8");
			response.setStatus(HttpServletResponse.SC_OK);
			baseRequest.setHandled(true);
			response.getWriter().println("<h1>Done</h1>");
		}
	};
	ContextHandler context = new ContextHandler();
	context.setContextPath("/vraptor/restart");
	context.setResourceBase(".");
	context.setClassLoader(Thread.currentThread().getContextClassLoader());
	context.setHandler(system);
	return context;
}
 
Example 6
Source File: WebServer.java    From sparkler with Apache License 2.0 6 votes vote down vote up
public WebServer(int port, String resRoot){
    super(port);
    LOG.info("Port:{}, Resources Root:{}", port, resRoot);
    ResourceHandler rh0 = new ResourceHandler();
    ContextHandler context0 = new ContextHandler();
    context0.setContextPath("/res/*");
    context0.setResourceBase(resRoot);
    context0.setHandler(rh0);

    //ServletHandler context1 = new ServletHandler();
    //this.setHandler(context1);

    ServletContextHandler context1 =  new ServletContextHandler();
    context1.addServlet(TestSlaveServlet.class, "/slavesite/*");

    // Create a ContextHandlerCollection and set the context handlers to it.
    // This will let jetty process urls against the declared contexts in
    // order to match up content.
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[] { context1, context0});

    this.setHandler(contexts);
}
 
Example 7
Source File: MessageFailureTest.java    From knox with Apache License 2.0 6 votes vote down vote up
private static void startBackend() throws Exception {
  backend = new Server();
  connector = new ServerConnector(backend);
  backend.addConnector(connector);

  /* start backend with Echo socket */
  final BigEchoSocketHandler wsHandler = new BigEchoSocketHandler(
      new EchoSocket());

  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setHandler(wsHandler);
  backend.setHandler(context);

  // Start Server
  backend.start();

  String host = connector.getHost();
  if (host == null) {
    host = "localhost";
  }
  int port = connector.getLocalPort();
  serverUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/", host, port));
}
 
Example 8
Source File: BaseIntegrationTest.java    From apollo with Apache License 2.0 5 votes vote down vote up
protected ContextHandler mockMetaServerHandler(final boolean failedAtFirstTime) {
  final ServiceDTO someServiceDTO = new ServiceDTO();
  someServiceDTO.setAppName(someAppName);
  someServiceDTO.setInstanceId(someInstanceId);
  someServiceDTO.setHomepageUrl(configServiceURL);
  final AtomicInteger counter = new AtomicInteger(0);

  ContextHandler context = new ContextHandler("/services/config");
  context.setHandler(new AbstractHandler() {
    @Override
    public void handle(String target, Request baseRequest, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
      if (failedAtFirstTime && counter.incrementAndGet() == 1) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        baseRequest.setHandled(true);
        return;
      }
      response.setContentType("application/json;charset=UTF-8");
      response.setStatus(HttpServletResponse.SC_OK);

      response.getWriter().println(gson.toJson(Lists.newArrayList(someServiceDTO)));

      baseRequest.setHandled(true);
    }
  });

  return context;
}
 
Example 9
Source File: ConfigIntegrationTest.java    From apollo with Apache License 2.0 5 votes vote down vote up
private ContextHandler mockPollNotificationHandler(final long pollResultTimeOutInMS,
    final int statusCode,
    final List<ApolloConfigNotification> result,
    final boolean failedAtFirstTime) {
  ContextHandler context = new ContextHandler("/notifications/v2");
  context.setHandler(new AbstractHandler() {
    AtomicInteger counter = new AtomicInteger(0);

    @Override
    public void handle(String target, Request baseRequest, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
      if (failedAtFirstTime && counter.incrementAndGet() == 1) {
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        baseRequest.setHandled(true);
        return;
      }

      try {
        TimeUnit.MILLISECONDS.sleep(pollResultTimeOutInMS);
      } catch (InterruptedException e) {
      }

      response.setContentType("application/json;charset=UTF-8");
      response.setStatus(statusCode);
      response.getWriter().println(gson.toJson(result));
      baseRequest.setHandled(true);
    }
  });

  return context;
}
 
Example 10
Source File: ApiServer.java    From lancoder with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	try {
		Properties jettyShutUpProperties = new Properties();
		jettyShutUpProperties.setProperty("org.eclipse.jetty.LEVEL", "WARN");
		StdErrLog.setProperties(jettyShutUpProperties);

		server = new Server(master.getConfig().getApiServerPort());

		// static resources handler
		ContextHandler ctxStatic = new ContextHandler("/");
		ResourceHandler staticHandler = new ResourceHandler();
		staticHandler.setResourceBase(this.getClass().getClassLoader().getResource(WEB_DIR).toExternalForm());
		// staticHandler.setResourceBase("src/main/web/web_resources");
		staticHandler.setDirectoriesListed(true);
		ctxStatic.setHandler(staticHandler);

		// api handler
		ContextHandler ctxApi = buildServletContextHandler();
		ctxApi.setContextPath("/api");

		ContextHandlerCollection contexts = new ContextHandlerCollection();
		contexts.setHandlers(new Handler[] { ctxStatic, ctxApi });
		server.setHandler(contexts);

		server.start();
		server.join();
	} catch (Exception e) {
		// TODO alert master api server api crashed
		e.printStackTrace();
	}
}
 
Example 11
Source File: App.java    From app-runner with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Map<String, String> settings = System.getenv();

    // When run from app-runner, you must use the port set in the environment variable APP_PORT
    int port = Integer.parseInt(settings.getOrDefault("APP_PORT", "8081"));
    // All URLs must be prefixed with the app name, which is got via the APP_NAME env var.
    String appName = settings.getOrDefault("APP_NAME", "my-app");
    String env = settings.getOrDefault("APP_ENV", "local"); // "prod" or "local"
    boolean isLocal = "local".equals(env);
    log.info("Starting " + appName + " in " + env + " on port " + port);

    Server jettyServer = new Server(new InetSocketAddress("localhost", port));
    jettyServer.setStopAtShutdown(true);

    HandlerList handlers = new HandlerList();
    // TODO: set your own handlers
    handlers.addHandler(resourceHandler(isLocal));

    // you must serve everything from a directory named after your app
    ContextHandler ch = new ContextHandler();
    ch.setContextPath("/" + appName);
    ch.setHandler(handlers);
    jettyServer.setHandler(ch);

    try {
        jettyServer.start();
    } catch (Throwable e) {
        log.error("Error on start", e);
        System.exit(1);
    }

    log.info("Started app at http://localhost:" + port + ch.getContextPath());
    jettyServer.join();
}
 
Example 12
Source File: Main.java    From selenium with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  Flags flags = new Flags();
  JCommander.newBuilder().addObject(flags).build().parse(args);

  Server server = new Server();
  ServerConnector connector = new ServerConnector(server);
  connector.setPort(flags.port);
  server.setConnectors(new Connector[] {connector });

  HandlerList handlers = new HandlerList();

  ContextHandler context = new ContextHandler();
  context.setContextPath("/tests");
  ResourceHandler testHandler = new ResourceHandler();
  testHandler.setBaseResource(Resource.newClassPathResource("/tests"));
  testHandler.setDirectoriesListed(true);
  context.setHandler(testHandler);
  handlers.addHandler(context);

  ContextHandler coreContext = new ContextHandler();
  coreContext.setContextPath("/core");
  ResourceHandler coreHandler = new ResourceHandler();
  coreHandler.setBaseResource(Resource.newClassPathResource("/core"));
  coreContext.setHandler(coreHandler);
  handlers.addHandler(coreContext);

  ServletContextHandler driverContext = new ServletContextHandler();
  driverContext.setContextPath("/");
  driverContext.addServlet(WebDriverServlet.class, "/wd/hub/*");
  handlers.addHandler(driverContext);

  server.setHandler(handlers);
  server.start();
}
 
Example 13
Source File: WebServer.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Server setupServer() throws Exception {
    // String webDir = "target/classes/webui";
    // String webDir = "src/main/resources/webui";
    String webDir = WebServer.class.getClassLoader().getResource("webui").toExternalForm();
    log.info("Base webdir is {}", webDir);

    int httpPort = ConfigFactory.load().getInt("resource-reporting.visualization.webui-port");
    log.info("Resource reporting web ui port is ", httpPort);

    // Create Jetty server
    Server server = new Server(httpPort);

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setWelcomeFiles(new String[] { "filter.html" });
    resource_handler.setResourceBase(webDir);

    WebSocketHandler wsHandler = new WebSocketHandler.Simple(PubSubProxyWebSocket.class);

    ContextHandler context = new ContextHandler();
    context.setContextPath("/ws");
    context.setHandler(wsHandler);

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { context, resource_handler, new DefaultHandler() });

    server.setHandler(handlers);

    ClusterResources.subscribeToAll(callback);

    return server;
}
 
Example 14
Source File: AuthenticationTest.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private static void createContext(Path crlPath)
{
    final ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath("/" + crlPath.getFileName());
    contextHandler.setHandler(new CrlServerHandler(crlPath));
    HANDLERS.addHandler(contextHandler);
}
 
Example 15
Source File: WebService.java    From pulsar with Apache License 2.0 5 votes vote down vote up
public void addStaticResources(String basePath, String resourcePath) {
    ContextHandler capHandler = new ContextHandler();
    capHandler.setContextPath(basePath);
    ResourceHandler resHandler = new ResourceHandler();
    resHandler.setBaseResource(Resource.newClassPathResource(resourcePath));
    resHandler.setEtags(true);
    resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL);
    capHandler.setHandler(resHandler);
    handlers.add(capHandler);
}
 
Example 16
Source File: JettyServer.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private ContextHandler createDocsWebApp(final String contextPath) {
    try {
        final ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setDirectoriesListed(false);

        // load the docs directory
        final File docsDir = Paths.get("docs").toRealPath().toFile();
        final Resource docsResource = Resource.newResource(docsDir);

        // load the component documentation working directory
        final String componentDocsDirPath = props.getProperty(NiFiProperties.COMPONENT_DOCS_DIRECTORY, "work/docs/components");
        final File workingDocsDirectory = Paths.get(componentDocsDirPath).toRealPath().getParent().toFile();
        final Resource workingDocsResource = Resource.newResource(workingDocsDirectory);

        // load the rest documentation
        final File webApiDocsDir = new File(webApiContext.getTempDirectory(), "webapp/docs");
        if (!webApiDocsDir.exists()) {
            final boolean made = webApiDocsDir.mkdirs();
            if (!made) {
                throw new RuntimeException(webApiDocsDir.getAbsolutePath() + " could not be created");
            }
        }
        final Resource webApiDocsResource = Resource.newResource(webApiDocsDir);

        // create resources for both docs locations
        final ResourceCollection resources = new ResourceCollection(docsResource, workingDocsResource, webApiDocsResource);
        resourceHandler.setBaseResource(resources);

        // create the context handler
        final ContextHandler handler = new ContextHandler(contextPath);
        handler.setHandler(resourceHandler);

        logger.info("Loading documents web app with context path set to " + contextPath);
        return handler;
    } catch (Exception ex) {
        throw new IllegalStateException("Resource directory paths are malformed: " + ex.getMessage());
    }
}
 
Example 17
Source File: WebServer.java    From buck with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
ImmutableList<ContextHandler> createHandlers() {
  Map<String, Handler> contextPathToHandler = new HashMap<>();

  contextPathToHandler.put(INDEX_CONTEXT_PATH, new TemplateHandler(new IndexHandlerDelegate()));

  StaticResourcesHandler staticResourcesHandler = new StaticResourcesHandler();
  contextPathToHandler.put(STATIC_CONTEXT_PATH, staticResourcesHandler);

  // Handlers for traces.
  BuildTraces buildTraces = new BuildTraces(projectFilesystem);
  contextPathToHandler.put(
      TRACE_CONTEXT_PATH, new TemplateHandler(new TraceHandlerDelegate(buildTraces)));
  contextPathToHandler.put(
      TRACES_CONTEXT_PATH, new TemplateHandler(new TracesHandlerDelegate(buildTraces)));
  contextPathToHandler.put(TRACE_DATA_CONTEXT_PATH, new TraceDataHandler(buildTraces));
  contextPathToHandler.put(ARTIFACTS_CONTEXT_PATH, artifactCacheHandler);

  ImmutableList.Builder<ContextHandler> handlers = ImmutableList.builder();
  for (Map.Entry<String, Handler> entry : contextPathToHandler.entrySet()) {
    String contextPath = entry.getKey();
    Handler handler = entry.getValue();
    ContextHandler contextHandler = new ContextHandler(contextPath);
    contextHandler.setHandler(handler);
    handlers.add(contextHandler);
  }

  // Create a handler that acts as a WebSocket server.
  ServletContextHandler servletContextHandler =
      new ServletContextHandler(
          /* parent */ server,
          /* contextPath */ "/ws",
          /* sessions */ true,
          /* security */ false);
  servletContextHandler.addServlet(new ServletHolder(streamingWebSocketServlet), "/build");
  handlers.add(servletContextHandler);
  return handlers.build();
}
 
Example 18
Source File: StreamingReceiver.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void startHttpServer() throws Exception {
    KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    createAndConfigHttpServer(kylinConfig);

    ContextHandlerCollection contexts = new ContextHandlerCollection();

    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/kylin");

    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    ctx.setConfigLocation("classpath:applicationContext.xml");
    ctx.refresh();
    DispatcherServlet dispatcher = new DispatcherServlet(ctx);
    context.addServlet(new ServletHolder(dispatcher), "/api/*");

    ContextHandler logContext = new ContextHandler("/kylin/logs");
    String logDir = getLogDir(kylinConfig);
    ResourceHandler logHandler = new ResourceHandler();
    logHandler.setResourceBase(logDir);
    logHandler.setDirectoriesListed(true);
    logContext.setHandler(logHandler);

    contexts.setHandlers(new Handler[] { context, logContext });
    httpServer.setHandler(contexts);
    httpServer.start();
    httpServer.join();
}
 
Example 19
Source File: JettyHttpTransport.java    From cougar with Apache License 2.0 4 votes vote down vote up
public void initialiseStaticJettyConfig() throws Exception {
        server.initialiseConnectors();

        ErrorHandler errorHandler = new CougarErrorHandler();
        wsdlStaticHandler = new StaticContentServiceHandler(
                wsdlContextPath,
                wsdlRegex,
                wsdlMediaType,
                uuidHeader,
                uuidParentsHeader,
                deserializer,
                geoIPLocator,
                requestLogger,
                true);
        wsdlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);

        htmlStaticHandler = new StaticContentServiceHandler(
                htmlContextPath,
                htmlRegex,
                htmlMediaType,
                uuidHeader,
                uuidParentsHeader,
                deserializer,
                geoIPLocator,
                requestLogger,
                suppressCommasInAccessLogForStaticHtml);
        htmlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);

        StatisticsHandler statisticsHandler = new StatisticsHandler();
        statisticsHandler.setServer(server.getJettyServer());

        handlerCollection.setServer(server.getJettyServer());

        JettyHandler defaultJettyServiceHandler = new AliasHandler(defaultCommandProcessor, suppressCommasInAccessLogForCalls, pathAliases);
        ContextHandler context = new ContextHandler();
        context.setContextPath("");
        context.setResourceBase(".");
        context.setHandler(defaultJettyServiceHandler);
        handlerCollection.addHandler(context);

        handlerCollection.addHandler(wsdlStaticHandler);
        handlerCollection.addHandler(htmlStaticHandler);
//        handlerCollection.addHandler(aliasHandler);
        statisticsHandler.setHandler(handlerCollection);

        // Register the errorhandler with the server itself
        server.addBean(errorHandler);
        server.setHandler(statisticsHandler);
    }
 
Example 20
Source File: JettyStarter.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
public List<String> deployWebApplications(String rmUrl, String schedulerUrl) {
    initializeRestProperties();

    setSystemPropertyIfNotDefined("rm.url", rmUrl);
    setSystemPropertyIfNotDefined("scheduler.url", schedulerUrl);

    if (WebProperties.WEB_DEPLOY.getValueAsBoolean()) {
        logger.info("Starting the web applications...");

        int httpPort = getJettyHttpPort();
        int httpsPort = 443;
        if (WebProperties.WEB_HTTPS_PORT.isSet()) {
            httpsPort = WebProperties.WEB_HTTPS_PORT.getValueAsInt();
        }

        boolean httpsEnabled = WebProperties.WEB_HTTPS.getValueAsBoolean();
        boolean redirectHttpToHttps = WebProperties.WEB_REDIRECT_HTTP_TO_HTTPS.getValueAsBoolean();

        int restPort = httpPort;

        String httpProtocol;
        String[] defaultVirtualHost;
        String[] httpVirtualHost = new String[] { "@" + HTTP_CONNECTOR_NAME };

        if (httpsEnabled) {
            httpProtocol = "https";
            defaultVirtualHost = new String[] { "@" + HTTPS_CONNECTOR_NAME };
            restPort = httpsPort;
        } else {
            defaultVirtualHost = httpVirtualHost;
            httpProtocol = "http";
        }

        Server server = createHttpServer(httpPort, httpsPort, httpsEnabled, redirectHttpToHttps);

        server.setStopAtShutdown(true);

        HandlerList handlerList = new HandlerList();

        if (WebProperties.JETTY_LOG_FILE.isSet()) {
            String pathToJettyLogFile = FileStorageSupportFactory.relativeToHomeIfNotAbsolute(WebProperties.JETTY_LOG_FILE.getValueAsString());
            File jettyLogFile = new File(pathToJettyLogFile);
            if (!jettyLogFile.getParentFile().exists() && !jettyLogFile.getParentFile().mkdirs()) {
                logger.error("Could not create jetty log file in: " +
                             WebProperties.JETTY_LOG_FILE.getValueAsString());
            } else {
                NCSARequestLog requestLog = new NCSARequestLog(pathToJettyLogFile);
                requestLog.setAppend(true);
                requestLog.setExtended(false);
                requestLog.setLogTimeZone("GMT");
                requestLog.setLogLatency(true);
                requestLog.setRetainDays(WebProperties.JETTY_LOG_RETAIN_DAYS.getValueAsInt());

                RequestLogHandler requestLogHandler = new RequestLogHandler();
                requestLogHandler.setRequestLog(requestLog);
                handlerList.addHandler(requestLogHandler);
            }
        }

        if (httpsEnabled && redirectHttpToHttps) {
            ContextHandler redirectHandler = new ContextHandler();
            redirectHandler.setContextPath("/");
            redirectHandler.setHandler(new SecuredRedirectHandler());
            redirectHandler.setVirtualHosts(httpVirtualHost);
            handlerList.addHandler(redirectHandler);
        }

        addWarsToHandlerList(handlerList, defaultVirtualHost);
        server.setHandler(handlerList);

        String schedulerHost = ProActiveInet.getInstance().getHostname();
        return startServer(server, schedulerHost, restPort, httpProtocol);
    }
    return new ArrayList<>();
}