Class WebServerConfiguration
- java.lang.Object
-
- com.github.toolarium.jwebserver.config.WebServerConfiguration
-
- All Implemented Interfaces:
IWebServerConfiguration
public class WebServerConfiguration extends java.lang.Object implements IWebServerConfiguration
Define the webserver configuration
-
-
Constructor Summary
Constructors Constructor Description WebServerConfiguration()Constructor for WebServerConfigurationWebServerConfiguration(IWebServerConfiguration configuration)Constructor for WebServerConfiguration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringformatArrayAsString(java.lang.String[] stringArray)Format an array as stringjava.lang.StringgetAccessLogFilePattern()The access log file pattern, e.g.java.lang.StringgetAccessLogFormatString()Get access log format string:java.lang.StringgetBasicAuthentication()Get the basic authentication: user:passwordjava.lang.StringgetDirectory()Get the directoryjava.lang.StringgetHealthPath()Get the health pathjava.lang.StringgetHostname()Get the hostnameintgetIoThreads()Get the number of I/O threadsintgetPort()Get the portjava.lang.StringgetResourcePath()Get the resource pathjava.lang.String[]getSupportedFileExtensions()Set the supported file extensionsVerboseLevelgetVerboseLevel()Get the verbose leveljava.lang.StringgetWebserverName()Get the webserver namejava.lang.String[]getWelcomeFiles()Set the welcome filesintgetWorkerThreads()Get the number of working threadsbooleanhasBasicAuthentication()Define if the resource has basic authenticationbooleanhasHealthCheck()Define if the server support healthbooleanisDirectoryListingEnabled()Define if the directory listing is enabledbooleanisLocalDirectory()Define if the directory is localjava.lang.String[]parseStringArray(java.lang.String stringArray)Parse the string arraybooleanreadFromClasspath()Define if the directory should be read from the classpathWebServerConfigurationreadProperties()Read the configuration from the classpathWebServerConfigurationsetAccessLogFilePattern(java.lang.String accessLogFilePattern)Set the access log file patternWebServerConfigurationsetAccessLogFormatString(java.lang.String accessLogFormatString)Set the access log format stringWebServerConfigurationsetBasicAuthentication(java.lang.String basicAuthentication)Define if basic authentication is enabledWebServerConfigurationsetDirectory(java.lang.String directory)Set the directoryWebServerConfigurationsetDirectory(java.lang.String directory, java.lang.Boolean readFromClasspath)Set the directoryWebServerConfigurationsetDirectoryListingEnabled(java.lang.Boolean directoryListingEnabled)Define if the directory listing is enabledWebServerConfigurationsetHealthPath(java.lang.String healthPath)Set the health pathWebServerConfigurationsetHostname(java.lang.String hostname)Set the host nameWebServerConfigurationsetIoThreads(java.lang.Integer ioThreads)Set the I/O threadsWebServerConfigurationsetPort(java.lang.Integer port)Set the portWebServerConfigurationsetResourcePath(java.lang.String resourcePath)Set the resource pathWebServerConfigurationsetSupportedFileExtensions(java.lang.String supportedFileExtensions)Set the supported file extensionsWebServerConfigurationsetSupportedFileExtensions(java.lang.String[] supportedFileExtensions)Set the supported file extensionsWebServerConfigurationsetVerboseLevel(VerboseLevel verboseLevel)Set the verbose levelWebServerConfigurationsetWebserverName(java.lang.String webserverName)Set the webserver nameWebServerConfigurationsetWelcomeFiles(java.lang.String welcomeFiles)Set the welcome filesWebServerConfigurationsetWelcomeFiles(java.lang.String[] welcomeFiles)Set the welcome filesWebServerConfigurationsetWorkerThreads(java.lang.Integer workerThreads)Set the worker threads
-
-
-
Constructor Detail
-
WebServerConfiguration
public WebServerConfiguration()
Constructor for WebServerConfiguration
-
WebServerConfiguration
public WebServerConfiguration(IWebServerConfiguration configuration)
Constructor for WebServerConfiguration- Parameters:
configuration- the configuration
-
-
Method Detail
-
getWebserverName
public java.lang.String getWebserverName()
Description copied from interface:IWebServerConfigurationGet the webserver name- Specified by:
getWebserverNamein interfaceIWebServerConfiguration- Returns:
- the webserver name
- See Also:
IWebServerConfiguration.getWebserverName()
-
setWebserverName
public WebServerConfiguration setWebserverName(java.lang.String webserverName)
Set the webserver name- Parameters:
webserverName- the webserve name- Returns:
- the WebServerConfiguration
-
getHostname
public java.lang.String getHostname()
Description copied from interface:IWebServerConfigurationGet the hostname- Specified by:
getHostnamein interfaceIWebServerConfiguration- Returns:
- the hostname
- See Also:
IWebServerConfiguration.getHostname()
-
setHostname
public WebServerConfiguration setHostname(java.lang.String hostname)
Set the host name- Parameters:
hostname- the hostname- Returns:
- the WebServerConfiguration
-
getPort
public int getPort()
Description copied from interface:IWebServerConfigurationGet the port- Specified by:
getPortin interfaceIWebServerConfiguration- Returns:
- the port
- See Also:
IWebServerConfiguration.getPort()
-
setPort
public WebServerConfiguration setPort(java.lang.Integer port)
Set the port- Parameters:
port- the port- Returns:
- the WebServerConfiguration
-
getDirectory
public java.lang.String getDirectory()
Description copied from interface:IWebServerConfigurationGet the directory- Specified by:
getDirectoryin interfaceIWebServerConfiguration- Returns:
- the directory
- See Also:
IWebServerConfiguration.getDirectory()
-
setDirectory
public WebServerConfiguration setDirectory(java.lang.String directory)
Set the directory- Parameters:
directory- the directory- Returns:
- the WebServerConfiguration
-
setDirectory
public WebServerConfiguration setDirectory(java.lang.String directory, java.lang.Boolean readFromClasspath)
Set the directory- Parameters:
directory- the directoryreadFromClasspath- the directory should be read from the classpath- Returns:
- the WebServerConfiguration
-
readFromClasspath
public boolean readFromClasspath()
Description copied from interface:IWebServerConfigurationDefine if the directory should be read from the classpath- Specified by:
readFromClasspathin interfaceIWebServerConfiguration- Returns:
- true if the directory should be read from the classpath
- See Also:
IWebServerConfiguration.readFromClasspath()
-
isLocalDirectory
public boolean isLocalDirectory()
Description copied from interface:IWebServerConfigurationDefine if the directory is local- Specified by:
isLocalDirectoryin interfaceIWebServerConfiguration- Returns:
- true if the directory is local
- See Also:
IWebServerConfiguration.isLocalDirectory()
-
isDirectoryListingEnabled
public boolean isDirectoryListingEnabled()
Description copied from interface:IWebServerConfigurationDefine if the directory listing is enabled- Specified by:
isDirectoryListingEnabledin interfaceIWebServerConfiguration- Returns:
- true if it is enabled
- See Also:
IWebServerConfiguration.isDirectoryListingEnabled()
-
setDirectoryListingEnabled
public WebServerConfiguration setDirectoryListingEnabled(java.lang.Boolean directoryListingEnabled)
Define if the directory listing is enabled- Parameters:
directoryListingEnabled- turn true if it is enabled- Returns:
- the WebServerConfiguration
-
getVerboseLevel
public VerboseLevel getVerboseLevel()
Description copied from interface:IWebServerConfigurationGet the verbose level- Specified by:
getVerboseLevelin interfaceIWebServerConfiguration- Returns:
- the verbose level
- See Also:
IWebServerConfiguration.getVerboseLevel()
-
setVerboseLevel
public WebServerConfiguration setVerboseLevel(VerboseLevel verboseLevel)
Set the verbose level- Parameters:
verboseLevel- the verbose level- Returns:
- the WebServerConfiguration
-
getAccessLogFormatString
public java.lang.String getAccessLogFormatString()
Description copied from interface:IWebServerConfigurationGet access log format string:- %a - Remote IP address
- %A - Local IP address
- %b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
- %B - Bytes sent, excluding HTTP headers
- %h - Remote host name
- %H - Request protocol
- %l - Remote logical username from identd (always returns '-')
- %m - Request method
- %o - Obfuscated remote IP address (IPv4: last byte removed, IPv6: cut off after second colon, ie. '1.2.3.' or 'fe08:44:')
- %p - Local port
- %q - Query string (excluding the '?' character)
- %r - First line of the request
- %s - HTTP status code of the response
- %t - Date and time, in Common Log Format format
- %u - Remote user that was authenticated
- %U - Requested URL path
- %v - Local server name
- %D - Time taken to process the request, in millis
- %T - Time taken to process the request, in seconds
- %I - current Request thread name (can compare later with stacktraces)
In addition, the caller can specify one of the following aliases for commonly utilized patterns:
- common -
%h %l %u %t "%r" %s %b - combined -
%h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}" - commonobf -
%o %l %u %t "%r" %s %b - combinedobf -
%o %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}"
There is also support to write information from the cookie, incoming header, or the session
It is modeled after the apache syntax:%{i,xxx}for incoming headers%{o,xxx}for outgoing response headers%{c,xxx}for a specific cookie%{r,xxx}xxx is an attribute in the ServletRequest%{s,xxx}xxx is an attribute in the HttpSession
- Specified by:
getAccessLogFormatStringin interfaceIWebServerConfiguration- Returns:
- the accesslog format string
- See Also:
IWebServerConfiguration.getAccessLogFormatString()
-
setAccessLogFormatString
public WebServerConfiguration setAccessLogFormatString(java.lang.String accessLogFormatString)
Set the access log format string- Parameters:
accessLogFormatString- the access log format string- Returns:
- the WebServerConfiguration
-
getAccessLogFilePattern
public java.lang.String getAccessLogFilePattern()
Description copied from interface:IWebServerConfigurationThe access log file pattern, e.g. "access-%d{yyyy-MM-dd}.log.gz"For more information, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy
- Specified by:
getAccessLogFilePatternin interfaceIWebServerConfiguration- Returns:
- the access log file pattern
- See Also:
IWebServerConfiguration.getAccessLogFilePattern()
-
setAccessLogFilePattern
public WebServerConfiguration setAccessLogFilePattern(java.lang.String accessLogFilePattern)
Set the access log file pattern- Parameters:
accessLogFilePattern- the access log file pattern- Returns:
- the WebServerConfiguration
-
hasBasicAuthentication
public boolean hasBasicAuthentication()
Description copied from interface:IWebServerConfigurationDefine if the resource has basic authentication- Specified by:
hasBasicAuthenticationin interfaceIWebServerConfiguration- Returns:
- true if it is enabled
- See Also:
IWebServerConfiguration.hasBasicAuthentication()
-
getBasicAuthentication
public java.lang.String getBasicAuthentication()
Description copied from interface:IWebServerConfigurationGet the basic authentication: user:password- Specified by:
getBasicAuthenticationin interfaceIWebServerConfiguration- Returns:
- the basic authentication
- See Also:
IWebServerConfiguration.getBasicAuthentication()
-
setBasicAuthentication
public WebServerConfiguration setBasicAuthentication(java.lang.String basicAuthentication)
Define if basic authentication is enabled- Parameters:
basicAuthentication- true if basic authentication is enabled- Returns:
- the WebServerConfiguration
-
hasHealthCheck
public boolean hasHealthCheck()
Description copied from interface:IWebServerConfigurationDefine if the server support health- Specified by:
hasHealthCheckin interfaceIWebServerConfiguration- Returns:
- true if it is enabled
- See Also:
IWebServerConfiguration.hasHealthCheck()
-
getHealthPath
public java.lang.String getHealthPath()
Description copied from interface:IWebServerConfigurationGet the health path- Specified by:
getHealthPathin interfaceIWebServerConfiguration- Returns:
- the health path
- See Also:
IWebServerConfiguration.getHealthPath()
-
setHealthPath
public WebServerConfiguration setHealthPath(java.lang.String healthPath)
Set the health path- Parameters:
healthPath- the resource path- Returns:
- the WebServerConfiguration
-
getResourcePath
public java.lang.String getResourcePath()
Description copied from interface:IWebServerConfigurationGet the resource path- Specified by:
getResourcePathin interfaceIWebServerConfiguration- Returns:
- the resource path
- See Also:
IWebServerConfiguration.getResourcePath()
-
setResourcePath
public WebServerConfiguration setResourcePath(java.lang.String resourcePath)
Set the resource path- Parameters:
resourcePath- the resource path- Returns:
- the WebServerConfiguration
-
getIoThreads
public int getIoThreads()
Description copied from interface:IWebServerConfigurationGet the number of I/O threads- Specified by:
getIoThreadsin interfaceIWebServerConfiguration- Returns:
- the number of I/O threads
- See Also:
IWebServerConfiguration.getIoThreads()
-
setIoThreads
public WebServerConfiguration setIoThreads(java.lang.Integer ioThreads)
Set the I/O threads- Parameters:
ioThreads- the io threads- Returns:
- the WebServerConfiguration
-
getWorkerThreads
public int getWorkerThreads()
Description copied from interface:IWebServerConfigurationGet the number of working threads- Specified by:
getWorkerThreadsin interfaceIWebServerConfiguration- Returns:
- the number of working threads
- See Also:
IWebServerConfiguration.getWorkerThreads()
-
setWorkerThreads
public WebServerConfiguration setWorkerThreads(java.lang.Integer workerThreads)
Set the worker threads- Parameters:
workerThreads- the worker threads- Returns:
- the WebServerConfiguration
-
getWelcomeFiles
public java.lang.String[] getWelcomeFiles()
Description copied from interface:IWebServerConfigurationSet the welcome files- Specified by:
getWelcomeFilesin interfaceIWebServerConfiguration- Returns:
- the welcome files
- See Also:
IWebServerConfiguration.getWorkerThreads()
-
setWelcomeFiles
public WebServerConfiguration setWelcomeFiles(java.lang.String welcomeFiles)
Set the welcome files- Parameters:
welcomeFiles- the welcome files- Returns:
- the WebServerConfiguration
-
setWelcomeFiles
public WebServerConfiguration setWelcomeFiles(java.lang.String[] welcomeFiles)
Set the welcome files- Parameters:
welcomeFiles- the welcome files- Returns:
- the WebServerConfiguration
-
getSupportedFileExtensions
public java.lang.String[] getSupportedFileExtensions()
Description copied from interface:IWebServerConfigurationSet the supported file extensions- Specified by:
getSupportedFileExtensionsin interfaceIWebServerConfiguration- Returns:
- the supported file extensions
- See Also:
IWebServerConfiguration.getSupportedFileExtensions()
-
setSupportedFileExtensions
public WebServerConfiguration setSupportedFileExtensions(java.lang.String supportedFileExtensions)
Set the supported file extensions- Parameters:
supportedFileExtensions- the supported file extensions- Returns:
- the WebServerConfiguration
-
setSupportedFileExtensions
public WebServerConfiguration setSupportedFileExtensions(java.lang.String[] supportedFileExtensions)
Set the supported file extensions- Parameters:
supportedFileExtensions- the supported file extensions- Returns:
- the WebServerConfiguration
-
readProperties
public WebServerConfiguration readProperties()
Read the configuration from the classpath- Returns:
- the WebServerConfiguration
-
parseStringArray
public java.lang.String[] parseStringArray(java.lang.String stringArray)
Parse the string array- Parameters:
stringArray- the string array- Returns:
- the parsed string
-
formatArrayAsString
public java.lang.String formatArrayAsString(java.lang.String[] stringArray)
Format an array as string- Parameters:
stringArray- the welcome files- Returns:
- the formated string
-
-