Package net.ionite.docval.server
Class DocValHttpServer
java.lang.Object
java.lang.Thread
net.ionite.docval.server.DocValHttpServer
- All Implemented Interfaces:
Runnable
HTTP Server for bulk- or continuous validation.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionDocValHttpServer(String configFile) Initialize a server with the configuration in the given configuration file.DocValHttpServer(ConfigData configData) Initialize a server with the configuration in the given configuration data.DocValHttpServer(ValidatorManager validatorManager) Initialize a server with a validator manager initialized by the caller. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(String host, int port, int workers) Add the given IP address/hostname and port number to the listeners.Retrieve the versionvoidhalt(int delay) Stop the servervoid(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.void(Re)load all validation files as configured in the configuration that has been read.voidsetValidatorManager(ValidatorManager validatorManager) Replace the validator manager with the given onevoidstart()Start the server on all the configured listenersMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
DocValHttpServer
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 startedConfigurationError- if there is an error in the configuration
-
DocValHttpServer
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 startedConfigurationError- if there is an error in the configuration
-
DocValHttpServer
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
(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 fileConfigurationError- If there is an error in the configuration file itself
-
loadValidationFiles
(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 fileConfigurationError- If there is an error in the configuration file itself
-
setValidatorManager
Replace the validator manager with the given one- Parameters:
validatorManager- The manager class containing the validators
-
addListener
Add the given IP address/hostname and port number to the listeners.- Parameters:
host- The hostname or IP address to listen onport- The port to listen onworkers- 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 -
halt
public void halt(int delay) Stop the server- Parameters:
delay- the maximum time in seconds to wait until exchanges have finished.
-
getVersion
Retrieve the version- Returns:
- The version string of the server
- Throws:
IOException- if there is an error reading the implementation version
-