Search in sources :

Example 1 with SocketConnector

use of org.eclipse.jetty.server.bio.SocketConnector in project wicket-dashboard by decebals.

the class Start method main.

public static void main(String[] args) throws Exception {
    Server server = new Server();
    SocketConnector connector = new SocketConnector();
    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    int port = Integer.parseInt(System.getProperty("jetty.port", "8081"));
    connector.setPort(port);
    server.addConnector(connector);
    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setServer(server);
    webAppContext.setContextPath("/");
    webAppContext.setWar("src/main/webapp");
    server.setHandler(webAppContext);
    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER (" + port + "), PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        // while (System.in.available() == 0) {
        // Thread.sleep(5000);
        // }
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) SocketConnector(org.eclipse.jetty.server.bio.SocketConnector)

Example 2 with SocketConnector

use of org.eclipse.jetty.server.bio.SocketConnector in project BeyondUPnP by kevinshine.

the class AndroidJettyServletContainer method addConnector.

@Override
public synchronized int addConnector(String host, int port) throws IOException {
    SocketConnector connector = new SocketConnector();
    connector.setHost(host);
    connector.setPort(port);
    // Open immediately so we can get the assigned local port
    connector.open();
    // Only add if open() succeeded
    server.addConnector(connector);
    // stats the connector if the server is started (server starts all connectors when started)
    if (server.isStarted()) {
        try {
            connector.start();
        } catch (Exception ex) {
            log.severe("Couldn't start connector: " + connector + " " + ex);
            throw new RuntimeException(ex);
        }
    }
    return connector.getLocalPort();
}
Also used : SocketConnector(org.eclipse.jetty.server.bio.SocketConnector) IOException(java.io.IOException)

Example 3 with SocketConnector

use of org.eclipse.jetty.server.bio.SocketConnector in project h2o-3 by h2oai.

the class JettyHTTPD method startHttp.

protected void startHttp() throws Exception {
    _server = new Server();
    //    QueuedThreadPool p = new QueuedThreadPool();
    //    p.setName("jetty-h2o");
    //    p.setMinThreads(3);
    //    p.setMaxThreads(50);
    //    p.setMaxIdleTimeMs(3000);
    //    _server.setThreadPool(p);
    Connector connector = new SocketConnector();
    connector.setHost(_ip);
    connector.setPort(_port);
    createServer(connector);
}
Also used : SslSocketConnector(org.eclipse.jetty.server.ssl.SslSocketConnector) SocketConnector(org.eclipse.jetty.server.bio.SocketConnector) Connector(org.eclipse.jetty.server.Connector) RequestServer(water.api.RequestServer) Server(org.eclipse.jetty.server.Server) SslSocketConnector(org.eclipse.jetty.server.ssl.SslSocketConnector) SocketConnector(org.eclipse.jetty.server.bio.SocketConnector)

Example 4 with SocketConnector

use of org.eclipse.jetty.server.bio.SocketConnector in project head by mifos.

the class AbstractServerLauncher method createServer.

protected Server createServer() {
    if (server != null) {
        throw new IllegalStateException("HTTP Server already running, stop it first before starting it again");
    }
    server = new Server();
    final SocketConnector connector = new SocketConnector();
    connector.setPort(port);
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    server.setConnectors(new Connector[] { connector });
    return server;
}
Also used : Server(org.eclipse.jetty.server.Server) SocketConnector(org.eclipse.jetty.server.bio.SocketConnector)

Aggregations

SocketConnector (org.eclipse.jetty.server.bio.SocketConnector)4 Server (org.eclipse.jetty.server.Server)3 IOException (java.io.IOException)1 Connector (org.eclipse.jetty.server.Connector)1 SslSocketConnector (org.eclipse.jetty.server.ssl.SslSocketConnector)1 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)1 RequestServer (water.api.RequestServer)1