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


Java ServerConnector.setReuseAddress方法代碼示例

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


在下文中一共展示了ServerConnector.setReuseAddress方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDevServer

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
public static Server createDevServer(int port, String contextPath) {

        Server server = new Server();
        server.setStopAtShutdown(true);

        ServerConnector connector = new ServerConnector(server);
        // 設置服務端口
        connector.setPort(port);
        connector.setReuseAddress(false);
        server.setConnectors(new Connector[] {connector});

        // 設置web資源根路徑以及訪問web的根路徑
        WebAppContext webAppCtx = new WebAppContext(DEFAULT_APP_CONTEXT_PATH, contextPath);
        webAppCtx.setDescriptor(DEFAULT_APP_CONTEXT_PATH + "/WEB-INF/web.xml");
        webAppCtx.setResourceBase(DEFAULT_APP_CONTEXT_PATH);
        webAppCtx.setClassLoader(Thread.currentThread().getContextClassLoader());
        server.setHandler(webAppCtx);

        return server;
    }
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:21,代碼來源:Launcher.java

示例2: installListeners

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
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()]));
}
 
開發者ID:groupon,項目名稱:monsoon,代碼行數:23,代碼來源:ApiServer.java

示例3: createConnector

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
public ServerConnector createConnector(final Metric metric, final Server server, final ServerSocketChannel ch) {
    ServerConnector connector;
    if (connectorConfig.ssl().enabled()) {
        connector = new JDiscServerConnector(connectorConfig, metric, server, ch,
                                             newSslConnectionFactory(),
                                             newHttpConnectionFactory());
    } else {
        connector = new JDiscServerConnector(connectorConfig, metric, server, ch,
                                             newHttpConnectionFactory());
    }
    connector.setPort(connectorConfig.listenPort());
    connector.setName(connectorConfig.name());
    connector.setAcceptQueueSize(connectorConfig.acceptQueueSize());
    connector.setReuseAddress(connectorConfig.reuseAddress());
    double soLingerTimeSeconds = connectorConfig.soLingerTime();
    if (soLingerTimeSeconds == -1) {
        connector.setSoLingerTime(-1);
    } else {
        connector.setSoLingerTime((int)(soLingerTimeSeconds * 1000.0));
    }
    connector.setIdleTimeout((long)(connectorConfig.idleTimeout() * 1000.0));
    connector.setStopTimeout((long)(connectorConfig.stopTimeout() * 1000.0));
    return connector;
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:25,代碼來源:ConnectorFactory.java

示例4: setUp

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
@Before
@Override
public void setUp() throws Exception {
    server = new Server(9000);

    ServerConnector connector0 = new ServerConnector(server);
    connector0.setReuseAddress(true);
    server.setConnectors(new Connector[]{connector0});

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/service");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new EchoService()), "/EchoService");
    server.start();

    payload = readPayload();

    super.setUp();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:AbstractBaseEsbPerformanceIntegrationTest.java

示例5: start

import org.eclipse.jetty.server.ServerConnector; //導入方法依賴的package包/類
public synchronized void start() {
	if (started) {
		return;
	}
	try {
		QueuedThreadPool pool = new QueuedThreadPool(AppInfo.getInt("http.pool.maxThreads", 200),
				AppInfo.getInt("http.pool.minThreads", 8), AppInfo.getInt("http.pool.idleTimeout", 60000),
				new LinkedBlockingQueue<Runnable>(AppInfo.getInt("http.pool.queues", 1000)));
		server = new Server(pool);
		ServerConnector connector = new ServerConnector(server, null, null, null,
				AppInfo.getInt("http.connector.acceptors", 0), AppInfo.getInt("http.connector.selectors", 5),
				new HttpConnectionFactory());
		Log.get("HttpServer").info("listen port:" + port);
		String host = AppInfo.get("http.host");
		if (host != null && host.length() > 0) {
			connector.setHost(host);
		}
		connector.setPort(port);
		connector.setReuseAddress(true);

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

		if (AppInfo.getBoolean("http.jetty.session.enable", false)) {
			SessionHandler h = createSessionHandler();
			context.insertHandler(h);
		}
		server.setHandler(context);
		server.start();
		started = true;
	} catch (Exception e) {
		Log.printStack(e);
		System.exit(-1);
	}

}
 
開發者ID:youtongluan,項目名稱:sumk,代碼行數:46,代碼來源:JettyServer.java


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