• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DefaultHttpServerIODispatch类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.http.impl.nio.DefaultHttpServerIODispatch的典型用法代码示例。如果您正苦于以下问题:Java DefaultHttpServerIODispatch类的具体用法?Java DefaultHttpServerIODispatch怎么用?Java DefaultHttpServerIODispatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DefaultHttpServerIODispatch类属于org.apache.http.impl.nio包,在下文中一共展示了DefaultHttpServerIODispatch类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: start

点赞 3

import org.apache.http.impl.nio.DefaultHttpServerIODispatch; //导入依赖的package包/类
public void start() throws Exception {
	// Create HTTP protocol basic processing chain
	HttpProcessor httpProcessor = HttpProcessorBuilder.create()
			.add(new ResponseDate()).add(new ResponseContent())
			.add(new ResponseConnControl()).build();
	// Create server
	HttpAsyncService protocolHandler = new HttpAsyncService(httpProcessor,
			uriMapper);
	NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory = new DefaultNHttpServerConnectionFactory();
	IOEventDispatch ioEventDispatch = new DefaultHttpServerIODispatch(
			protocolHandler, connFactory);
	IOReactorConfig config = IOReactorConfig.custom()
			.setIoThreadCount(threads).setSoReuseAddress(true).build();
	ListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
	// Start server
	ioReactor.listen(new InetSocketAddress(port));
	ioReactor.execute(ioEventDispatch);
}
 

开发者ID:fxbonnet,
项目名称:nio-benchmark,
代码行数:19,
代码来源:AsyncServer.java

示例2: OppoMessenger

点赞 2

import org.apache.http.impl.nio.DefaultHttpServerIODispatch; //导入依赖的package包/类
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
public OppoMessenger(final String remoteHost, final int remotePort, final int localPort,
                     final HttpClientService httpClient)
        throws IOException {
    this.httpClient = httpClient;

    // Set up the server
    final HttpProcessor processor = HttpProcessorBuilder.create()
            .add(new ResponseContent())
            .add(new ResponseContentEncoding())
            .add(new ResponseConnControl())
            .build();

    final HttpAsyncService service = new HttpAsyncService(processor, mapper);
    final NHttpConnectionFactory<DefaultNHttpServerConnection> connectionFactory = new DefaultNHttpServerConnectionFactory(ConnectionConfig.DEFAULT);
    final IOEventDispatch dispatch = new DefaultHttpServerIODispatch(service, connectionFactory);

    server = new DefaultListeningIOReactor(IOReactorConfig.DEFAULT);
    server.listen(new InetSocketAddress(localPort));

    new Thread(new Runnable() {
        @Override public void run() {
            try {
                server.execute(dispatch);
            } catch (final IOException e) {
                logger().level(Error).message("HTTP server failed").error(e).log();
            }
        }
    }, "Oppo HTTP server");

    // Set up the client
    deviceUrlBase = "http://" + remoteHost + ':' + remotePort + '/';
}
 

开发者ID:markmckenna,
项目名称:LibOppo,
代码行数:34,
代码来源:OppoMessenger.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)