Methods Summary |
---|
private org.apache.http.HttpServerConnection | acceptConnection()
Socket socket = this.serversocket.accept();
DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
conn.bind(socket, this.params);
return conn;
|
public java.net.InetAddress | getInetAddress()
return this.serversocket.getInetAddress();
|
public int | getPort()
return this.serversocket.getLocalPort();
|
public void | registerHandler(java.lang.String pattern, org.apache.http.protocol.HttpRequestHandler handler)
this.reqistry.register(pattern, handler);
|
public void | setExpectationVerifier(org.apache.http.protocol.HttpExpectationVerifier expectationVerifier)
this.expectationVerifier = expectationVerifier;
|
public void | shutdown()
if (this.shutdown) {
return;
}
this.shutdown = true;
try {
this.serversocket.close();
} catch (IOException ignore) {}
this.listener.interrupt();
try {
this.listener.join(1000);
} catch (InterruptedException ignore) {}
|
public void | start()
if (this.listener != null) {
throw new IllegalStateException("Listener already running");
}
this.listener = new Thread(new Runnable() {
public void run() {
while (!shutdown && !Thread.interrupted()) {
try {
// Set up HTTP connection
HttpServerConnection conn = acceptConnection();
// Set up the HTTP service
HttpService httpService = new HttpService(
httpproc,
connStrategy,
responseFactory);
httpService.setParams(params);
httpService.setExpectationVerifier(expectationVerifier);
httpService.setHandlerResolver(reqistry);
// Start worker thread
Thread t = new WorkerThread(httpService, conn);
t.setDaemon(true);
t.start();
} catch (InterruptedIOException ex) {
break;
} catch (IOException e) {
break;
}
}
}
});
this.listener.start();
|