public class SimpleHttpServer extends java.lang.Object implements com.sun.net.httpserver.HttpHandler, HTTPServer
| Constructor and Description |
|---|
SimpleHttpServer(java.util.Map props)
Creates new SimpleHttpServer
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContext(java.lang.Object obj,
java.lang.String path)
adds the given servlet at the given path to the context
|
protected void |
finalize() |
java.lang.String |
getName()
returns the name of the server
|
static javax.net.ssl.SSLContext |
getSSLContext(java.lang.String ksPath,
java.lang.String ksPassword)
returns SSLContext with given path to keyStore, the password for it
|
void |
handle(com.sun.net.httpserver.HttpExchange he)
default handler listing request details in json
|
void |
join()
joins the thread of the server
|
static void |
main(java.lang.String[] args) |
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
parseGetParameters(com.sun.net.httpserver.HttpExchange he)
parses the GET parameters and returns the map loaded with parameters
|
static int |
parsePostParameters(com.sun.net.httpserver.HttpExchange he,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> params)
parses the POST parameters and returns the map loaded with parameters
|
int |
removeContext(java.lang.String path)
removes the context at given path and returns number of contexts left
|
static void |
sendResponse(com.sun.net.httpserver.HttpExchange he,
int rc,
java.lang.String text)
sends the http status code and the text back as the response
|
void |
setService(java.lang.String path,
java.util.Map props,
Service service)
It creates the handler with the given property map and sets the service
on the handler.
|
void |
start()
starts the server without blocking
|
void |
stop()
stops the server with delays
|
public SimpleHttpServer(java.util.Map props)
public static javax.net.ssl.SSLContext getSSLContext(java.lang.String ksPath,
java.lang.String ksPassword)
throws java.lang.Exception
java.lang.Exceptionpublic static void sendResponse(com.sun.net.httpserver.HttpExchange he,
int rc,
java.lang.String text)
throws java.io.IOException
java.io.IOExceptionpublic static java.util.Map<java.lang.String,java.util.List<java.lang.String>> parseGetParameters(com.sun.net.httpserver.HttpExchange he)
public static int parsePostParameters(com.sun.net.httpserver.HttpExchange he,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> params)
throws java.io.IOException
java.io.IOExceptionpublic void handle(com.sun.net.httpserver.HttpExchange he)
throws java.io.IOException
handle in interface com.sun.net.httpserver.HttpHandlerjava.io.IOExceptionpublic void setService(java.lang.String path,
java.util.Map props,
Service service)
setService in interface HTTPServerpublic void addContext(java.lang.Object obj,
java.lang.String path)
addContext in interface HTTPServerpublic int removeContext(java.lang.String path)
public java.lang.String getName()
HTTPServergetName in interface HTTPServerpublic void start()
start in interface HTTPServerpublic void stop()
stop in interface HTTPServerpublic void join()
HTTPServerjoin in interface HTTPServerprotected void finalize()
finalize in class java.lang.Objectpublic static void main(java.lang.String[] args)