@ThreadSafe
public final class ZPageServer
extends java.lang.Object
Example usage with private HttpServer
public class Main {
public static void main(String[] args) throws Exception {
ZPageServer.startHttpServerAndRegisterAllPages(8000);
... // do work
}
}
Example usage with shared HttpServer
public class Main {
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 10);
ZPageServer.registerAllPagesToHttpServer(server);
server.start();
... // do work
}
}
Modifier and Type | Method and Description |
---|---|
static void |
registerAllPagesToHttpServer(com.sun.net.httpserver.HttpServer server)
Registers all zPages to the given
HttpServer server . |
static void |
startHttpServerAndRegisterAllPages(int port)
Starts a private
HttpServer and registers all zPages to it. |
public static void registerAllPagesToHttpServer(com.sun.net.httpserver.HttpServer server)
HttpServer
server
.server
- the HttpServer
for the page to register to.public static void startHttpServerAndRegisterAllPages(int port) throws java.io.IOException
HttpServer
and registers all zPages to it. When the JVM shuts down the
server is stopped.
Users can only call this function once per process.
port
- the port used to bind the HttpServer
server
java.lang.IllegalStateException
- if the server is already started.java.io.IOException
- if the server cannot bind to the specified port.