本文整理汇总了Java中org.apache.http.impl.DefaultBHttpServerConnectionFactory.INSTANCE属性的典型用法代码示例。如果您正苦于以下问题:Java DefaultBHttpServerConnectionFactory.INSTANCE属性的具体用法?Java DefaultBHttpServerConnectionFactory.INSTANCE怎么用?Java DefaultBHttpServerConnectionFactory.INSTANCE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.impl.DefaultBHttpServerConnectionFactory
的用法示例。
在下文中一共展示了DefaultBHttpServerConnectionFactory.INSTANCE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RequestListenerThread
public RequestListenerThread(
int port,
HttpService httpService,
SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
while (!createServerSocket(sf, port))
{
port++;
if (port >= 65535) {
System.out.println("Now the port is already in use,port number add 1");
ConsoleFactory.printToConsole("Now the port is already in use,port number add 1",true);
break;
}
}
monitorPort = port;
this.httpService = httpService;
}
示例2: RequestListenerThread
/**
* Default constructor which specifies the <code>port</code> to listen to
* for requests and the <code>handlers</code>, which specify how to handle
* the request.
*
* @param port
* the port to listen to
* @param handlers
* the handlers, which specify how to handle the different
* requests
*
* @throws IOException
* if some IO operation fails
*/
public RequestListenerThread(final int port,
final Map<String, IHandler> handlers) throws IOException {
super(port);
// Set up the HTTP protocol processor
final HttpProcessor httpproc = new ImmutableHttpProcessor(
new HttpResponseInterceptor[] { new ResponseDate(),
new ResponseServer(), new ResponseContent(),
new ResponseConnControl() });
// Set up request handlers
UriHttpRequestHandlerMapper registry = new UriHttpRequestHandlerMapper();
for (final Entry<String, IHandler> entry : handlers.entrySet()) {
registry.register(entry.getKey(), entry.getValue());
}
// Set up the HTTP service
httpService = new HttpService(httpproc, registry);
connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
}
示例3: RequestListenerThread
public RequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
}
示例4: RequestListenerThread
public RequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(100);
System.out.println("Request Listener Thread created");
}
示例5: GenericRequestListenerThread
public GenericRequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(1000);
//System.out.println("Request Listener Thread created");
}
示例6: LateBindingRequestListenerThread
public LateBindingRequestListenerThread(
final int port,
final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
// only 4 connections can run concurrently
connectionHandlerExecutor = Executors.newFixedThreadPool(22);
System.out.println("Request Listener Thread created");
}
示例7: RequestListenerThread
public RequestListenerThread(final int port,
final HttpService httpService, final SSLServerSocketFactory sf)
throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port)
: new ServerSocket(port);
this.httpService = httpService;
LimitedQueue<Runnable> blockingQueue = new LimitedQueue<Runnable>(
10);
executor = new java.util.concurrent.ThreadPoolExecutor(1, 10, 0L,
TimeUnit.MILLISECONDS, blockingQueue);
}
示例8: getHttpConnectionFactory
public HttpConnectionFactory<DefaultBHttpServerConnection> getHttpConnectionFactory() {
if (null == _connectionFactory) _connectionFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
return _connectionFactory;
}
示例9: RequestListenerThread
public RequestListenerThread(final int port, final HttpService httpService,
final SSLServerSocketFactory sf) throws IOException {
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
this.serversocket = sf != null ? sf.createServerSocket(port) : new ServerSocket(port);
this.httpService = httpService;
}
示例10: SimpleHttpServer
public SimpleHttpServer(int port, ConnectedAddressesProvider connectedAddressesProvider){
this.connFactory = DefaultBHttpServerConnectionFactory.INSTANCE;
// Set up the HTTP protocol processor
HttpProcessor httpproc = HttpProcessorBuilder.create()
.add(new ResponseDate())
.add(new ResponseServer("Test/1.1"))
.add(new ResponseContent())
.add(new ResponseConnControl()).build();
// Set up request handlers
UriHttpRequestHandlerMapper reqistry = new UriHttpRequestHandlerMapper();
reqistry.register("*", new HttpRequestHandlerNew(connectedAddressesProvider));
// Set up the HTTP service
httpService = new HttpService(httpproc, reqistry);
try {
serversocket = new ServerSocket(port, 1, InetAddress.getByName("127.0.0.1"));
System.out.println("Listening on port " + serversocket.getLocalPort());
while (!Thread.interrupted()) {
try {
// Set up HTTP connection
Socket socket = serversocket.accept();
System.out.println("Incoming connection from " + socket.getInetAddress());
HttpServerConnection conn = connFactory.createConnection(socket);
// Start worker thread
Thread t = new WorkerThread(httpService, conn);
t.setDaemon(true);
t.start();
} catch (InterruptedIOException ex) {
break;
} catch (IOException e) {
System.err.println("I/O error initialising connection thread: "
+ e.getMessage());
break;
}
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}