Class DocValHttpServer

java.lang.Object
java.lang.Thread
net.ionite.docval.server.DocValHttpServer
All Implemented Interfaces:
Runnable

public class DocValHttpServer extends Thread
HTTP Server for bulk- or continuous validation.
  • Constructor Details

    • DocValHttpServer

      public DocValHttpServer(String configFile) throws IOException, ConfigurationError
      Initialize a server with the configuration in the given configuration file.
      Parameters:
      configFile - The configuration file to read
      Throws:
      IOException - if the server could not be started
      ConfigurationError - if there is an error in the configuration
    • DocValHttpServer

      public DocValHttpServer(ConfigData configData) throws IOException, ConfigurationError
      Initialize a server with the configuration in the given configuration data.
      Parameters:
      configData - The configuration data to use
      Throws:
      IOException - if the server could not be started
      ConfigurationError - if there is an error in the configuration
    • DocValHttpServer

      public DocValHttpServer(ValidatorManager validatorManager)
      Initialize a server with a validator manager initialized by the caller. This server does not start listening automatically, the caller must call addListener() as well.
      Parameters:
      validatorManager - the validator manager to use for validation
  • Method Details

    • loadConfigFile

      public void loadConfigFile() throws IOException, ConfigurationError
      (Re)load the validation part of the configuration file used in the initializer (if any).

      Note that this does *not* reconfigure or re-initialize the listeners specified in the configuration. It also does NOT read the validation files themselves, call loadValidationFiles() after loadConfigFile() to do that (changed in 1.3.0)
      Throws:
      IOException - If there is an I/O error while reading the configuration file
      ConfigurationError - If there is an error in the configuration file itself
    • loadValidationFiles

      public void loadValidationFiles() throws IOException, ConfigurationError
      (Re)load all validation files as configured in the configuration that has been read. Call this after loadConfigFile()
      Throws:
      IOException - If there is an I/O error while reading the configuration file
      ConfigurationError - If there is an error in the configuration file itself
    • setValidatorManager

      public void setValidatorManager(ValidatorManager validatorManager)
      Replace the validator manager with the given one
      Parameters:
      validatorManager - The manager class containing the validators
    • addListener

      public void addListener(String host, int port, int workers) throws IOException
      Add the given IP address/hostname and port number to the listeners.
      Parameters:
      host - The hostname or IP address to listen on
      port - The port to listen on
      workers - The number of worker threads to start
      Throws:
      IOException - if the port could not be opened for listening.
    • start

      public void start()
      Start the server on all the configured listeners
      Overrides:
      start in class Thread
    • halt

      public void halt(int delay)
      Stop the server
      Parameters:
      delay - the maximum time in seconds to wait until exchanges have finished.
    • getVersion

      public String getVersion() throws IOException
      Retrieve the version
      Returns:
      The version string of the server
      Throws:
      IOException - if there is an error reading the implementation version