Example usage for org.apache.http.impl DefaultBHttpServerConnection toString

List of usage examples for org.apache.http.impl DefaultBHttpServerConnection toString

Introduction

In this page you can find the example usage for org.apache.http.impl DefaultBHttpServerConnection toString.

Prototype

public String toString() 

Source Link

Usage

From source file:us.pserver.revok.server.RevokServer.java

/**
 * Not invoke directly. Executes server routines.
 *//*from  w  w w.  j  a  v a2s.  c  o  m*/
@Override
public void run() {
    // Stablish a listen server connection
    try (ServerSocket server = con.connectServerSocket();) {
        server.setSoTimeout(SOCK_SO_TIMEOUT);
        // Log the server start
        log.info("Listening on: " + con.toString());
        log.info("RevokServer started!\n");

        // Loop while the server should be running
        while (isRunning()) {
            try {
                // Accept a client TCP connection
                Socket sock = server.accept();
                // Create and bind an HTTP connection
                // over the TCP connection received.
                DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(HTTP_CONN_BUFFER_SIZE);
                conn.bind(sock);
                // Submit for Thread worker execution
                // a HttpConnectionHandler for handling 
                // the HTTP connection
                log.info("------------------------------").info("Handling socket: " + conn.toString());
                exec.submit(new RunnableConnectionHandler(factory.createChannel(conn, serial), container));
                // Catch socket timeout exceptions and continue 
                // accepting other connections
            } catch (SocketTimeoutException se) {
            }
        } //while
    } catch (IOException e) {
        // Catch and log other error occurred accepting connections.
        // Errors over server listening connections are fatal
        // and irrecoverable.
        log.error(new IOException("Error running RevokServer", e), true);
        if (log.outputs().isEmpty())
            throw new RuntimeException("Error running RevokServer", e);
    }
    // Shutdown the server and log when it not should be running anymore
    log.info("Stopping ExecutorService...");
    exec.shutdown();
    log.info("RevokServer Shutdown!");
}