protected HttpServerConnectionUpnpStream(ProtocolFactory protocolFactory, HttpServerConnection connection, final HttpParams params) { super(protocolFactory); this.connection = connection; this.params = params; // The Date header is recommended in UDA, need to document the requirement in StreamServer interface? httpProcessor.addInterceptor(new ResponseDate()); // The Server header is only required for Control so callers have to add it to UPnPMessage // httpProcessor.addInterceptor(new ResponseServer()); httpProcessor.addInterceptor(new ResponseContent()); httpProcessor.addInterceptor(new ResponseConnControl()); httpService = new UpnpHttpService( httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory() ); httpService.setParams(params); }
public void examine(final HttpServerConnection connection) { if (null != connection && log.isDebugEnabled() && !connection.isOpen()) { log.debug("Connection [{}] closed. Capturing metrics.", connection); final HttpConnectionMetrics metrics = connection.getMetrics(); final WeakReference<StringBuilder> sb = new WeakReference<StringBuilder>(new StringBuilder("{'connection_metrics':{'requests':'")); sb.get().append(metrics.getRequestCount()).append("','responses':'").append(metrics.getResponseCount()) .append("', 'received_bytes':'").append(metrics.getReceivedBytesCount()).append("', 'sent_bytes':'").append(metrics.getSentBytesCount()).append("'}}"); log.debug("[{}]", sb.get().toString()); } }
public void run() { System.out.println("Listening on port " + serversocket.getLocalPort()); ConsoleFactory.printToConsole("Listening on port " + serversocket.getLocalPort(),true); while (isRun && !Thread.interrupted()) { try { // Set up HTTP connection Socket socket = serversocket.accept(); System.out.println("Incoming connection from " + socket.getInetAddress()); ConsoleFactory.printToConsole("Incoming connection from " + socket.getInetAddress(),true); HttpServerConnection conn = this.connFactory.createConnection(socket); // Start worker thread Thread t = new WorkerThread(this.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; } } }
@Override public void run() { System.out.println("Listening on port " + this.serversocket.getLocalPort()); while (!Thread.interrupted()) { try { // Set up HTTP connection Socket socket = this.serversocket.accept(); System.out.println("Incoming connection from " + socket.getInetAddress()); HttpServerConnection conn = this.connFactory.createConnection(socket); // Start worker thread Thread t = new WorkerThread(this.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; } } }
public WorkerThread( final HttpService httpservice, final HttpServerConnection conn) { super(); this.httpservice = httpservice; this.conn = conn; }
public ProxyThread( final HttpService httpservice, final HttpServerConnection inconn, final HttpClientConnection outconn) { super(); this.httpservice = httpservice; this.inconn = inconn; this.outconn = outconn; }
public WorkerThread( final org.apache.http.protocol.HttpService httpservice, final HttpServerConnection conn, final Socket socket) { super(); this.httpservice = httpservice; this.conn = conn; this.socket = socket; }
ConnectionHandlerThread( final HttpService httpservice, final HttpServerConnection conn) { super(); this.httpservice = httpservice; this.conn = conn; }
@Override public void run() { System.out.println("Listening on port " + this.serversocket.getLocalPort()); while (!Thread.interrupted()) { try { // Set up HTTP connection Socket socket = this.serversocket.accept(); //System.out.println("Incoming connection from " + socket.getInetAddress()); HttpServerConnection conn = this.connFactory.createConnection(socket); //Thread t = new TaskExecutorThread(this.httpService, conn); // Initialize the pool Thread connectionHandler = new ConnectionHandlerThread(this.httpService, conn); connectionHandler.setDaemon(false); //System.out.println("print #2"); connectionHandlerExecutor.execute(connectionHandler); //connectionHandler.start(); //System.out.println("\tConnection Handler Thread created"); //t.start(); } catch (InterruptedIOException ex) { break; } catch (IOException e) { System.err.println("I/O error initialising connection thread: " + e.getMessage()); break; } } // when the listener is interupted shutdown the pool // and wait for any Connection Handler threads still running connectionHandlerExecutor.shutdown(); while (!connectionHandlerExecutor.isTerminated()) { } System.out.println("Finished all connection handler threads"); }
public WorkerThread(HttpService httpservice, HttpServerConnection conn, OnWebServListener listener) { super(); this.httpservice = httpservice; this.conn = conn; this.listener = listener; }
@Override protected Thread createWorkerThread(final Socket socket) throws IOException { // create the connection final HttpServerConnection conn = connFactory.createConnection(socket); return new WorkerThread(httpService, conn, socket); }
@Override public void run() { System.out.println("Listening on port " + this.serversocket.getLocalPort()); while (!Thread.interrupted()) { try { // Set up HTTP connection /** * TODO: Change this to use an executor service */ Socket socket = this.serversocket.accept(); System.out.println("Incoming connection from " + socket.getInetAddress()); HttpServerConnection conn = this.connFactory .createConnection(socket); // Start worker thread Thread t = new WorkerThread(this.httpService, conn); t.setDaemon(true); // executor.submit(t); t.start(); } catch (InterruptedIOException ex) { break; } catch (IOException e) { System.err .println("I/O error initialising connection thread: " + e.getMessage()); break; } } }
public WorkerThread(final HttpService httpservice, final HttpServerConnection conn) { super(); this.httpservice = httpservice; this.conn = conn; }
public WorkerTask(final HttpService httpService, final HttpServerConnection conn, final int count) { _httpService = httpService; _conn = conn; }
Worker(final HttpServerConnection conn) { this.conn = conn; }
public WorkerThread(HttpService httpservice, HttpServerConnection conn, EsperHttpServiceClassicRunnable runnable) { this.httpservice = httpservice; this.conn = conn; this.runnable = runnable; }
public HttpServerConnection getConnection() { return connection; }
private HttpServerConnection getHttpServerConnection() { return _httpServerConnection; }
RequestWorker(final HttpService httpService, final HttpServerConnection connection) { super(); _httpService = httpService; _httpServerConnection = connection; }
public ServerWorker(HttpServerConnection conn) { this.conn = conn; }
public RemoteConnection(InetAddress remoteAddress, HttpServerConnection connection) { this.remoteAddress = remoteAddress; this.connection = connection; }
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(); } }
public AdminWorkerThread(final HttpService httpservice, final HttpServerConnection conn) { super(); this.httpservice = httpservice; this.conn = conn; }
HttpServerConnection getHttpServerConnection() throws IOException { final Socket socket = getSocket(); if (null == socket) throw new IllegalStateException(new IllegalArgumentException(new NullPointerException("Undefined 'java.net.Socket' returned by underlying framework!"))); debug("Incoming connection from [{}]", socket.getInetAddress()); return getHttpConnectionFactory().createConnection(socket); }