当前位置: 首页>>代码示例>>Java>>正文


Java SocketConnector.setPort方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.bio.SocketConnector.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java SocketConnector.setPort方法的具体用法?Java SocketConnector.setPort怎么用?Java SocketConnector.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.bio.SocketConnector的用法示例。


在下文中一共展示了SocketConnector.setPort方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: main

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:virgo47,项目名称:javasimon,代码行数:39,代码来源:Start.java

示例9: main

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:flex-oss,项目名称:flex-ui,代码行数:32,代码来源:Start.java

示例10: setupJettyServer

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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;
}
 
开发者ID:Stratio,项目名称:Explorer,代码行数:13,代码来源:ExplorerServer.java

示例11: createListeners

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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 });
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:10,代码来源:JettyServer.java

示例12: createListeners

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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 } );
  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:12,代码来源:WebServer.java

示例13: build

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
@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);
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:9,代码来源:InternalConnectorFactory.java

示例14: main

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:sparsick,项目名称:ansible-docker-talk,代码行数:65,代码来源:Start.java

示例15: main

import org.eclipse.jetty.server.bio.SocketConnector; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:65,代码来源:Start.java


注:本文中的org.eclipse.jetty.server.bio.SocketConnector.setPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。