| 限定符和类型 | 字段和说明 |
|---|---|
private org.jboss.netty.bootstrap.ServerBootstrap |
bootstrap |
private org.jboss.netty.channel.Channel |
channel |
private ConnectionTrackingHandler |
connectionTrackingHandler |
private static long |
DEFAULT_STALE_CONNECTION_TIMEOUT |
private Thread.UncaughtExceptionHandler |
exceptionHandler |
private Executor |
executor |
private List<ExecutorService> |
executorServices |
private List<HttpHandler> |
handlers |
private Thread.UncaughtExceptionHandler |
ioExceptionHandler |
private int |
maxChunkSize |
private int |
maxContentLength |
private int |
maxHeaderSize |
private int |
maxInitialLineLength |
protected long |
nextId |
private URI |
publicUri |
private SocketAddress |
socketAddress |
private SSLContext |
sslContext |
private long |
staleConnectionTimeout |
private StaleConnectionTrackingHandler |
staleConnectionTrackingHandler |
| 限定符 | 构造器和说明 |
|---|---|
|
NettyWebServer(Executor executor,
int port) |
private |
NettyWebServer(ExecutorService executorService,
int port) |
|
NettyWebServer(Executor executor,
SocketAddress socketAddress,
URI publicUri) |
|
NettyWebServer(int port) |
| 限定符和类型 | 方法和说明 |
|---|---|
NettyWebServer |
add(HttpHandler handler)
Add an HttpHandler.
|
NettyWebServer |
add(String path,
EventSourceHandler handler)
Add a WebSocketHandler for dealing with WebSockets.
|
NettyWebServer |
add(String path,
HttpHandler handler)
Add an HttpHandler that will only respond to a certain path (e.g "/some/page").
|
NettyWebServer |
add(String path,
WebSocketHandler handler)
Add a WebSocketHandler for dealing with WebSockets.
|
NettyWebServer |
connectionExceptionHandler(Thread.UncaughtExceptionHandler ioExceptionHandler)
What to do when an exception occurs when attempting to read/write data
from/to the underlying connection. e.g.
|
Executor |
getExecutor()
Get main work executor that all handlers will execute on.
|
int |
getPort()
Get base port that webserver is serving on.
|
URI |
getUri()
Get base URI that endpoint is serving on (or connected to).
|
boolean |
isRunning() |
private static URI |
localUri(int port) |
NettyWebServer |
maxChunkSize(int maxChunkSize) |
NettyWebServer |
maxContentLength(int maxContentLength) |
NettyWebServer |
maxHeaderSize(int maxHeaderSize) |
NettyWebServer |
maxInitialLineLength(int maxInitialLineLength) |
protected Object |
nextId() |
protected void |
setupDefaultHandlers() |
NettyWebServer |
setupSsl(InputStream keyStore,
String pass)
Setup SSL/TLS handler
This is shortcut for
setupSsl(keyStore, pass, pass). |
NettyWebServer |
setupSsl(InputStream keyStore,
String storePass,
String keyPass)
Setup SSL/TLS handler
|
private void |
shutdownAndAwaitTermination(ExecutorService executorService) |
NettyWebServer |
staleConnectionTimeout(long millis)
Number of milliseconds before a stale HTTP keep-alive connection is closed by the server.
|
Future<NettyWebServer> |
start()
Start in background.
|
Future<WebServer> |
stop()
Stop in background.
|
protected long |
timestamp() |
NettyWebServer |
uncaughtExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)
What to do when an exception gets thrown in a handler.
|
private static final long DEFAULT_STALE_CONNECTION_TIMEOUT
private final SocketAddress socketAddress
private final URI publicUri
private final List<HttpHandler> handlers
private final List<ExecutorService> executorServices
private final Executor executor
private org.jboss.netty.bootstrap.ServerBootstrap bootstrap
private org.jboss.netty.channel.Channel channel
private SSLContext sslContext
protected long nextId
private Thread.UncaughtExceptionHandler exceptionHandler
private Thread.UncaughtExceptionHandler ioExceptionHandler
private ConnectionTrackingHandler connectionTrackingHandler
private StaleConnectionTrackingHandler staleConnectionTrackingHandler
private long staleConnectionTimeout
private int maxInitialLineLength
private int maxHeaderSize
private int maxChunkSize
private int maxContentLength
public NettyWebServer(int port)
private NettyWebServer(ExecutorService executorService, int port)
public NettyWebServer(Executor executor, int port)
public NettyWebServer(Executor executor, SocketAddress socketAddress, URI publicUri)
protected void setupDefaultHandlers()
public NettyWebServer setupSsl(InputStream keyStore, String pass) throws WebbitException
EndpointsetupSsl(keyStore, pass, pass).setupSsl 在接口中 Endpoint<WebServer>keyStore - Keystore InputStreampass - Store and key passwordWebbitException - A problem loading the keystore#setupSsl(String, String, String)public NettyWebServer setupSsl(InputStream keyStore, String storePass, String keyPass) throws WebbitException
WebServersetupSsl 在接口中 WebServerkeyStore - Keystore InputStreamstorePass - Store passwordkeyPass - Key passwordWebbitException - A problem loading the keystorepublic URI getUri()
Endpointpublic int getPort()
WebServerpublic Executor getExecutor()
EndpointgetExecutor 在接口中 Endpoint<WebServer>public NettyWebServer staleConnectionTimeout(long millis)
WebServerstaleConnectionTimeout 在接口中 WebServerpublic NettyWebServer add(HttpHandler handler)
WebServerHttpControl.nextHandler()). This is repeated
until a HttpHandler returns a response. If there are no remaining handlers, the
webserver shall return 404 NOT FOUND to the browser.
HttpHandlers are attempted in the order in which they are added to the WebServer.add 在接口中 WebServerHttpHandlerpublic NettyWebServer add(String path, HttpHandler handler)
WebServeradd(newPathMatchHandler(path, handler)).add 在接口中 WebServerHttpHandler,
WebServer.add(HttpHandler),
PathMatchHandlerpublic NettyWebServer add(String path, WebSocketHandler handler)
WebServeradd(new PathMatchHandler(path, newHttpToWebSocketHandler(handler))).public NettyWebServer add(String path, EventSourceHandler handler)
WebServeradd(new PathMatchHandler(path, newHttpToEventSourceHandler(handler))).add 在接口中 WebServerHttpHandler,
WebServer.add(HttpHandler),
HttpToEventSourceHandler,
PathMatchHandlerpublic Future<NettyWebServer> start()
EndpointFuture.get() on the returned future.public boolean isRunning()
public Future<WebServer> stop()
EndpointFuture.get() on the returned future.private void shutdownAndAwaitTermination(ExecutorService executorService)
public NettyWebServer uncaughtExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)
EndpointPrintStackTraceExceptionHandler.
It is suggested that apps supply their own implementation (e.g. to log somewhere).uncaughtExceptionHandler 在接口中 Endpoint<WebServer>public NettyWebServer connectionExceptionHandler(Thread.UncaughtExceptionHandler ioExceptionHandler)
EndpointSilentExceptionHandler
as this is a common thing to happen on a network, and most systems should not care.connectionExceptionHandler 在接口中 Endpoint<WebServer>public NettyWebServer maxChunkSize(int maxChunkSize)
HttpRequestDecoderpublic NettyWebServer maxContentLength(int maxContentLength)
HttpChunkAggregatorpublic NettyWebServer maxHeaderSize(int maxHeaderSize)
HttpRequestDecoderpublic NettyWebServer maxInitialLineLength(int maxInitialLineLength)
HttpRequestDecoderprivate static URI localUri(int port)
protected long timestamp()
protected Object nextId()
Copyright © 2014. All rights reserved.