Class HTTPServerConfig

java.lang.Object
org.languagetool.server.HTTPServerConfig
Direct Known Subclasses:
HTTPSServerConfig

public class HTTPServerConfig extends Object
Since:
2.0
  • Field Details

    • DEFAULT_HOST

      public static final String DEFAULT_HOST
      See Also:
    • DEFAULT_PORT

      public static final int DEFAULT_PORT
      The default port on which the server is running (8081).
      See Also:
    • verbose

      protected boolean verbose
    • publicAccess

      protected boolean publicAccess
    • port

      protected int port
    • allowOriginUrl

      protected String allowOriginUrl
    • serverURL

      protected URI serverURL
    • maxTextLength

      protected int maxTextLength
    • maxTextHardLength

      protected int maxTextHardLength
    • maxTextLengthWithApiKey

      protected int maxTextLengthWithApiKey
    • secretTokenKey

      protected String secretTokenKey
    • maxCheckTimeMillis

      protected long maxCheckTimeMillis
    • maxCheckTimeWithApiKeyMillis

      protected long maxCheckTimeWithApiKeyMillis
    • maxCheckThreads

      protected int maxCheckThreads
    • mode

      protected org.languagetool.server.HTTPServerConfig.Mode mode
    • languageModelDir

      protected File languageModelDir
    • word2vecModelDir

      protected File word2vecModelDir
    • pipelineCaching

      protected boolean pipelineCaching
    • pipelinePrewarming

      protected boolean pipelinePrewarming
    • maxPipelinePoolSize

      protected int maxPipelinePoolSize
    • pipelineExpireTime

      protected int pipelineExpireTime
    • fasttextModel

      protected File fasttextModel
    • fasttextBinary

      protected File fasttextBinary
    • neuralNetworkModelDir

      protected File neuralNetworkModelDir
    • requestLimit

      protected int requestLimit
    • requestLimitInBytes

      protected int requestLimitInBytes
    • timeoutRequestLimit

      protected int timeoutRequestLimit
    • requestLimitPeriodInSeconds

      protected int requestLimitPeriodInSeconds
    • ipFingerprintFactor

      protected int ipFingerprintFactor
    • trustXForwardForHeader

      protected boolean trustXForwardForHeader
    • maxWorkQueueSize

      protected int maxWorkQueueSize
    • rulesConfigFile

      protected File rulesConfigFile
    • cacheSize

      protected int cacheSize
    • cacheTTLSeconds

      protected long cacheTTLSeconds
    • maxErrorsPerWordRate

      protected float maxErrorsPerWordRate
    • maxSpellingSuggestions

      protected int maxSpellingSuggestions
    • blockedReferrers

      protected List<String> blockedReferrers
    • hiddenMatchesServer

      protected String hiddenMatchesServer
    • hiddenMatchesServerTimeout

      protected int hiddenMatchesServerTimeout
    • hiddenMatchesServerFailTimeout

      protected int hiddenMatchesServerFailTimeout
    • hiddenMatchesLanguages

      protected List<org.languagetool.Language> hiddenMatchesLanguages
    • dbDriver

      protected String dbDriver
    • dbUrl

      protected String dbUrl
    • dbUsername

      protected String dbUsername
    • dbPassword

      protected String dbPassword
    • dbLogging

      protected boolean dbLogging
    • prometheusMonitoring

      protected boolean prometheusMonitoring
    • prometheusPort

      protected int prometheusPort
    • globalConfig

      protected org.languagetool.GlobalConfig globalConfig
    • disabledRuleIds

      protected List<String> disabledRuleIds
    • skipLoggingRuleMatches

      protected boolean skipLoggingRuleMatches
    • skipLoggingChecks

      protected boolean skipLoggingChecks
    • slowRuleLoggingThreshold

      protected int slowRuleLoggingThreshold
    • abTest

      protected String abTest
  • Constructor Details

    • HTTPServerConfig

      public HTTPServerConfig()
      Create a server configuration for the default port (DEFAULT_PORT).
    • HTTPServerConfig

      public HTTPServerConfig(int serverPort)
      Parameters:
      serverPort - the port to bind to
      Since:
      2.8
    • HTTPServerConfig

      public HTTPServerConfig(int serverPort, boolean verbose)
      Parameters:
      serverPort - the port to bind to
      verbose - when set to true, the input text will be logged in case there is an exception
  • Method Details

    • setLanguageModelDirectory

      public void setLanguageModelDirectory(String langModelDir)
    • isVerbose

      public boolean isVerbose()
    • isPublicAccess

      public boolean isPublicAccess()
    • getPort

      public int getPort()
    • getAllowOriginUrl

      @Nullable public @Nullable String getAllowOriginUrl()
      Value to set as the "Access-Control-Allow-Origin" http header. null will not return that header at all. With * your server can be used from any other web site from Javascript/Ajax (search Cross-origin resource sharing (CORS) for details).
    • setAllowOriginUrl

      public void setAllowOriginUrl(String allowOriginUrl)
      Since:
      4.2
    • getServerURL

      @Nullable public @Nullable URI getServerURL()
      Returns:
      prefix / base URL for API requests
      Since:
      4.8
    • setServerURL

      public void setServerURL(@Nullable @Nullable String url)
      Parameters:
      url - prefix / base URL for API requests
      Since:
      4.8
    • setMaxTextLength

      public void setMaxTextLength(int len)
      Parameters:
      len - the maximum text length allowed (in number of characters), texts that are longer will cause an exception when being checked, unless the user can provide a JWT 'token' parameter with a 'maxTextLength' claim
    • setMaxTextHardLength

      public void setMaxTextHardLength(int len)
      Parameters:
      len - the maximum text length allowed (in number of characters), texts that are longer will cause an exception when being checked even if the user can provide a JWT token
      Since:
      3.9
    • getNeuralNetworkModelDir

      public File getNeuralNetworkModelDir()
      Get base directory for neural network models or null
      Since:
      4.4
    • getFasttextModel

      @Nullable public @Nullable File getFasttextModel()
      Get model path for fasttext language detection
      Since:
      4.3
    • setFasttextModel

      public void setFasttextModel(File model)
      Set model path for fasttext language detection
      Since:
      4.4
    • getFasttextBinary

      @Nullable public @Nullable File getFasttextBinary()
      Get binary path for fasttext language detection
      Since:
      4.3
    • setFasttextBinary

      public void setFasttextBinary(File binary)
      Set binary path for fasttext language detection
      Since:
      4.4
    • isPipelineCachingEnabled

      public boolean isPipelineCachingEnabled()
      Since:
      4.4 Cache initalized JLanguageTool instances and share between non-parallel requests with identical paramenters Improves response time (especially when dealing with many small requests without specific settings), but increases memory usage
    • isPipelinePrewarmingEnabled

      public boolean isPipelinePrewarmingEnabled()
      Since:
      4.4 Before starting to listen for requests, create a few pipelines for frequently used request settings and run simple checks on them; prevents long response time / request overload on the first real incoming requests
    • getMaxPipelinePoolSize

      public int getMaxPipelinePoolSize()
      Since:
      4.4 Keep pipelines ready for this many different request settings
    • getPipelineExpireTime

      public int getPipelineExpireTime()
      Since:
      4.4 Expire pipelines for a specific request setting after this many seconds without any matching request elapsed
    • setPipelineCaching

      public void setPipelineCaching(boolean pipelineCaching)
      Since:
      4.4
    • setPipelinePrewarming

      public void setPipelinePrewarming(boolean pipelinePrewarming)
      Since:
      4.4
    • setMaxPipelinePoolSize

      public void setMaxPipelinePoolSize(int maxPipelinePoolSize)
      Since:
      4.4
    • setPipelineExpireTime

      public void setPipelineExpireTime(int pipelineExpireTime)
      Since:
      4.4
    • isPrometheusMonitoring

      public boolean isPrometheusMonitoring()
      Returns:
      Since:
      4.6
    • getPrometheusPort

      public int getPrometheusPort()
      Returns:
      Since:
      4.6
    • getSlowRuleLoggingThreshold

      @Experimental public int getSlowRuleLoggingThreshold()
      Returns:
      threshold for rule computation time until a warning gets logged, in milliseconds
      Since:
      4.5
    • isSkipLoggingChecks

      public boolean isSkipLoggingChecks()
      Since:
      4.6
    • getDisabledRuleIds

      public List<String> getDisabledRuleIds()
      Since:
      4.7
    • getAbTest

      @Experimental @Nullable public @Nullable String getAbTest()
      Since:
      4.4 See if a specific A/B-Test is to be run
    • setAbTest

      @Experimental public void setAbTest(@Nullable @Nullable String abTest)
      Since:
      4.4 Enable a specific A/B-Test to be run (or null to disable all tests)
    • getProperty

      protected String getProperty(Properties props, String propertyName, File config)
      Throws:
      org.languagetool.server.IllegalConfigurationException - if property is not set
    • getOptionalProperty

      protected String getOptionalProperty(Properties props, String propertyName, String defaultValue)