org.eclipse.jetty.server.Connector Java Examples

The following examples show how to use org.eclipse.jetty.server.Connector. 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: WebServerTask.java    From datacollector with Apache License 2.0 8 votes vote down vote up
@SuppressWarnings("squid:S2095")
private Server createRedirectorServer() {
  int unsecurePort = conf.get(HTTP_PORT_KEY, HTTP_PORT_DEFAULT);
  String hostname = conf.get(HTTP_BIND_HOST, HTTP_BIND_HOST_DEFAULT);

  QueuedThreadPool qtp = new QueuedThreadPool(25);
  qtp.setName(serverName + "Redirector");
  qtp.setDaemon(true);
  Server server = new LimitedMethodServer(qtp);
  InetSocketAddress addr = new InetSocketAddress(hostname, unsecurePort);
  ServerConnector connector = new ServerConnector(server);
  connector.setHost(addr.getHostName());
  connector.setPort(addr.getPort());
  server.setConnectors(new Connector[]{connector});

  ServletContextHandler context = new ServletContextHandler();
  context.addServlet(new ServletHolder(new RedirectorServlet()), "/*");
  context.setContextPath("/");
  server.setHandler(context);
  return server;
}
 
Example #2
Source File: PrometheusServer.java    From nifi with Apache License 2.0 6 votes vote down vote up
public PrometheusServer(int addr, SSLContextService sslContextService, ComponentLog logger, boolean needClientAuth, boolean wantClientAuth) throws Exception {
    PrometheusServer.logger = logger;
    this.server = new Server();
    this.handler = new ServletContextHandler(server, "/metrics");
    this.handler.addServlet(new ServletHolder(new MetricsServlet()), "/");

    SslContextFactory sslFactory = createSslFactory(sslContextService, needClientAuth, wantClientAuth);
    HttpConfiguration httpsConfiguration = new HttpConfiguration();
    httpsConfiguration.setSecureScheme("https");
    httpsConfiguration.setSecurePort(addr);
    httpsConfiguration.addCustomizer(new SecureRequestCustomizer());

    ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslFactory, "http/1.1"),
            new HttpConnectionFactory(httpsConfiguration));
    https.setPort(addr);
    this.server.setConnectors(new Connector[]{https});
    this.server.start();

}
 
Example #3
Source File: DeploymentCheck.java    From jetty-runtime with Apache License 2.0 6 votes vote down vote up
@Override
public void lifeCycleStarted(LifeCycle bean) {
  if (bean instanceof Server) {
    Server server = (Server)bean;
    Connector[] connectors = server.getConnectors();
    if (connectors == null || connectors.length == 0) {
      server.dumpStdErr();
      throw new IllegalStateException("No Connector");
    } else if (!Arrays.stream(connectors).allMatch(Connector::isStarted)) {
      server.dumpStdErr();
      throw new IllegalStateException("Connector not started");
    }
    ContextHandler context = server.getChildHandlerByClass(ContextHandler.class);
    if (context == null || !context.isAvailable()) {
      server.dumpStdErr();
      throw new IllegalStateException("No Available Context");
    }
  }
}
 
Example #4
Source File: ApiServer.java    From monsoon with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void installListeners(Server server, Collection<? extends InetSocketAddress> addresses) {
    final List<Connector> connectors = new ArrayList<>(addresses.size());

    for (InetSocketAddress address : addresses) {
        final ServerConnector server_connector = new ServerConnector(server);
        server_connector.setReuseAddress(true);
        if (address.getAddress() != null) {
            if (!address.getAddress().isAnyLocalAddress()) {
                LOG.log(Level.INFO, "Binding API server address: {0}", address.getAddress().getHostAddress());
                server_connector.setHost(address.getAddress().getHostAddress());
            }
        } else if (address.getHostString() != null) {
            LOG.log(Level.INFO, "Binding API server address name: {0}", address.getHostString());
            server_connector.setHost(address.getHostString());
        }
        LOG.log(Level.INFO, "Binding API server port: {0}", address.getPort());
        server_connector.setPort(address.getPort());
        connectors.add(server_connector);
    }

    server.setConnectors(connectors.toArray(new Connector[connectors.size()]));
}
 
Example #5
Source File: JettyWebSocketServer.java    From sequenceiq-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void startSSL(String keyStoreLocation, String keyStorePassword) throws Exception {
    Server server = new Server();

    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(keyStoreLocation);
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    ServerConnector https = new ServerConnector(server,
            new SslConnectionFactory(sslContextFactory, "http/1.1"),
            new HttpConnectionFactory(httpsConfig));
    https.setHost(host);
    https.setPort(port);
    server.setConnectors(new Connector[]{https});

    configureContextHandler(server);
    startServer(server);
}
 
Example #6
Source File: TestDynamicLoadingUrl.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static Pair<Server, Integer> runHttpServer(Map<String, Object> jars) throws Exception {
  final Server server = new Server();
  final ServerConnector connector = new ServerConnector(server);
  server.setConnectors(new Connector[] { connector });
  server.setHandler(new AbstractHandler() {
    @Override
    public void handle(String s, Request request, HttpServletRequest req, HttpServletResponse rsp)
      throws IOException {
      ByteBuffer b = (ByteBuffer) jars.get(s);
      if (b != null) {
        rsp.getOutputStream().write(b.array(), 0, b.limit());
        rsp.setContentType("application/octet-stream");
        rsp.setStatus(HttpServletResponse.SC_OK);
        request.setHandled(true);
      }
    }
  });
  server.start();
  return new Pair<>(server, connector.getLocalPort());
}
 
Example #7
Source File: TimbuctooV4.java    From timbuctoo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void serverStarted(Server server) {
  // Detect the port Jetty is listening on - works with configured and random ports
  for (final Connector connector : server.getConnectors()) {
    try {
      if ("application".equals(connector.getName())) {
        final ServerSocketChannel channel = (ServerSocketChannel) connector
          .getTransport();
        final InetSocketAddress socket = (InetSocketAddress) channel
          .getLocalAddress();

        timbuctooConfiguration.getUriHelper().notifyOfPort(socket.getPort());
      }
    } catch (Exception e) {
      LOG.error("No base url provided, and unable to get generate one myself", e);
    }
  }
}
 
Example #8
Source File: CompletionServer.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Starts the server.
 * 
 * @param host
 *            the host to listen
 * @param port
 *            the port to listen
 * @throws Exception
 *             if the server can't be started
 */
public void start(String host, int port) throws Exception {
    server = new Server();

    @SuppressWarnings("resource")
    final ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);
    connector.setHost(host);
    server.setConnectors(new Connector[] {connector });

    final ServletHandler servletHandler = new ServletHandler();
    server.setHandler(servletHandler);
    servletHandler.addServletWithMapping(AddInServlet.class, "/*");

    final HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {servletHandler, new DefaultHandler() });
    server.setHandler(handlers);

    server.start();
}
 
Example #9
Source File: ApiIT.java    From greenmail with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
    // Check if executed inside target directory or module directory
    String pathPrefix =new File(".").getCanonicalFile().getName().equals("target") ? "../" : "./";

    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(18080);
    connector.setHost("localhost");
    server.setConnectors(new Connector[]{connector});

    WebAppContext context = new WebAppContext();
    context.setDescriptor(pathPrefix + "src/main/webapp/WEB-INF/web.xml");
    context.setResourceBase(pathPrefix + "src/main/webapp");
    context.setContextPath("/");
    context.setParentLoaderPriority(true);

    server.setHandler(context);

    server.start();

    client = ClientBuilder.newClient();
    root = client.target("http://" + connector.getHost() + ':' + connector.getPort() + '/');
}
 
Example #10
Source File: AthenzJettyContainerTest.java    From athenz with Apache License 2.0 6 votes vote down vote up
@Test
public void testInitContainerInvalidHTTPPort() {
    
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "-10");
    System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
    
    AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
    assertNotNull(container);
    
    Server server = container.getServer();
    Connector[] connectors = server.getConnectors();
    assertEquals(connectors.length, 2);
    
    assertTrue(connectors[0].getProtocols().contains("http/1.1"));
    
    assertTrue(connectors[1].getProtocols().contains("http/1.1"));
    assertTrue(connectors[1].getProtocols().contains("ssl"));
}
 
Example #11
Source File: KaramelServiceApplication.java    From karamel with Apache License 2.0 6 votes vote down vote up
public int getPort(Environment environment) {
  int defaultPort = 9090;
  MutableServletContextHandler h = environment.getApplicationContext();
  if (h == null) {
    return defaultPort;
  }
  Server s = h.getServer();
  if (s == null) {
    return defaultPort;
  }
  Connector[] c = s.getConnectors();
  if (c != null && c.length > 0) {
    AbstractNetworkConnector anc = (AbstractNetworkConnector) c[0];
    if (anc != null) {
      return anc.getLocalPort();
    }
  }
  return defaultPort;
}
 
Example #12
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true if a listener on the HTTPS binding port is running.
 *
 * @return true if a listener on the HTTPS binding port is running.
 */
public boolean isHttpsBindActive()
{
    if ( isHttpBindEnabled() )
    {
        final int configuredPort = getHttpBindSecurePort();
        for ( final Connector connector : httpBindServer.getConnectors() )
        {
            if ( !( connector instanceof ServerConnector ) )
            {
                continue;
            }
            final int activePort = ( (ServerConnector) connector ).getLocalPort();

            if ( activePort == configuredPort )
            {
                return true;
            }
        }
    }
    return false;
}
 
Example #13
Source File: CrudApiHandler.java    From java-crud-api with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception
{
  // jetty config
  Properties properties = new Properties();
  properties.load(CrudApiHandler.class.getClassLoader().getResourceAsStream("jetty.properties"));
  HttpConfiguration config = new HttpConfiguration();
  config.setSendServerVersion( false );
  HttpConnectionFactory factory = new HttpConnectionFactory( config );
  Server server = new Server();
  ServerConnector connector = new ServerConnector(server,factory);
  server.setConnectors( new Connector[] { connector } );
  connector.setHost(properties.getProperty("host"));
  connector.setPort(Integer.parseInt(properties.getProperty("port")));
  server.addConnector(connector);
  server.setHandler(new CrudApiHandler());
  server.start();
  server.join();
}
 
Example #14
Source File: RestHelper.java    From kafka-connect-http with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {
    //flushCapturedRequests();
    server = new Server(0);
    ServerConnector connector = new ServerConnector(server);
    ServletContextHandler handler = new ServletContextHandler();
    ServletHolder testServ = new ServletHolder("test", RestHelper.class);
    testServ.setInitParameter("resourceBase",System.getProperty("user.dir"));
    testServ.setInitParameter("dirAllowed","true");
    handler.addServlet(testServ,"/test");
    handler.addServlet(testServ,"/someTopic");
    handler.addServlet(testServ,"/someKey");



    server.setHandler(handler);
    server.setConnectors(new Connector[]{connector});

    server.start();

    port = server.getURI().getPort();

}
 
Example #15
Source File: HttpServer.java    From heroic with Apache License 2.0 6 votes vote down vote up
private ServerConnector findServerConnector(Server server) {
    final Connector[] connectors = server.getConnectors();

    if (connectors.length == 0) {
        throw new IllegalStateException("server has no connectors");
    }

    for (final Connector c : connectors) {
        if (!(c instanceof ServerConnector)) {
            continue;
        }

        return (ServerConnector) c;
    }

    throw new IllegalStateException("Server has no associated ServerConnector");
}
 
Example #16
Source File: JettyStarterTest.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testCreateHttpServerUsingHttpsAndRedirection() {
    createHttpsContextProperties();

    server = jettyStarter.createHttpServer(8080, 8443, true, true);

    Connector[] connectors = server.getConnectors();

    assertThat(connectors).hasLength(2);
    assertThat(connectors[0].getName()).isEqualTo(JettyStarter.HTTP_CONNECTOR_NAME);
    assertThat(connectors[0].getConnectionFactory(HttpConnectionFactory.class)).isNotNull();
    assertThat(connectors[1].getName()).isEqualTo(JettyStarter.HTTPS_CONNECTOR_NAME.toLowerCase());
    assertThat(connectors[1].getConnectionFactory(HttpConnectionFactory.class)).isNotNull();
    assertThat(connectors[1].getConnectionFactory(SslConnectionFactory.class)).isNotNull();

    unsetHttpsContextProperties();
}
 
Example #17
Source File: JettyWebappTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception
{
  super.setUp();
  System.setProperty("solr.solr.home", SolrJettyTestBase.legacyExampleCollection1SolrHome());
  System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
  System.setProperty("solr.tests.doContainerStreamCloseAssert", "false");

  File dataDir = createTempDir().toFile();
  dataDir.mkdirs();

  System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
  String path = ExternalPaths.WEBAPP_HOME;

  server = new Server(port);
  // insecure: only use for tests!!!!
  server.setSessionIdManager(new DefaultSessionIdManager(server, new Random(random().nextLong())));
  new WebAppContext(server, path, context );

  ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
  connector.setIdleTimeout(1000 * 60 * 60);
  connector.setPort(0);
  server.setConnectors(new Connector[]{connector});
  server.setStopAtShutdown( true );

  server.start();
  port = connector.getLocalPort();
}
 
Example #18
Source File: JettyServer.java    From sumk with Apache License 2.0 5 votes vote down vote up
protected synchronized void init() {
	try {
		buildJettyProperties();
		server = new Server(new ExecutorThreadPool(HttpExcutors.getThreadPool()));
		ServerConnector connector = this.createConnector();
		Logs.http().info("listen port: {}", port);
		String host = StartContext.httpHost();
		if (host != null && host.length() > 0) {
			connector.setHost(host);
		}
		connector.setPort(port);

		server.setConnectors(new Connector[] { connector });
		ServletContextHandler context = createServletContextHandler();
		context.setContextPath(AppInfo.get("sumk.jetty.web.root", "/"));
		context.addEventListener(new SumkLoaderListener());
		addUserListener(context, Arrays.asList(ServletContextListener.class, ContextScopeListener.class));
		String resourcePath = AppInfo.get("sumk.jetty.resource");
		if (StringUtil.isNotEmpty(resourcePath)) {
			ResourceHandler resourceHandler = JettyHandlerSupplier.resourceHandlerSupplier().get();
			if (resourceHandler != null) {
				resourceHandler.setResourceBase(resourcePath);
				context.insertHandler(resourceHandler);
			}
		}

		if (AppInfo.getBoolean("sumk.jetty.session.enable", false)) {
			SessionHandler h = JettyHandlerSupplier.sessionHandlerSupplier().get();
			if (h != null) {
				context.insertHandler(h);
			}
		}
		server.setHandler(context);
	} catch (Throwable e) {
		Log.printStack("sumk.http", e);
		System.exit(1);
	}

}
 
Example #19
Source File: StartSolrJetty.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static void main( String[] args )
  {
    //System.setProperty("solr.solr.home", "../../../example/solr");

    Server server = new Server();
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
    // Set some timeout options to make debugging easier.
    connector.setIdleTimeout(1000 * 60 * 60);
    connector.setPort(8983);
    server.setConnectors(new Connector[] { connector });

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/solr");
    bb.setWar("webapp/web");

//    // START JMX SERVER
//    if( true ) {
//      MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
//      MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
//      server.getContainer().addEventListener(mBeanContainer);
//      mBeanContainer.start();
//    }

    server.setHandler(bb);

    try {
      System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
      server.start();
      while (System.in.available() == 0) {
        Thread.sleep(5000);
      }
      server.stop();
      server.join();
    }
    catch (Exception e) {
      e.printStackTrace();
      System.exit(100);
    }
  }
 
Example #20
Source File: HttpServer.java    From calcite-avatica with Apache License 2.0 5 votes vote down vote up
private ServerConnector configureServerConnector() {
  final ServerConnector connector = getServerConnector();
  connector.setIdleTimeout(60 * 1000);
  connector.setPort(port);
  server.setConnectors(new Connector[] { connector });
  return connector;
}
 
Example #21
Source File: MockServer.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
public MockServer() throws IOException {
    server = new Server();
    connector = new ServerConnector(server);
    connector.setPort(httpPort);

    HttpConfiguration https = new HttpConfiguration();
    https.addCustomizer(new SecureRequestCustomizer());

    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setTrustAll(true);
    sslContextFactory.setValidateCerts(false);
    sslContextFactory.setNeedClientAuth(false);
    sslContextFactory.setWantClientAuth(false);
    sslContextFactory.setValidatePeerCerts(false);
    sslContextFactory.setKeyStorePassword("password");
    sslContextFactory.setKeyStorePath(MockServer.class.getResource("mock-keystore.jks").toExternalForm());

    sslConnector = new ServerConnector(server,
                                       new SslConnectionFactory(sslContextFactory,
                                                                HttpVersion.HTTP_1_1.asString()),
                                       new HttpConnectionFactory(https));
    sslConnector.setPort(httpsPort);

    server.setConnectors(new Connector[] {connector, sslConnector});

    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder(new AlwaysSuccessServlet()), "/*");
    server.setHandler(context);
}
 
Example #22
Source File: EmbeddedJetty.java    From junit-servers with MIT License 5 votes vote down vote up
private ServerConnector findConnector() {
	log.debug("Extracting jetty server connector");
	for (Connector connector : server.getConnectors()) {
		if (connector instanceof ServerConnector) {
			return (ServerConnector) connector;
		}
	}

	log.warn("Cannot find jetty server connector");
	return null;
}
 
Example #23
Source File: HandleHttpRequest.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected int getPort() {
    for (final Connector connector : server.getConnectors()) {
        if (connector instanceof ServerConnector) {
            return ((ServerConnector) connector).getLocalPort();
        }
    }

    throw new IllegalStateException("Server is not listening on any ports");
}
 
Example #24
Source File: JettyUtil.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
public static void setSendServerVersion(Server server, boolean send) {
  //
  // Remove display of Server header
  // @see http://stackoverflow.com/questions/15652902/remove-the-http-server-header-in-jetty-9
  //
  
  for(Connector y : server.getConnectors()) {
    for(ConnectionFactory x  : y.getConnectionFactories()) {
      if(x instanceof HttpConnectionFactory) {
        ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(send);
      }
    }
  }    
}
 
Example #25
Source File: AbstractJettyMixin.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings( "ValueOfIncrementOrDecrementUsed" )
public final Interface[] interfacesServed()
{
    Connector[] connectors = server.getConnectors();
    Interface[] result = new Interface[ connectors.length ];
    int index = 0;
    for( Connector connector : connectors )
    {
        if( connector instanceof NetworkConnector )
        {
            NetworkConnector netConnector = (NetworkConnector) connector;
            String host = configuration().hostName().get();
            if( host == null )
            {
                host = netConnector.getHost();
                if( host == null ) // If serving all interfaces.
                {
                    try
                    {
                        host = InetAddress.getLocalHost().getHostAddress();
                    }
                    catch( UnknownHostException e )
                    {
                        throw new InternalError( "UnknownHost for local interface.", e );
                    }
                }
            }
            result[ index++] = new InterfaceImpl( host, netConnector.getPort(), servedProtocol() );
        }
    }
    return result;
}
 
Example #26
Source File: ApiServer.java    From modernmt with Apache License 2.0 5 votes vote down vote up
public ApiServer(ServerOptions options) {
    requestPool = new QueuedThreadPool(250);
    jettyServer = new Server(requestPool);

    ServerConnector connector = new ServerConnector(jettyServer);
    connector.setPort(options.port);
    jettyServer.setConnectors(new Connector[]{connector});

    Handler rootHandler;
    String contextPath = normalizeContextPath(options.contextPath);
    if (contextPath == null) {
        ServletHandler router = new ServletHandler();
        router.addServletWithMapping(Router.class, "/*");
        rootHandler = router;
    } else {
        ServletContextHandler contextHandler = new ServletContextHandler();
        contextHandler.setContextPath(contextPath);
        contextHandler.addServlet(Router.class, "/*");
        rootHandler = contextHandler;
    }

    MultipartConfigInjectionHandler multipartWrapper = new MultipartConfigInjectionHandler(
            options.temporaryDirectory, options.maxFileSize, options.maxRequestSize, options.fileSizeThreshold);
    multipartWrapper.setHandler(rootHandler);

    jettyServer.setHandler(multipartWrapper);
}
 
Example #27
Source File: JettyHttpServer.java    From cloudhopper-commons with Apache License 2.0 5 votes vote down vote up
public int getOpenConnections() {
if (this.server == null) return -1;
// fairly tough to calculate since we'll need to tally all connectors
// this should only be used as an estimate
int openConnections = 0;
for (Connector connector : server.getConnectors()) {
    openConnections += connector.getConnectedEndPoints().size();
}
return openConnections;
   }
 
Example #28
Source File: JettyHTTPServerEngineTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private int getMaxIdle(Connector connector) throws Exception {
    try {
        return (int)connector.getClass().getMethod("getMaxIdleTime").invoke(connector);
    } catch (NoSuchMethodException nex) {
        //jetty 9
    }
    return ((Long)connector.getClass().getMethod("getIdleTimeout").invoke(connector)).intValue();
}
 
Example #29
Source File: JettyServerThreadPoolMetricsTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() throws Exception {
    registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, new MockClock());

    Iterable<Tag> tags = Collections.singletonList(Tag.of("id", "0"));
    QueuedThreadPool threadPool = new InstrumentedQueuedThreadPool(registry, tags);
    threadPool.setMinThreads(32);
    threadPool.setMaxThreads(100);
    server = new Server(threadPool);
    ServerConnector connector = new ServerConnector(server);
    server.setConnectors(new Connector[] { connector });
    server.start();
}
 
Example #30
Source File: JettyWebSocketServer.java    From sequenceiq-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws Exception {
    Server server = new Server();

    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(new HttpConfiguration()));
    http.setHost(host);
    http.setPort(port);
    server.setConnectors(new Connector[]{http});

    configureContextHandler(server);
    startServer(server);
}