當前位置: 首頁>>代碼示例>>Java>>正文


Java SocketConnector類代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.bio.SocketConnector的典型用法代碼示例。如果您正苦於以下問題:Java SocketConnector類的具體用法?Java SocketConnector怎麽用?Java SocketConnector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SocketConnector類屬於org.eclipse.jetty.server.bio包,在下文中一共展示了SocketConnector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reverseProxy

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
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();
}
 
開發者ID:tomkraljevic,項目名稱:jetty-embed-reverse-proxy-example,代碼行數:23,代碼來源:ProxyServer.java

示例2: addConnector

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:kevinshine,項目名稱:BeyondUPnP,代碼行數:24,代碼來源:AndroidJettyServletContainer.java

示例3: startHttp

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
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);
  }
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:19,代碼來源:JettyHTTPD.java

示例4: createConnector

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:32,代碼來源:GitBlitServer.java

示例5: createConnector

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:BullShark,項目名稱:IRCBlit,代碼行數:26,代碼來源:GitBlitServer.java

示例6: setupJettyOptions

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
/**
 * 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() ) );
  }

}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:28,代碼來源:WebServer.java

示例7: testNoExceptionAndUsingDefaultServerValue_WhenJettyOptionSetAsInvalidValue

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:17,代碼來源:WebServerTest.java

示例8: testNoExceptionAndUsingDefaultServerValue_WhenJettyOptionSetAsEmpty

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:17,代碼來源:WebServerTest.java

示例9: main

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
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);
	}
}
 
開發者ID:bptlab,項目名稱:Unicorn,代碼行數:38,代碼來源:StartEapWebInterface.java

示例10: main

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Ellychou,項目名稱:Todo-Jersey-Spring-MyBatis,代碼行數:34,代碼來源:Starter.java

示例11: setUp

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:29,代碼來源:JettyWebappTest.java

示例12: addConnector

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:15,代碼來源:JettyServletContainer.java

示例13: before

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:28,代碼來源:TestODataIntegration.java

示例14: startHttp

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
protected void startHttp() throws Exception {
  _server = new Server();

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

  createServer(connector);
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:10,代碼來源:AbstractHTTPD.java

示例15: setUp

import org.eclipse.jetty.server.bio.SocketConnector; //導入依賴的package包/類
@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();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:28,代碼來源:JettyWebappTest.java


注:本文中的org.eclipse.jetty.server.bio.SocketConnector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。