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.

Note that the org.kawanfw.sql.WebServer class is used to start and stop the embedded Web Server from command line and uses the APIs of this class. Source code is available here:  WebServer.java.
Author:
Nicolas de Pomereu
  • Field Details

    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      The 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.LifecycleException
      Starts the embedded Web Server.
      Parameters:
      host - the host of the Web Server
      port - the port of the Web Server
      propertiesFile - properties file to use for configuration of the Web Server
      Throws:
      ConnectException - if the default port is not available
      IOException - if an IOException occurs
      DatabaseConfigurationException - if there is a configuration error, either in Configurators or in the server-sql.properties file
      org.apache.catalina.LifecycleException - thrown by embedded Tomcat for any lifecycle related problem
      SQLException - thrown by embedded Tomcat for any SQL Error
    • startServer

      public void startServer​(String host, File propertiesFile) throws ConnectException, IOException, DatabaseConfigurationException, org.apache.catalina.LifecycleException, SQLException
      Starts the embedded Web Server on the default port DEFAULT_PORT.
      Parameters:
      host - the host of the Web Server
      propertiesFile - properties file to use for configuration of the Web Server
      Throws:
      ConnectException - if the default port is not available
      IOException - if an IOException occurs
      DatabaseConfigurationException - if there is a configuration error, either in Configurators or in the server-sql.properties file
      org.apache.catalina.LifecycleException - thrown by embedded Tomcat for any lifecycle related problem
      SQLException - thrown by embedded Tomcat for any SQL Error
    • stopServer

      public void stopServer() throws IOException
      Stops the embedded Web server running on the default port DEFAULT_PORT.
      Throws:
      IOException - if the semaphore file (that signals to the SQL Web Server to stop) can not be created
    • stopServer

      public void stopServer​(int port) throws IOException
      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 port DEFAULT_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