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.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 hostnameintgetPort()Get the portjava.lang.StringgetResourcePath()Get the resource pathVerboseLevelgetVerboseLevel()Get the verbose levelbooleanhasBasicAuthentication()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 localbooleanreadFromClasspath()Define if the directory should be read from the classpathWebServerConfigurationreadProperties()Read the configuration from the classpathWebServerConfigurationsetAccessLogFormatString(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 nameWebServerConfigurationsetPort(java.lang.Integer port)Set the portWebServerConfigurationsetResourcePath(java.lang.String resourcePath)Set the resource pathWebServerConfigurationsetVerboseLevel(VerboseLevel verboseLevel)Set the verbose level
-
-
-
Constructor Detail
-
WebServerConfiguration
public WebServerConfiguration()
Constructor for WebServerConfiguration
-
WebServerConfiguration
public WebServerConfiguration(IWebServerConfiguration configuration)
Constructor for WebServerConfiguration- Parameters:
configuration- the configuration
-
-
Method Detail
-
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
-
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
-
readProperties
public WebServerConfiguration readProperties()
Read the configuration from the classpath- Returns:
- the WebServerConfiguration
-
-