Package org.h2.server.web
Class WebServer
java.lang.Object
org.h2.server.web.WebServer
- All Implemented Interfaces:
Service
The web server is a simple standalone HTTP server that implements the H2
Console application. It is not optimized for performance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSession(Connection conn) Create a session with a given connection.static StringencodeAdminPassword(String password) Generates a random salt and returns it with a hash of specified password with this salt.booleanCheck if remote connections are allowed.getHost()getName()Get the human readable name of the service.intgetPort()Gets the port this service is listening on.getType()Get the human readable short name of the service.getURL()Get the URL of this service in a human readable formvoidInitialize the service from command line options.booleanbooleanisDaemon()Check if a daemon thread should be used.booleanisRunning(boolean traceError) Check if the service is running.booleanvoidlisten()Listen for incoming connections.voidsaveCommandHistoryList(ArrayList<String> commandHistory) Save the command history to the properties file.voidsetAllowSecureCreation(boolean allowSecureCreation) voidsetCommandHistoryAllowed(boolean allowed) voidSets the key for privileged connections.voidsetShutdownHandler(ShutdownHandler shutdownHandler) voidstart()Start the service.voidstop()Stop the service.
-
Constructor Details
-
WebServer
public WebServer()
-
-
Method Details
-
setKey
Sets the key for privileged connections.- Parameters:
key- key, or null
-
setAllowSecureCreation
public void setAllowSecureCreation(boolean allowSecureCreation) - Parameters:
allowSecureCreation- whether creation of databases using the key should be allowed
-
init
Description copied from interface:ServiceInitialize the service from command line options. -
getURL
Description copied from interface:ServiceGet the URL of this service in a human readable form -
getHost
- Returns:
- host name
-
start
public void start()Description copied from interface:ServiceStart the service. This usually means create the server socket. This method must not block. -
listen
public void listen()Description copied from interface:ServiceListen for incoming connections. This method blocks. -
isRunning
public boolean isRunning(boolean traceError) Description copied from interface:ServiceCheck if the service is running. -
isStopped
public boolean isStopped() -
stop
public void stop()Description copied from interface:ServiceStop the service. -
getType
Description copied from interface:ServiceGet the human readable short name of the service. -
getName
Description copied from interface:ServiceGet the human readable name of the service. -
getAllowOthers
public boolean getAllowOthers()Description copied from interface:ServiceCheck if remote connections are allowed.- Specified by:
getAllowOthersin interfaceService- Returns:
- true if remote connections are allowed
-
getPort
public int getPort()Description copied from interface:ServiceGets the port this service is listening on. -
isCommandHistoryAllowed
public boolean isCommandHistoryAllowed() -
setCommandHistoryAllowed
public void setCommandHistoryAllowed(boolean allowed) -
getCommandHistoryList
-
saveCommandHistoryList
Save the command history to the properties file.- Parameters:
commandHistory- the history
-
setShutdownHandler
-
addSession
Create a session with a given connection.- Parameters:
conn- the connection- Returns:
- the URL of the web site to access this connection
- Throws:
SQLException- on failure
-
isDaemon
public boolean isDaemon()Description copied from interface:ServiceCheck if a daemon thread should be used. -
encodeAdminPassword
Generates a random salt and returns it with a hash of specified password with this salt.- Parameters:
password- the password- Returns:
- a salt and hash of salted password as a hex encoded string to be used in configuration file
- Throws:
IllegalArgumentException- when password is too short
-