Java 类org.eclipse.jetty.server.bio.SocketConnector 实例源码

项目:jetty-embed-reverse-proxy-example    文件:ProxyServer.java   
private static void reverseProxy() throws Exception{
  Server server = new Server();

  SocketConnector connector = new SocketConnector();
  connector.setHost("127.0.0.1");
  connector.setPort(8888);

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

  // Setup proxy handler to handle CONNECT methods
  ConnectHandler proxy = new ConnectHandler();
  server.setHandler(proxy);

  // Setup proxy servlet
  ServletContextHandler context = new ServletContextHandler(proxy, "/", ServletContextHandler.SESSIONS);
  ServletHolder proxyServlet = new ServletHolder(ProxyServlet.Transparent.class);
  proxyServlet.setInitParameter("ProxyTo", "https://localhost:54321/");
  proxyServlet.setInitParameter("Prefix", "/");
  context.addServlet(proxyServlet, "/*");

  server.start();
}
项目:BeyondUPnP    文件:AndroidJettyServletContainer.java   
@Override
synchronized public 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();
}
项目:https-github.com-h2oai-h2o-3    文件:JettyHTTPD.java   
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();
    if (_ip != null) {
      connector.setHost(_ip);
    }
    connector.setPort(_port);

    createServer(connector);
  }
项目:gitblit    文件:GitBlitServer.java   
/**
 * Creates an http connector.
 * 
 * @param useNIO
 * @param port
 * @param threadPoolSize
 * @return an http connector
 */
private Connector createConnector(boolean useNIO, int port, int threadPoolSize) {
    Connector connector;
    if (useNIO) {
        logger.info("Setting up NIO SelectChannelConnector on port " + port);
        SelectChannelConnector nioconn = new SelectChannelConnector();
        nioconn.setSoLingerTime(-1);
        if (threadPoolSize > 0) {
            nioconn.setThreadPool(new QueuedThreadPool(threadPoolSize));
        }
        connector = nioconn;
    } else {
        logger.info("Setting up SocketConnector on port " + port);
        SocketConnector sockconn = new SocketConnector();
        if (threadPoolSize > 0) {
            sockconn.setThreadPool(new QueuedThreadPool(threadPoolSize));
        }
        connector = sockconn;
    }

    connector.setPort(port);
    connector.setMaxIdleTime(30000);
    return connector;
}
项目:IRCBlit    文件:GitBlitServer.java   
/**
 * Creates an http connector.
 * 
 * @param useNIO
 * @param port
 * @return an http connector
 */
private Connector createConnector(boolean useNIO, int port) {
    Connector connector;
    if (useNIO) {
        logger.info("Setting up NIO SelectChannelConnector on port " + port);
        SelectChannelConnector nioconn = new SelectChannelConnector();
        nioconn.setSoLingerTime(-1);
        nioconn.setThreadPool(new QueuedThreadPool(20));
        connector = nioconn;
    } else {
        logger.info("Setting up SocketConnector on port " + port);
        SocketConnector sockconn = new SocketConnector();
        connector = sockconn;
    }

    connector.setPort(port);
    connector.setMaxIdleTime(30000);
    return connector;
}
项目:pentaho-kettle    文件:WebServer.java   
/**
 * Set up jetty options to the connector
 *
 * @param connector
 */
protected void setupJettyOptions( SocketConnector connector ) {
  if ( validProperty( Const.KETTLE_CARTE_JETTY_ACCEPTORS ) ) {
    connector.setAcceptors( Integer.parseInt( System.getProperty( Const.KETTLE_CARTE_JETTY_ACCEPTORS ) ) );
    log.logBasic(
        BaseMessages.getString( PKG, "WebServer.Log.ConfigOptions", "acceptors", connector.getAcceptors() ) );
  }

  if ( validProperty( Const.KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE ) ) {
    connector
        .setAcceptQueueSize( Integer.parseInt( System.getProperty( Const.KETTLE_CARTE_JETTY_ACCEPT_QUEUE_SIZE ) ) );
    log.logBasic( BaseMessages
        .getString( PKG, "WebServer.Log.ConfigOptions", "acceptQueueSize", connector.getAcceptQueueSize() ) );
  }

  if ( validProperty( Const.KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME ) ) {
    connector.setLowResourceMaxIdleTime(
        Integer.parseInt( System.getProperty( Const.KETTLE_CARTE_JETTY_RES_MAX_IDLE_TIME ) ) );
    log.logBasic( BaseMessages.getString( PKG, "WebServer.Log.ConfigOptions", "lowResourcesMaxIdleTime",
        connector.getLowResourceMaxIdleTime() ) );
  }

}
项目:pentaho-kettle    文件:WebServerTest.java   
@Test
public void testNoExceptionAndUsingDefaultServerValue_WhenJettyOptionSetAsInvalidValue() throws Exception {
  System.setProperty( Const.KETTLE_CARTE_JETTY_ACCEPTORS, "TEST" );
  try {
    webServerNg =
        new WebServer( logMock, trMapMock, jbMapMock, sRepoMock, detections, HOST_NAME, PORT + 1, SHOULD_JOIN, null );
  } catch ( NumberFormatException nmbfExc ) {
    fail( "Should not have thrown any NumberFormatException but it does: " + nmbfExc );
  }
  assertEquals( getSocketConnectors( webServerNg ).size(), EXPECTED_CONNECTORS_SIZE );
  for ( SocketConnector sc : getSocketConnectors( webServerNg ) ) {
    assertEquals( defSocketConnector.getAcceptors(), sc.getAcceptors() );
  }
  webServerNg.setWebServerShutdownHandler( null ); // disable system.exit
  webServerNg.stopServer();
}
项目:pentaho-kettle    文件:WebServerTest.java   
@Test
public void testNoExceptionAndUsingDefaultServerValue_WhenJettyOptionSetAsEmpty() throws Exception {
  System.setProperty( Const.KETTLE_CARTE_JETTY_ACCEPTORS, EMPTY_STRING );
  try {
    webServerNg =
        new WebServer( logMock, trMapMock, jbMapMock, sRepoMock, detections, HOST_NAME, PORT + 1, SHOULD_JOIN, null );
  } catch ( NumberFormatException nmbfExc ) {
    fail( "Should not have thrown any NumberFormatException but it does: " + nmbfExc );
  }
  assertEquals( getSocketConnectors( webServerNg ).size(), EXPECTED_CONNECTORS_SIZE );
  for ( SocketConnector sc : getSocketConnectors( webServerNg ) ) {
    assertEquals( defSocketConnector.getAcceptors(), sc.getAcceptors() );
  }
  webServerNg.setWebServerShutdownHandler( null ); // disable system.exit
  webServerNg.stopServer();
}
项目:Unicorn    文件:StartEapWebInterface.java   
public static void main(final String[] args) throws Exception {
    final int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    final Server server = new Server();
    final SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8081);
    server.addConnector(connector);

    final WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        // System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (final Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:Todo-Jersey-Spring-MyBatis    文件:Starter.java   
public static void main(String[] args) throws Exception {
    int timeout = 60 * 60 * 1000;

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8888);
    server.addConnector(connector);

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");


    server.setHandler(bb);

    try {
        log.info(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        //noinspection ResultOfMethodCallIgnored
        System.in.read();
        log.info(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:search    文件:JettyWebappTest.java   
@Override
public void setUp() throws Exception 
{
  super.setUp();
  System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);
  System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));

  File dataDir = createTempDir();
  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 HashSessionIdManager(new Random(random().nextLong())));
  new WebAppContext(server, path, context );

  SocketConnector connector = new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(0);
  server.setConnectors(new Connector[]{connector});
  server.setStopAtShutdown( true );

  server.start();
  port = connector.getLocalPort();
}
项目:DroidDLNA    文件:JettyServletContainer.java   
@Override
synchronized public 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);

    return connector.getLocalPort();
}
项目:teiid    文件:TestODataIntegration.java   
@BeforeClass
public static void before() throws Exception {
    teiid = new EmbeddedServer();
    teiid.start(new EmbeddedConfiguration());
    teiid.addTranslator(LoopbackExecutionFactory.class);

    server = new Server();

    SocketConnector connector = new SocketConnector();
    server.setConnectors(new Connector[] {connector});

    ServletHandler handler = new ServletHandler();
       server.setHandler(handler);

       handler.addFilterWithMapping(new FilterHolder(new ODataFilter() {
        @Override
        public Client buildClient(String vdbName, int version, Properties props) {
            LocalClient c=  new LocalClient(vdbName, version, props);
            c.setDriver(teiid.getDriver());
            return c;
        }
       }), "/*", 0);
       handler.addServletWithMapping(ODataServlet.class, "/*");
       server.start();
       port = connector.getLocalPort();
       deployVDB();
}
项目:h2o-3    文件:AbstractHTTPD.java   
protected void startHttp() throws Exception {
  _server = new Server();

  Connector connector=new SocketConnector();
  connector.setHost(_ip);
  connector.setPort(_port);

  createServer(connector);
}
项目:NYBC    文件:JettyWebappTest.java   
@Override
public void setUp() throws Exception 
{
  super.setUp();
  System.setProperty("solr.solr.home", ExternalPaths.EXAMPLE_HOME);

  File dataDir = new File(LuceneTestCase.TEMP_DIR,
      getClass().getName() + "-" + System.currentTimeMillis());
  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 HashSessionIdManager(new Random(random().nextLong())));
  new WebAppContext(server, path, context );

  SocketConnector connector = new SocketConnector();
  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(0);
  server.setConnectors(new Connector[]{connector});
  server.setStopAtShutdown( true );

  server.start();
  port = connector.getLocalPort();
}
项目:socom    文件:DeploySocom.java   
public void startServer(int port) {
    Server server = new Server(port);
    SocketConnector http = new SocketConnector();
    server.addConnector(http);

    // set up gwt handler
    WebAppContext gwthandler = new WebAppContext();     
    gwthandler.setResourceBase("./war");
    gwthandler.setDescriptor("./war/WEB-INF/web.xml");
    gwthandler.setContextPath("/web");
    gwthandler.setParentLoaderPriority(true);

    ServletContextHandler servletHandler = new ServletContextHandler(server, "/servlet", true, true);
    servletHandler.setMaxFormContentSize(50000000 /* 50 MB */);
    servletHandler.addServlet(new ServletHolder(this), "/");

    HandlerList handlers = new HandlerList();
    handlers.addHandler(servletHandler);
    handlers.addHandler(gwthandler);

    server.setHandler(handlers);

    try {
        server.start();
        logger.Info("***Server is running on " + InetAddress.getLocalHost() + "@" + port);
    } catch (UnknownHostException e) {
        logger.Info("***Server is running on port " + port);
    } catch (Throwable t) {
        if (t.getMessage().contains("Permission")) {
            logger.Fatal("Failed to start Server. Right permissions? (Only superusers can use ports < 1024)");
            t.printStackTrace();
        } else {
            logger.Fatal("Failed to start Server. Already Running?");
            t.printStackTrace();
        }
        return;
    }

    this.socom = new SocomCore();
}
项目:javasimon    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = 3600;

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        //noinspection ResultOfMethodCallIgnored
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:flex-ui    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(PORT);
    server.addConnector(connector);

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar(getRootPath().resolve(WAR_PATH).toString());

    server.setHandler(bb);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:Explorer    文件:ExplorerServer.java   
private static Server setupJettyServer(int port) {
    int timeout = 1000 * 30;
    final Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(port);
    server.addConnector(connector);
    return server;
}
项目:gitiles    文件:DevServer.java   
private Connector[] connectors() {
  Connector c = new SocketConnector();
  c.setHost(null);
  c.setPort(cfg.getInt("gitiles", null, "port", 8080));
  c.setStatsOn(false);
  return new Connector[]{c};
}
项目:pdi-agile-bi-plugin    文件:JettyServer.java   
private void createListeners() {
  SocketConnector connector = new SocketConnector();
  connector.setPort(port);
  connector.setHost(hostname);
  connector.setName(hostname);
  log.logBasic("WebServer.Log.CreateListener " + hostname + ":" + port);

  server.setConnectors(new Connector[] { connector });
}
项目:pentaho-kettle    文件:WebServer.java   
private void createListeners() {

    SocketConnector connector = getConnector();
    setupJettyOptions( connector );
    connector.setPort( port );
    connector.setHost( hostname );
    connector.setName( BaseMessages.getString( PKG, "WebServer.Log.KettleHTTPListener", hostname ) );
    log.logBasic( BaseMessages.getString( PKG, "WebServer.Log.CreateListener", hostname, "" + port ) );

    server.setConnectors( new Connector[] { connector } );
  }
项目:pentaho-kettle    文件:WebServer.java   
private SocketConnector getConnector() {
  if ( sslConfig != null ) {
    log.logBasic( BaseMessages.getString( PKG, "WebServer.Log.SslModeUsing" ) );
    SslSocketConnector connector = new SslSocketConnector();
    connector.setKeystore( sslConfig.getKeyStore() );
    connector.setPassword( sslConfig.getKeyStorePassword() );
    connector.setKeyPassword( sslConfig.getKeyPassword() );
    connector.setKeystoreType( sslConfig.getKeyStoreType() );
    return connector;
  } else {
    return new SocketConnector();
  }

}
项目:pentaho-kettle    文件:WebServerTest.java   
@Test
public void testJettyOption_AcceptorsSetUp() throws Exception {
  assertEquals( getSocketConnectors( webServer ).size(), EXPECTED_CONNECTORS_SIZE );
  for ( SocketConnector sc : getSocketConnectors( webServer ) ) {
    assertEquals( EXPECTED_ACCEPTORS, sc.getAcceptors() );

  }

}
项目:pentaho-kettle    文件:WebServerTest.java   
@Test
public void testJettyOption_AcceptQueueSizeSetUp() throws Exception {
  assertEquals( getSocketConnectors( webServer ).size(), EXPECTED_CONNECTORS_SIZE );
  for ( SocketConnector sc : getSocketConnectors( webServer ) ) {
    assertEquals( EXPECTED_ACCEPT_QUEUE_SIZE, sc.getAcceptQueueSize() );
  }

}
项目:pentaho-kettle    文件:WebServerTest.java   
@Test
public void testJettyOption_LowResourceMaxIdleTimeSetUp() throws Exception {
  assertEquals( getSocketConnectors( webServer ).size(), EXPECTED_CONNECTORS_SIZE );
  for ( SocketConnector sc : getSocketConnectors( webServer ) ) {
    assertEquals( EXPECTED_RES_MAX_IDLE_TIME, sc.getLowResourceMaxIdleTime() );
  }

}
项目:pentaho-kettle    文件:WebServerTest.java   
private List<SocketConnector> getSocketConnectors( WebServer wServer ) {
  List<SocketConnector> sConnectors = new ArrayList<SocketConnector>();
  Connector[] connectors = wServer.getServer().getConnectors();
  for ( Connector cn : connectors ) {
    if ( cn instanceof SocketConnector ) {
      sConnectors.add( (SocketConnector) cn );
    }
  }
  return sConnectors;
}
项目:grails-lightweight-deploy    文件:InternalConnectorFactory.java   
@Override
public Set<? extends AbstractConnector> build() {
    final SocketConnector connector = new SocketConnector();
    connector.setPort(getConfiguration().getAdminPort());
    connector.setThreadPool(new QueuedThreadPool(8));
    connector.setName(INTERNAL_CONNECTOR_NAME);
    return Sets.newHashSet(connector);
}
项目:ansible-docker-talk    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:vlo-curation    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8090);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:Intercloud    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:search    文件:StartSolrJetty.java   
public static void main( String[] args ) 
  {
    //System.setProperty("solr.solr.home", "../../../example/solr");

    Server server = new Server();
    SocketConnector connector = new SocketConnector();
    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    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);
    }
  }
项目:directory-fortress-commander    文件:StartExamples.java   
/**
 * Main function, starts the jetty server.
 * 
 * @param args
 */
public static void main(String[] args)
{
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // fortress-rest navigation (iff enabled in fortress.properties)
       System.setProperty("version", "2.0.0");
       System.setProperty( GlobalIds.IS_JETTY_SERVER, "true");

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(8081);
    server.setConnectors(new Connector[] { connector });

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    //bb.setContextPath("/rbac");
       bb.setContextPath("/fortress-web");
    bb.setWar("src/main/webapp");

       // Setup the test security realm, its name must match what's in the web.xml's 'realm-name' tag:
       HashLoginService dummyLoginService = new HashLoginService(
         "SentrySecurityRealm");
       dummyLoginService.setConfig("src/test/resources/jetty-users.properties");
       bb.getSecurityHandler().setLoginService( dummyLoginService );
    server.setHandler(bb);

    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    server.getContainer().addEventListener(mBeanContainer);

    try
    {
        mBeanContainer.start();
        server.start();
        server.join();
    }
    catch (Exception e)
    {
        e.printStackTrace();
        System.exit(100);
    }
}
项目:practicalwicket    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:NYBC    文件:StartSolrJetty.java   
public static void main( String[] args ) 
  {
    //System.setProperty("solr.solr.home", "../../../example/solr");

    Server server = new Server();
    SocketConnector connector = new SocketConnector();
    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    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);
    }
  }
项目:Invoice-Keeper    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:wicket-bootstrap-example    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/main/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:wicket-memcached-data-store    文件:Start.java   
public static void main(String[] args) throws Exception {
    int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(timeout);
    connector.setSoLingerTime(-1);
    connector.setPort(8080);
    server.addConnector(connector);

    Resource keystore = Resource.newClassPathResource("/keystore");
    if (keystore != null && keystore.exists()) {
        // if a keystore for a SSL certificate is available, start a SSL
        // connector on port 8443.
        // By default, the quickstart comes with a Apache Wicket Quickstart
        // Certificate that expires about half way september 2021. Do not
        // use this certificate anywhere important as the passwords are
        // available in the source.

        connector.setConfidentialPort(8443);

        SslContextFactory factory = new SslContextFactory();
        factory.setKeyStoreResource(keystore);
        factory.setKeyStorePassword("wicket");
        factory.setTrustStoreResource(keystore);
        factory.setKeyManagerPassword("wicket");
        SslSocketConnector sslConnector = new SslSocketConnector(factory);
        sslConnector.setMaxIdleTime(timeout);
        sslConnector.setPort(8443);
        sslConnector.setAcceptors(4);
        server.addConnector(sslConnector);

        System.out.println("SSL access to the quickstart has been enabled on port 8443");
        System.out.println("You can access the application using SSL on https://localhost:8443");
        System.out.println();
    }

    WebAppContext bb = new WebAppContext();
    bb.setServer(server);
    bb.setContextPath("/");
    bb.setWar("src/test/webapp");

    // START JMX SERVER
    // 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();
        System.in.read();
        System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
项目:Anuenue    文件:SimpleAnuenueInstanceFactory.java   
/**
 * Create Anuenue instance for testing.
 * @param port port number
 * @param indexDir index directory
 * @param clusterConfigFile config file
 * @return Jetty Server
 * @throws Exception in case of any error.
 */
public static Server createSolrInstance(final int port,
        final String indexDir, final String clusterConfigFile) throws Exception {

    FileUtils.deleteQuietly(new File(indexDir));
    Server server = new Server();
    SocketConnector connector = new SocketConnector();
    connector.setSoLingerTime(-1);
    connector.setPort(port);
    server.setConnectors(new Connector[] { connector });

    String currentDir = new File(".").getAbsoluteFile().getParent();
    LOG.info("current dir: " + currentDir);

    /* setting system properties */
    System.setProperty("solr.solr.home", currentDir + File.separator + "solr");
    System.setProperty("solr.data.dir", indexDir);
    System.setProperty("jetty.home", currentDir);
    System.setProperty("anuenue.hostName", "localhost");
    System.setProperty("anuenue.basePort", Integer.toString(port));

    //org.eclipse.jetty.util.log.Log.setLog(null);

    if (clusterConfigFile != null) {
        System.setProperty("anuenue.clusterconf", clusterConfigFile);
    }

    // add solr.war
    WebAppContext solrWac = new WebAppContext();
    // needed to load external lib
    solrWac.setClassLoader(Thread.currentThread().getContextClassLoader());
    solrWac.setServer(server);
    solrWac.setContextPath("/solr");
    solrWac.setWar("webapps" + File.separator + "solr.war");

    // add anuenue.war
    WebAppContext anuenueWac = new WebAppContext();
    anuenueWac.setServer(server);
    anuenueWac.setWar("webapps" + File.separator + "anuenue.war");
    anuenueWac.setContextPath("/anuenue");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { solrWac, anuenueWac});
    server.setHandler(handlers);
    server.setStopAtShutdown(true);
    server.start();
    return server;
}
项目:serverside-todomvc    文件:Start.java   
public static void main(String[] args) throws Exception {
  int timeout = (int) Duration.ONE_HOUR.getMilliseconds();

  Server server = new Server();
  SocketConnector connector = new SocketConnector();

  // Set some timeout options to make debugging easier.
  connector.setMaxIdleTime(timeout);
  connector.setSoLingerTime(-1);
  connector.setPort(8080);
  server.addConnector(connector);

  Resource keystore = Resource.newClassPathResource("/keystore");
  if (keystore != null && keystore.exists()) {
    // if a keystore for a SSL certificate is available, start a SSL
    // connector on port 8443.
    // By default, the quickstart comes with a Apache Wicket Quickstart
    // Certificate that expires about half way september 2021. Do not
    // use this certificate anywhere important as the passwords are
    // available in the source.

    connector.setConfidentialPort(8443);

    SslContextFactory factory = new SslContextFactory();
    factory.setKeyStoreResource(keystore);
    factory.setKeyStorePassword("wicket");
    factory.setTrustStoreResource(keystore);
    factory.setKeyManagerPassword("wicket");
    SslSocketConnector sslConnector = new SslSocketConnector(factory);
    sslConnector.setMaxIdleTime(timeout);
    sslConnector.setPort(8443);
    sslConnector.setAcceptors(4);
    server.addConnector(sslConnector);

    System.out.println("SSL access to the quickstart has been enabled on port 8443");
    System.out.println("You can access the application using SSL on https://localhost:8443");
    System.out.println();
  }

  WebAppContext bb = new WebAppContext();
  bb.setServer(server);
  bb.setContextPath("/examples-java-wicket");
  bb.setWar("src/main/webapp");

  // START JMX SERVER
  // 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();
    System.in.read();
    System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
    server.stop();
    server.join();
  }
  catch (Exception e) {
    e.printStackTrace();
    System.exit(1);
  }
}