当前位置: 首页>>代码示例>>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;未经允许,请勿转载。