Package org.kawanfw.sql.api.server.web
Class WebServerApi
java.lang.Object
org.kawanfw.sql.api.server.web.WebServerApi
public class WebServerApi extends Object
APIs to start and stop the embedded Web Server from a Java program.
- Author:
- Nicolas de Pomereu
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PORT
The default port to use if parameter is not passed -
Constructor Summary
Constructors Constructor Description WebServerApi()
-
Method Summary
Modifier and Type Method Description boolean
isServerRunning()
Says if the the embedded Web Server is running on on the default portDEFAULT_PORT
.boolean
isServerRunning(int port)
Says if the the embedded Web Server is running on the specified port.void
startServer(String host, int port, File propertiesFile)
Starts the embedded Web Server.void
startServer(String host, File propertiesFile)
Starts the embedded Web Server on the default portDEFAULT_PORT
.void
stopServer()
Stops the embedded Web server running on the default portDEFAULT_PORT
.void
stopServer(int port)
Stops the embedded Web server running on the designated port.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTThe default port to use if parameter is not passed- See Also:
- Constant Field Values
-
-
Constructor Details
-
WebServerApi
public WebServerApi()
-
-
Method Details
-
startServer
public void startServer(String host, int port, File propertiesFile) throws ConnectException, IOException, SQLException, DatabaseConfigurationException, org.apache.catalina.LifecycleExceptionStarts the embedded Web Server.- Parameters:
host
- the host of the Web Serverport
- the port of the Web ServerpropertiesFile
- properties file to use for configuration of the Web Server- Throws:
ConnectException
- if the default port is not availableIOException
- if an IOException occursDatabaseConfigurationException
- if there is a configuration error, either in Configurators or in theserver-sql.properties
fileorg.apache.catalina.LifecycleException
- thrown by embedded Tomcat for any lifecycle related problemSQLException
- thrown by embedded Tomcat for any SQL Error
-
startServer
public void startServer(String host, File propertiesFile) throws ConnectException, IOException, DatabaseConfigurationException, org.apache.catalina.LifecycleException, SQLExceptionStarts the embedded Web Server on the default portDEFAULT_PORT
.- Parameters:
host
- the host of the Web ServerpropertiesFile
- properties file to use for configuration of the Web Server- Throws:
ConnectException
- if the default port is not availableIOException
- if an IOException occursDatabaseConfigurationException
- if there is a configuration error, either in Configurators or in theserver-sql.properties
fileorg.apache.catalina.LifecycleException
- thrown by embedded Tomcat for any lifecycle related problemSQLException
- thrown by embedded Tomcat for any SQL Error
-
stopServer
Stops the embedded Web server running on the default portDEFAULT_PORT
.- Throws:
IOException
- if the semaphore file (that signals to the SQL Web Server to stop) can not be created
-
stopServer
Stops the embedded Web server running on the designated port.- Parameters:
port
- the port on which the SQL Web server is running- Throws:
IOException
- if the semaphore file (that signals to the Web Server to stop) can not be created
-
isServerRunning
public boolean isServerRunning()Says if the the embedded Web Server is running on on the default portDEFAULT_PORT
.- Returns:
- true if the Web Server is running on the default port
-
isServerRunning
public boolean isServerRunning(int port)Says if the the embedded Web Server is running on the specified port.- Parameters:
port
- the port of the Web Server- Returns:
- true if the Web Server is running on the specified port
-