org.eclipse.jetty.server.handler.ContextHandlerCollection Java Examples

The following examples show how to use org.eclipse.jetty.server.handler.ContextHandlerCollection. 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: EmbeddedServer.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
    throws Exception
{
    Server server = new Server( 8080 );

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );


    server.start();
    server.join();
}
 
Example #2
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 #3
Source File: Main.java    From openscoring with GNU Affero General Public License v3.0 6 votes vote down vote up
private Server createServer(InetSocketAddress address) throws Exception {
	Server server = new Server(address);

	Configuration.ClassList classList = Configuration.ClassList.setServerDefault(server);
	classList.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());

	ContextHandlerCollection handlerCollection = new ContextHandlerCollection();

	Handler applicationHandler = createApplicationHandler();
	handlerCollection.addHandler(applicationHandler);

	Handler adminConsoleHandler = createAdminConsoleHandler();
	if(adminConsoleHandler != null){
		handlerCollection.addHandler(adminConsoleHandler);
	}

	server.setHandler(handlerCollection);

	return server;
}
 
Example #4
Source File: ServersUtil.java    From joynr with Apache License 2.0 6 votes vote down vote up
public static Server startControlledBounceproxy(String bpId) throws Exception {

        final int port = ServletUtil.findFreePort();
        final String bpUrl = "http://localhost:" + port + "/bounceproxy/";

        System.setProperty("joynr.bounceproxy.id", bpId);
        System.setProperty("joynr.bounceproxy.controller.baseurl",
                           System.getProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL));
        System.setProperty("joynr.bounceproxy.url4cc", bpUrl);
        System.setProperty("joynr.bounceproxy.url4bpc", bpUrl);

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[]{ createControlledBounceproxyWebApp("", null) });
        Server server = startServer(contexts, port);

        System.clearProperty("joynr.bounceproxy.id");
        System.clearProperty("joynr.bounceproxy.controller.baseurl");
        System.clearProperty("joynr.bounceproxy.url4cc");
        System.clearProperty("joynr.bounceproxy.url4bpc");

        return server;
    }
 
Example #5
Source File: JettyUtil.java    From incubator-iotdb with Apache License 2.0 6 votes vote down vote up
public static Server getJettyServer(List<ServletContextHandler> handlers, int port) {
  Server server = new Server(port);
  ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setShowStacks(true);
  errorHandler.setServer(server);
  server.addBean(errorHandler);

  ContextHandlerCollection collection = new ContextHandlerCollection();
  ServletContextHandler[] sch = new ServletContextHandler[handlers.size()];
  for (int i = 0; i < handlers.size(); i++) {
    sch[i] = handlers.get(i);
  }
  collection.setHandlers(sch);
  server.setHandler(collection);
  return server;
}
 
Example #6
Source File: ServersUtil.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static Server startServer(ContextHandlerCollection contexts, int port) throws Exception {
    System.setProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH, "http://localhost:" + port);
    setBounceProxyUrl();
    setDirectoriesUrl();
    logger.info("HOST PATH: {}", System.getProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH));

    final Server jettyServer = new Server();
    ServerConnector connector = new ServerConnector(jettyServer,
                                                    new HttpConnectionFactory(new HttpConfiguration()));
    connector.setPort(port);
    connector.setAcceptQueueSize(1);
    jettyServer.setConnectors(new Connector[]{ connector });

    jettyServer.setHandler(contexts);
    jettyServer.start();

    logger.trace("Started jetty server: {}", jettyServer.dump());

    return jettyServer;
}
 
Example #7
Source File: ServerManager.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    Slf4jRequestLog requestLog = new Slf4jRequestLog();
    requestLog.setExtended(true);
    requestLog.setLogTimeZone(TimeZone.getDefault().getID());
    requestLog.setLogLatency(true);
    requestLogHandler.setRequestLog(requestLog);
    handlers.add(0, new ContextHandlerCollection());
    handlers.add(requestLogHandler);

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
    server.setHandler(handlerCollection);

    server.start();

    log.info("Server started at end point {}", getServiceUri());
}
 
Example #8
Source File: ProxyServer.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public void start() throws PulsarServerException {
    log.info("Starting web socket proxy at port {}", conf.getWebServicePort().get());
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    Slf4jRequestLog requestLog = new Slf4jRequestLog();
    requestLog.setExtended(true);
    requestLog.setLogTimeZone(TimeZone.getDefault().getID());
    requestLog.setLogLatency(true);
    requestLogHandler.setRequestLog(requestLog);
    handlers.add(0, new ContextHandlerCollection());
    handlers.add(requestLogHandler);

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
    server.setHandler(handlerCollection);

    try {
        server.start();
    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
Example #9
Source File: JavaNetReverseProxy.java    From jenkins-test-harness with MIT License 6 votes vote down vote up
public JavaNetReverseProxy(File cacheFolder) throws Exception {
    this.cacheFolder = cacheFolder;
    cacheFolder.mkdirs();
    QueuedThreadPool qtp = new QueuedThreadPool();
    qtp.setName("Jetty (JavaNetReverseProxy)");
    server = new Server(qtp);

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    server.setHandler(contexts);

    ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
    root.addServlet(new ServletHolder(this), "/");

    ServerConnector connector = new ServerConnector(server);
    server.addConnector(connector);
    server.start();

    localPort = connector.getLocalPort();
}
 
Example #10
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 #11
Source File: GatewayMicroService.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * Start/run the server.
 * @throws Exception when any exception occurs
 */
public void start() throws Exception {
    long startTime = System.currentTimeMillis();

    ContextHandlerCollection handlers = new ContextHandlerCollection();
    addModulesToJetty(handlers);

    // Create the server.
    int serverPort = serverPort();
    System.out.println("**** Starting Gateway (" + getClass().getSimpleName() + ") on port: " + serverPort);
    server = new Server(serverPort);
    server.setHandler(handlers);
    server.start();
    long endTime = System.currentTimeMillis();
    System.out.println("******* Started in " + (endTime - startTime) + "ms");
}
 
Example #12
Source File: GatewayServer.java    From hadoop-mini-clusters with Apache License 2.0 6 votes vote down vote up
private static HandlerCollection createHandlers(
        final GatewayConfig config,
        final GatewayServices services,
        final ContextHandlerCollection contexts) {
    HandlerCollection handlers = new HandlerCollection();
    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new AccessHandler());

    TraceHandler traceHandler = new TraceHandler();
    traceHandler.setHandler(contexts);
    traceHandler.setTracedBodyFilter(System.getProperty("org.apache.knox.gateway.trace.body.status.filter"));

    CorrelationHandler correlationHandler = new CorrelationHandler();
    correlationHandler.setHandler(traceHandler);

    DefaultTopologyHandler defaultTopoHandler = new DefaultTopologyHandler(config, services, contexts);

    handlers.setHandlers(new Handler[]{correlationHandler, defaultTopoHandler, logHandler});
    return handlers;
}
 
Example #13
Source File: WebServer.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Post deploy
 * @exception Throwable Thrown if an error occurs
 */
public void postDeploy() throws Throwable
{
   if (server != null &&
       !server.isRunning() &&
       handlers != null && handlers.getHandlers() != null && handlers.getHandlers().length > 0)
   {
      try
      {
         ContextHandlerCollection chc = new ContextHandlerCollection();
         chc.setHandlers(handlers.getHandlers());

         server.setHandler(chc);
   
         server.start();
      }
      catch (Exception e)
      {
         log.error("Could not start Jetty webserver", e);
      }
   }
}
 
Example #14
Source File: JettyCustomServer.java    From nano-framework with Apache License 2.0 6 votes vote down vote up
private void applyHandle(final String contextPath, final String warPath) {
    final ContextHandlerCollection handler = new ContextHandlerCollection();
    final WebAppContext webapp = new WebAppContext();
    webapp.setContextPath(contextPath);
    webapp.setDefaultsDescriptor(WEB_DEFAULT);
    if (StringUtils.isEmpty(warPath)) {
        webapp.setResourceBase(DEFAULT_RESOURCE_BASE);
        webapp.setDescriptor(DEFAULT_WEB_XML_PATH);
    } else {
        webapp.setWar(warPath);
    }
    
    applySessionHandler(webapp);
    
    handler.addHandler(webapp);
    super.setHandler(handler);
}
 
Example #15
Source File: Jetty9Server.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Override
public void configure() throws Exception {
    server.addEventListener(mbeans());
    server.addConnector(plainConnector());

    ContextHandlerCollection handlers = new ContextHandlerCollection();
    deploymentManager.setContexts(handlers);

    createWebAppContext();

    JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler();
    webAppContext.setErrorHandler(errorHandler);
    webAppContext.setGzipHandler(gzipHandler());
    server.addBean(errorHandler);
    server.addBean(deploymentManager);

    HandlerCollection serverLevelHandlers = new HandlerCollection();
    serverLevelHandlers.setHandlers(new Handler[]{handlers});
    server.setHandler(serverLevelHandlers);

    performCustomConfiguration();
    server.setStopAtShutdown(true);
}
 
Example #16
Source File: ManagerApiTestServer.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * Start/run the server.
 */
public void start() throws Exception {
    long startTime = System.currentTimeMillis();
    System.out.println("**** Starting Server (" + getClass().getSimpleName() + ")");
    preStart();

    ContextHandlerCollection handlers = new ContextHandlerCollection();
    addModulesToJetty(handlers);

    // Create the server.
    int serverPort = serverPort();
    server = new Server(serverPort);
    server.setHandler(handlers);
    server.start();
    long endTime = System.currentTimeMillis();
    System.out.println("******* Started in " + (endTime - startTime) + "ms");
}
 
Example #17
Source File: EchoServer.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * Start/run the server.
 */
public EchoServer start() throws Exception {
    long startTime = System.currentTimeMillis();
    System.out.println("**** Starting Server (" + getClass().getSimpleName() + ") on port " +  port); //$NON-NLS-1$ //$NON-NLS-2$
    preStart();

    ContextHandlerCollection handlers = new ContextHandlerCollection();
    addModulesToJetty(handlers);

    // Create the server.
    server = new Server(port);
    server.setHandler(handlers);
    server.start();
    long endTime = System.currentTimeMillis();
    System.out.println("******* Started in " + (endTime - startTime) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
    return this;
}
 
Example #18
Source File: HttpServiceImpl.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
public void registerServlet(String context, Servlet servlet, Dictionary dictionary, HttpContext httpContext) throws ServletException, NamespaceException {

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        server.setHandler(contexts);
        ServletContextHandler root = new ServletContextHandler(contexts, "/",
                ServletContextHandler.SESSIONS);
        ServletHolder servletHolder = new ServletHolder(servlet);
        root.addServlet(servletHolder, context);

        if (!server.getServer().getState().equals(server.STARTED)) {
            try {
                server.start();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
 
Example #19
Source File: ApplicationServer.java    From rest-utils with Apache License 2.0 6 votes vote down vote up
private void finalizeHandlerCollection(HandlerCollection handlers, HandlerCollection wsHandlers) {
  /* DefaultHandler must come last eo ensure all contexts
   * have a chance to handle a request first */
  handlers.addHandler(new DefaultHandler());
  /* Needed for graceful shutdown as per `setStopTimeout` documentation */
  StatisticsHandler statsHandler = new StatisticsHandler();
  statsHandler.setHandler(handlers);

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(new Handler[]{
      statsHandler,
      wsHandlers
  });

  super.setHandler(wrapWithGzipHandler(contexts));
}
 
Example #20
Source File: EmbeddedServer.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
    throws Exception
{
    Server server = new Server( 8080 );

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );


    server.start();
    server.join();
}
 
Example #21
Source File: EmbeddedServer.java    From xdocreport.samples with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main( String[] args )
    throws Exception
{
    Server server = new Server( 8080 );

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );


    server.start();
    server.join();
}
 
Example #22
Source File: GatewayServer.java    From apiman with Apache License 2.0 5 votes vote down vote up
/**
 * Start/run the server.
 */
public void start() throws Exception {
    long startTime = System.currentTimeMillis();
    System.out.println("**** Starting Server (" + getClass().getSimpleName() + ")");

    ContextHandlerCollection handlers = new ContextHandlerCollection();
    addModulesToJetty(handlers);

    // Create the server.
    server = new Server(port);
    server.setHandler(handlers);
    server.start();
    long endTime = System.currentTimeMillis();
    System.out.println("******* Started in " + (endTime - startTime) + "ms");
}
 
Example #23
Source File: TowerServer.java    From binlake with Apache License 2.0 5 votes vote down vote up
/**
 * bind handler for right url
 */
private void bindHandler() {
    logger.debug("bindHandler");
    CreateZNodesHandler.register();
    RemoveNodeHandler.register();
    ExistNodeHandler.register();
    ResetCounterHandler.register();
    SetInstanceOffline.register();
    SetInstanceOnline.register();
    SetBinlogPosHandler.register();
    SetLeaderHandler.register();
    SetCandidateHandler.register();
    SetTerminalHandler.register();
    GetSlaveBinlogHandler.register();
    SetAdminHandler.register();

    ContextHandlerCollection contexts = new ContextHandlerCollection();

    Handler[] handlers = new Handler[ApiCenter.CONTEXTS.size()];
    int index = 0;

    for (ContextHandler handler : ApiCenter.CONTEXTS) {
        handlers[index++] = handler;
    }
    contexts.setHandlers(handlers);
    server.setHandler(contexts);
}
 
Example #24
Source File: Jetty9ServerTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldHaveAHandlerCollectionAtServerLevel_ToAllowRequestLoggingHandlerToBeAdded() throws Exception {
    jetty9Server.configure();
    jetty9Server.startHandlers();

    assertThat(serverLevelHandler, instanceOf(HandlerCollection.class));
    assertThat(serverLevelHandler, not(instanceOf(ContextHandlerCollection.class)));

    Handler[] contentsOfServerLevelHandler = ((HandlerCollection) serverLevelHandler).getHandlers();
    assertThat(contentsOfServerLevelHandler.length, is(1));
    assertThat(contentsOfServerLevelHandler[0], instanceOf(ContextHandlerCollection.class));
}
 
Example #25
Source File: ServersUtil.java    From joynr with Apache License 2.0 5 votes vote down vote up
public static Server startBounceproxy() throws Exception {
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[]{ createBounceproxyWebApp() });

    final int port = ServletUtil.findFreePort();
    Server server = startServer(contexts, port);
    return server;
}
 
Example #26
Source File: ServersUtil.java    From joynr with Apache License 2.0 5 votes vote down vote up
private static Server startBounceproxyController(String warFileName) throws Exception {
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[]{ createBounceproxyControllerWebApp(warFileName, "", null) });

    final int port = ServletUtil.findFreePort();
    Server server = startServer(contexts, port);
    String serverUrl = "http://localhost:" + port;
    String bounceProxyUrl = serverUrl + "/controller/";
    System.setProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL, bounceProxyUrl);
    return server;
}
 
Example #27
Source File: VmRuntimeWebAppDeployer.java    From appengine-java-vm-runtime with Apache License 2.0 5 votes vote down vote up
public VmRuntimeWebAppDeployer(
    @Name("contexts") ContextHandlerCollection contexts,
    @Name("webapp") String webapp,
    @Name("properties") Map<String,String> properties) {
  this.contexts=contexts;
  this.webapp=webapp;
  this.properties = properties;
}
 
Example #28
Source File: ServersUtil.java    From joynr with Apache License 2.0 5 votes vote down vote up
private static Server startSSLServer(ContextHandlerCollection contexts,
                                     SSLSettings settings,
                                     int port) throws IOException, Exception {

    System.setProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH, "http://localhost:" + port);
    logger.info("PORT: {}", System.getProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH));
    final Server jettyServer = new Server();

    HttpConfiguration https_config = new HttpConfiguration();
    https_config.setSecureScheme("https");
    https_config.setSecurePort(port);
    https_config.setOutputBufferSize(32768);
    https_config.addCustomizer(new SecureRequestCustomizer());

    // Configure SSL
    final SslContextFactory contextFactory = new SslContextFactory();
    contextFactory.setKeyStorePath(settings.getKeyStorePath());
    contextFactory.setTrustStorePath(settings.getTrustStorePath());
    contextFactory.setKeyStorePassword(settings.getKeyStorePassword());
    contextFactory.setTrustStorePassword(settings.getKeyStorePassword());
    contextFactory.setNeedClientAuth(true);

    // Create and use an SSL connector
    ServerConnector connector = new ServerConnector(jettyServer,
                                                    new SslConnectionFactory(contextFactory, "http/1.1"),
                                                    new HttpConnectionFactory(https_config));
    connector.setPort(port);
    connector.setAcceptQueueSize(1);
    jettyServer.setConnectors(new Connector[]{ connector });

    String serverUrl = "https://localhost:" + port;
    System.getProperties().setProperty(MessagingPropertyKeys.PROPERTY_SERVLET_HOST_PATH, serverUrl);

    jettyServer.setHandler(contexts);
    jettyServer.start();

    return jettyServer;
}
 
Example #29
Source File: ProtobufferExporter.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
private CXFServlet configStandaloneServer() {
    httpServer = new org.eclipse.jetty.server.Server(httpPort);
    Bus bus = BusFactory.getDefaultBus(true);
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    httpServer.setHandler(contexts);
    ServletContextHandler root = new ServletContextHandler(contexts, "/",
            ServletContextHandler.SESSIONS);
    CXFServlet cxf = new CXFServlet();
    cxf.setBus(bus);
    ServletHolder servlet = new ServletHolder(cxf);
    root.addServlet(servlet, "/cxf/*");
    return cxf;
}
 
Example #30
Source File: ServersUtil.java    From joynr with Apache License 2.0 5 votes vote down vote up
public static Server startSSLServers(SSLSettings settings, int port) throws Exception {
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[]{ createBounceproxyWebApp(), discoveryWebApp(), accessControlWebApp() });
    Server server = startSSLServer(contexts, settings, port);
    setBounceProxyUrl();
    setDirectoriesUrl();

    return server;
}