public.javadoc.org.spincast.plugins.config.SpincastConfigDefault.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
SpincastConfigDefault (org.spincast:spincast-framework 1.14.0 API)
org.spincast.plugins.config
Class SpincastConfigDefault
- java.lang.Object
-
- org.spincast.plugins.config.ConfigFinder
-
- org.spincast.plugins.config.SpincastConfigDefault
-
- All Implemented Interfaces:
- SpincastConfig
- Direct Known Subclasses:
- SpincastConfigTestingDefault
public class SpincastConfigDefault
extends ConfigFinder
implements SpincastConfig
If you extend this class (which is recommended to implement your
configuration), beware that causing circular dependencies is very
easy if you inject more dependencies than SpincastConfigPluginConfig!
Indeed, most components depend on the config components.
Also, don't forget to annotated the testingMode
parameter with @TestingMode!
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.spincast.plugins.config.ConfigFinder
ConfigFinder.ConfigFinderBuilder
-
Field Summary
Fields
Modifier and Type
Field and Description
static String
ENVIRONMENT_NAME_DEFAULT
-
Fields inherited from class org.spincast.plugins.config.ConfigFinder
configs, logger, rawConfigs
-
Constructor Summary
Constructors
Modifier
Constructor and Description
protected
SpincastConfigDefault(SpincastConfigPluginConfig spincastConfigPluginConfig,
boolean testingMode)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
List<String>
getContentTypesToSkipGziping()
Even if gziping of the response is enabled, those Content-Types
still won't be gzipped.
String
getCookieNameFlashMessage()
Name of the Cookie to to use save a
Flash Message id.
String
getCookieNameLocale()
Name of the Cookie to use to
save the user Locale
.
String
getCookieNameTimeZoneId()
Name of the Cookie to use to
save the id of the user TimeZone
.
String
getCookiesValidatorCookieName()
Name of the Cookie to use to validate if
cookies are enabled.
Locale
getDefaultLocale()
The default Locale to use if no other Locale can be found
as a "best match", for the current request.
int
getDefaultRouteCacheFilterSecondsNbr()
When using the .cache()
method on
a route builder, this is the default number of
seconds to use.
Integer
getDefaultRouteCacheFilterSecondsNbrCdns()
When using the .cache()
method on
a route builder, this is the default number of
seconds to use by the CDNs.
StaticResourceCacheConfig
getDefaultStaticResourceCacheConfig(boolean isDynamicResource)
The default cache configurations for the static resource.
int
getDefaultTemplateVariablesFilterPosition()
If addGlobalTemplateVariablesAdderFilter
returns true
, then this is the position at
which the filter will be added.
TimeZone
getDefaultTimeZone()
The default TimeZone to use if no other TimeZone can be found
as a "best match", for the current request.
DictionaryEntryNotFoundBehavior
getDictionaryEntryNotFoundBehavior()
If a dictionary key is not found, how must Spincast react?
String
getEnvironmentName()
Returns the name of the environment.
protected String
getHostForDefaultPublicServerSchemeHostPort()
int
getHttpServerPort()
The HTTP (unsecure) port on which the server will listen on.
String
getHttpsKeyStoreKeyPass()
The "keypass" of the KeyStore
, for SSL.
String
getHttpsKeyStorePath()
The path to the KeyStore
, for SSL.
String
getHttpsKeyStoreStorePass()
The "storepass" of the KeyStore
, for SSL.
String
getHttpsKeyStoreType()
The type of the KeyStore
, for SSL.
int
getHttpsServerPort()
The HTTPS (secure) port on which the server will listen on.
int
getJsonPathArrayIndexMax()
Gets the maximum index of an element of an array, when parsing
a JsonPath
.
int
getKeyMaxLengthWhenConvertingMapToJsonObject()
int
getMaxNumberOfKeysWhenConvertingMapToJsonObject()
Gets the maximum number of keys
in a Map that
can be parsed as JsonPaths
to create a
JsonObject
.
String
getPublicServerHost()
The public host
int
getPublicServerPort()
The public port
String
getPublicServerScheme()
Three of the rare "final" methods in Spincast!
protected URI
getPublicURI()
String
getPublicUrlBase()
You should override this config!!!!
String
getQueryParamFlashMessageId()
The name of the queryString parameter to use
for a Flash Message id, when cookies are not
available.
int
getRouteForwardingMaxNumber()
The maximum number of time a request can be forwarded to another
route.
String
getServerHost()
The host/IP on which the server will listen to.
long
getServerMaxRequestBodyBytes()
Maximum number of bytes a request's body can have.
String
getSpincastModelRootVariableName()
Name of the root variables reserved for
Spincast in the response's model.
protected String
getSpincastWritableDirPath()
The path to the writable directory.
File
getTempDir()
A directory where temp files can be written by Spincast.
String
getValidationElementDefaultName()
The default name to use for the validation element
that will be available on the response's model when
Form
elements are added.
File
getWritableRootDir()
Will call getSpincastWritableDirPath()
to get
the path to use for the writable directory.
protected void
init()
boolean
isAddDefaultTemplateVariablesFilter()
Should the GlobalTemplateVariablesAdderFilter be automatically
added to all routes?
boolean
isDefaultRouteCacheFilterPrivate()
When using the .cache()
method on
a route builder, is the cache private by default?
boolean
isDevelopmentMode()
Let this to true
on a development environment,
where errors can be publicly displayed, where cache can
be disabled, where class redefinition can be done, etc.
boolean
isEnableCookiesValidator()
If true
, Spincast will always try to set a cookie
to validate if cookies are enabled on the client.
boolean
isEnableHttp2()
Should HTTP/2
be enabled on the
embedded Server
, if its supports it?
Note that Undertow, the default server provided with
Spincast, does support it.
boolean
isRoutesCaseSensitive()
Are the URLS case-sensitive or not, during the route matching
process?
The default value is false
.
boolean
isTestingMode()
Returns true
if the context
has been created for running tests.
boolean
isValidateLocalhostHost()
By default, if SpincastConfig.getPublicServerHost()
returns
"localhost"
, SpincastConfig.getEnvironmentName()
is
not "local"
and SpincastConfig.isDevelopmentMode()
is false,
an exception is thrown when the application starts.
boolean
isWriteToDiskDynamicStaticResource()
If true
, the dynamic resources (static resource
which have a generator in case they don't exist) won't be
saved to disk.
-
Methods inherited from class org.spincast.plugins.config.ConfigFinder
clearPrefixes, configure, expandMap, getAppJarDirectory, getAppRootDirectoryNoJar, getBigDecimal, getBigDecimal, getBigDecimalFromElement, getBigDecimalList, getBigDecimalList, getBoolean, getBoolean, getBooleanFromElement, getBooleanList, getBooleanList, getClasspathFilePath, getConfig, getConfig, getConfigFromMap, getConfigFromMap, getConfigList, getConfigList, getConfigs, getDate, getDate, getDateFromElement, getDateList, getDateList, getEnvironmentVariables, getEnvironmentVariablesConfigs, getEnvironmentVariablesPrefixes, getExternalFilePath, getInteger, getInteger, getIntegerFromElement, getIntegerList, getIntegerList, getLong, getLong, getLongFromElement, getLongList, getLongList, getMap, getMap, getMapList, getMapList, getRawConfig, getRawConfigs, getString, getString, getStringList, getStringList, getSystemPropertiesConfigs, getSystemPropertiesPrefixes, isEnvironmentVariablesStripPrefix, isExternalFileConfigsOverrideEnvironmentVariables, isSystemPropertiesStripPrefix, isThrowExceptionIfSpecifiedClasspathConfigFileIsNotFound, isThrowExceptionIfSpecifiedExternalConfigFileIsNotFound, loadYamlFileConfigs, mergeMaps
-
-
Field Detail
-
ENVIRONMENT_NAME_DEFAULT
public static final String ENVIRONMENT_NAME_DEFAULT
- See Also:
- Constant Field Values
-
Constructor Detail
-
SpincastConfigDefault
@Inject
protected SpincastConfigDefault(SpincastConfigPluginConfig spincastConfigPluginConfig,
boolean testingMode)
Constructor
-
Method Detail
-
init
@Inject
protected void init()
-
getEnvironmentName
public String getEnvironmentName()
Description copied from interface: SpincastConfig
Returns the name of the environment.
The default value is local
.
- Specified by:
getEnvironmentName
in interface SpincastConfig
- Returns:
- the name of the environment
-
getHttpServerPort
public int getHttpServerPort()
Description copied from interface: SpincastConfig
The HTTP (unsecure) port on which the server will listen on.
If <= 0, it won't be used.
The default value is 44419
so HTTP
is enabled by default.
- Specified by:
getHttpServerPort
in interface SpincastConfig
- Returns:
- the HTTP port
-
getHttpsServerPort
public int getHttpsServerPort()
Description copied from interface: SpincastConfig
The HTTPS (secure) port on which the server will listen on.
If <= 0, it won't be used.
The default value is -1
so HTTPS
is not enabled by default.
- Specified by:
getHttpsServerPort
in interface SpincastConfig
- Returns:
- the HTTPS port
-
getHttpsKeyStorePath
public String getHttpsKeyStorePath()
Description copied from interface: SpincastConfig
The path to the KeyStore
, for SSL. Can be a
classpath path or and absolute path.
The classpath will be checked first.
Only used if getHttpsServerPort()
returns a port > 0.
The default value is null
.
- Specified by:
getHttpsKeyStorePath
in interface SpincastConfig
- Returns:
- the path to the
KeyStore
-
getHttpsKeyStoreType
public String getHttpsKeyStoreType()
Description copied from interface: SpincastConfig
The type of the KeyStore
, for SSL.
For example: "JKS".
Only used if getHttpsServerPort()
returns a port > 0.
The default value is null
.
- Specified by:
getHttpsKeyStoreType
in interface SpincastConfig
- Returns:
- the type of the
KeyStore
-
getHttpsKeyStoreStorePass
public String getHttpsKeyStoreStorePass()
Description copied from interface: SpincastConfig
The "storepass" of the KeyStore
, for SSL.
Only used if getHttpsServerPort()
returns a port > 0.
The default value is null
.
- Specified by:
getHttpsKeyStoreStorePass
in interface SpincastConfig
- Returns:
- the "storepass" of the
KeyStore
-
getHttpsKeyStoreKeyPass
public String getHttpsKeyStoreKeyPass()
Description copied from interface: SpincastConfig
The "keypass" of the KeyStore
, for SSL.
Only used if getHttpsServerPort()
returns a port > 0.
The default value is null
.
- Specified by:
getHttpsKeyStoreKeyPass
in interface SpincastConfig
- Returns:
- the "keypass" of the
KeyStore
-
getPublicURI
protected URI getPublicURI()
-
getPublicServerScheme
public final String getPublicServerScheme()
Three of the rare "final" methods in Spincast!
- Specified by:
getPublicServerScheme
in interface SpincastConfig
-
getPublicServerHost
public final String getPublicServerHost()
Description copied from interface: SpincastConfig
The public host
- Specified by:
getPublicServerHost
in interface SpincastConfig
-
getPublicServerPort
public final int getPublicServerPort()
Description copied from interface: SpincastConfig
The public port
- Specified by:
getPublicServerPort
in interface SpincastConfig
-
getPublicUrlBase
public String getPublicUrlBase()
You should override this config!!!!
- Specified by:
getPublicUrlBase
in interface SpincastConfig
-
getHostForDefaultPublicServerSchemeHostPort
protected String getHostForDefaultPublicServerSchemeHostPort()
-
getServerHost
public String getServerHost()
Description copied from interface: SpincastConfig
The host/IP on which the server will listen to.
The default value is 0.0.0.0
.
- Specified by:
getServerHost
in interface SpincastConfig
- Returns:
- the host/IP
-
isDevelopmentMode
public boolean isDevelopmentMode()
Description copied from interface: SpincastConfig
Let this to true
on a development environment,
where errors can be publicly displayed, where cache can
be disabled, where class redefinition can be done, etc.
In production set it to false
The default value is true
.
- Specified by:
isDevelopmentMode
in interface SpincastConfig
- Returns:
true
if debug mode is enabled.
-
isTestingMode
public boolean isTestingMode()
Description copied from interface: SpincastConfig
Returns true
if the context
has been created for running tests.
For example, this would by default disable the
scheduled tasks to be registered.
- Specified by:
isTestingMode
in interface SpincastConfig
-
isRoutesCaseSensitive
public boolean isRoutesCaseSensitive()
Description copied from interface: SpincastConfig
Are the URLS case-sensitive or not, during the route matching
process?
The default value is false
.
- Specified by:
isRoutesCaseSensitive
in interface SpincastConfig
- Returns:
- if they are case-sensitive
- See Also:
- Should URL be case sensitive?
-
getServerMaxRequestBodyBytes
public long getServerMaxRequestBodyBytes()
Description copied from interface: SpincastConfig
Maximum number of bytes a request's body can have.
"-1" means no limit.
The default value is 104857600
(100MB).
- Specified by:
getServerMaxRequestBodyBytes
in interface SpincastConfig
- Returns:
- the maximum number of bytes
-
isEnableHttp2
public boolean isEnableHttp2()
Description copied from interface: SpincastConfig
Should HTTP/2
be enabled on the
embedded Server
, if its supports it?
Note that Undertow, the default server provided with
Spincast, does support it.
Defaults to true
.
- Specified by:
isEnableHttp2
in interface SpincastConfig
-
getContentTypesToSkipGziping
public List<String> getContentTypesToSkipGziping()
Description copied from interface: SpincastConfig
Even if gziping of the response is enabled, those Content-Types
still won't be gzipped.
If an entry ends with "*", it will be considered as a prefix
(ex: "image/*" will match all Content-Types starting with "image/").
Otherwise, the current response Content-Type will have to exactly
match the entry (case insensitive), or being followed by a " " or
a ";".
- Specified by:
getContentTypesToSkipGziping
in interface SpincastConfig
- Returns:
- the Content-Types that shouldn't be gzipped.
-
getWritableRootDir
public File getWritableRootDir()
Will call getSpincastWritableDirPath()
to get
the path to use for the writable directory. If this
method returns null
, a directory will be
created under the java.io.tmpdir
directory.
- Specified by:
getWritableRootDir
in interface SpincastConfig
- Returns:
- a directory with write permissions for Spincast.
-
getTempDir
public File getTempDir()
Description copied from interface: SpincastConfig
A directory where temp files can be written by Spincast.
This directory will be emptied each time the application starts!
- Specified by:
getTempDir
in interface SpincastConfig
-
getSpincastWritableDirPath
protected String getSpincastWritableDirPath()
The path to the writable directory.
The path can be relative or absolute.
- Returns:
- the path or
null
to use the
default location (using the "java.io.tmpdir" folder).
-
getDefaultLocale
public Locale getDefaultLocale()
Description copied from interface: SpincastConfig
The default Locale to use if no other Locale can be found
as a "best match", for the current request.
The default value is Locale.US
.
- Specified by:
getDefaultLocale
in interface SpincastConfig
- Returns:
- the default Locale
-
getDefaultTimeZone
public TimeZone getDefaultTimeZone()
Description copied from interface: SpincastConfig
The default TimeZone to use if no other TimeZone can be found
as a "best match", for the current request.
The default value is UTC
.
- Specified by:
getDefaultTimeZone
in interface SpincastConfig
- Returns:
- the default TimeZone
-
getRouteForwardingMaxNumber
public int getRouteForwardingMaxNumber()
Description copied from interface: SpincastConfig
The maximum number of time a request can be forwarded to another
route. After this number, an exception will be thrown.
The default value is 2
.
- Specified by:
getRouteForwardingMaxNumber
in interface SpincastConfig
- Returns:
- the maximum number of time
-
getDefaultRouteCacheFilterSecondsNbr
public int getDefaultRouteCacheFilterSecondsNbr()
Description copied from interface: SpincastConfig
When using the .cache()
method on
a route builder, this is the default number of
seconds to use.
- Specified by:
getDefaultRouteCacheFilterSecondsNbr
in interface SpincastConfig
-
isDefaultRouteCacheFilterPrivate
public boolean isDefaultRouteCacheFilterPrivate()
Description copied from interface: SpincastConfig
When using the .cache()
method on
a route builder, is the cache private by default?
- Specified by:
isDefaultRouteCacheFilterPrivate
in interface SpincastConfig
-
getDefaultRouteCacheFilterSecondsNbrCdns
public Integer getDefaultRouteCacheFilterSecondsNbrCdns()
Description copied from interface: SpincastConfig
When using the .cache()
method on
a route builder, this is the default number of
seconds to use by the CDNs.
- Specified by:
getDefaultRouteCacheFilterSecondsNbrCdns
in interface SpincastConfig
-
isWriteToDiskDynamicStaticResource
public boolean isWriteToDiskDynamicStaticResource()
Description copied from interface: SpincastConfig
If true
, the dynamic resources (static resource
which have a generator in case they don't exist) won't be
saved to disk. This means that the generator will always be called,
so changes during development will be picked up.
- Specified by:
isWriteToDiskDynamicStaticResource
in interface SpincastConfig
-
isAddDefaultTemplateVariablesFilter
public boolean isAddDefaultTemplateVariablesFilter()
Description copied from interface: SpincastConfig
Should the GlobalTemplateVariablesAdderFilter be automatically
added to all routes?
This filter bind some default variables to be used by the
templating engine.
- Specified by:
isAddDefaultTemplateVariablesFilter
in interface SpincastConfig
-
getDefaultTemplateVariablesFilterPosition
public int getDefaultTemplateVariablesFilterPosition()
Description copied from interface: SpincastConfig
If addGlobalTemplateVariablesAdderFilter
returns true
, then this is the position at
which the filter will be added.
- Specified by:
getDefaultTemplateVariablesFilterPosition
in interface SpincastConfig
-
getDefaultStaticResourceCacheConfig
public StaticResourceCacheConfig getDefaultStaticResourceCacheConfig(boolean isDynamicResource)
Description copied from interface: SpincastConfig
The default cache configurations for the static resource.
This will be used if no cache(...)
method is
used when building the static resource's route.
- Specified by:
getDefaultStaticResourceCacheConfig
in interface SpincastConfig
- Parameters:
isDynamicResource
- if true
, a generator is
use when the resource doesn't exist. Those kind of generated resources
may be modified more often then trully static resources, so we may
want to use a different caching period.
- Returns:
- the default cache configuration to use or
null
so no cache headers are sent at all.
-
getMaxNumberOfKeysWhenConvertingMapToJsonObject
public int getMaxNumberOfKeysWhenConvertingMapToJsonObject()
Description copied from interface: SpincastConfig
Gets the maximum number of keys
in a Map that
can be parsed as JsonPaths
to create a
JsonObject
.
This maximum is to prevent malicious user to POST
a very big number of keys
and harm
the server.
- Specified by:
getMaxNumberOfKeysWhenConvertingMapToJsonObject
in interface SpincastConfig
-
getKeyMaxLengthWhenConvertingMapToJsonObject
public int getKeyMaxLengthWhenConvertingMapToJsonObject()
Description copied from interface: SpincastConfig
Gets the maximum length of a key
in a Map that
can be parsed as JsonPaths
using the
create
method.
This maximum is to prevent malicious user to POST
very long and complex keys
and harm
the server.
- Specified by:
getKeyMaxLengthWhenConvertingMapToJsonObject
in interface SpincastConfig
-
getJsonPathArrayIndexMax
public int getJsonPathArrayIndexMax()
Description copied from interface: SpincastConfig
Gets the maximum index of an element of an array, when parsing
a JsonPath
.
- Specified by:
getJsonPathArrayIndexMax
in interface SpincastConfig
-
isValidateLocalhostHost
public boolean isValidateLocalhostHost()
Description copied from interface: SpincastConfig
By default, if SpincastConfig.getPublicServerHost()
returns
"localhost"
, SpincastConfig.getEnvironmentName()
is
not "local"
and SpincastConfig.isDevelopmentMode()
is false,
an exception is thrown when the application starts.
This validation is to make sure the developers
didn't forget to override the SpincastConfig.getPublicUrlBase()
method when they release to a non local environment.
You can disable this validation if you want.
- Specified by:
isValidateLocalhostHost
in interface SpincastConfig
-
isEnableCookiesValidator
public boolean isEnableCookiesValidator()
Description copied from interface: SpincastConfig
If true
, Spincast will always try to set a cookie
to validate if cookies are enabled on the client.
This is enabled by default
- Specified by:
isEnableCookiesValidator
in interface SpincastConfig
-
getQueryParamFlashMessageId
public String getQueryParamFlashMessageId()
Description copied from interface: SpincastConfig
The name of the queryString parameter to use
for a Flash Message id, when cookies are not
available.
- Specified by:
getQueryParamFlashMessageId
in interface SpincastConfig
-
getCookieNameFlashMessage
public String getCookieNameFlashMessage()
Description copied from interface: SpincastConfig
Name of the Cookie to to use save a
Flash Message id.
- Specified by:
getCookieNameFlashMessage
in interface SpincastConfig
-
getCookieNameLocale
public String getCookieNameLocale()
Description copied from interface: SpincastConfig
Name of the Cookie to use to
save the user Locale
.
The default is "spincast_locale"
- Specified by:
getCookieNameLocale
in interface SpincastConfig
-
getCookieNameTimeZoneId
public String getCookieNameTimeZoneId()
Description copied from interface: SpincastConfig
Name of the Cookie to use to
save the id of the user TimeZone
.
The default is "spincast_timezone"
- Specified by:
getCookieNameTimeZoneId
in interface SpincastConfig
-
getCookiesValidatorCookieName
public String getCookiesValidatorCookieName()
Description copied from interface: SpincastConfig
Name of the Cookie to use to validate if
cookies are enabled.
The default is "spincast_cookies_enabled".
- Specified by:
getCookiesValidatorCookieName
in interface SpincastConfig
-
getSpincastModelRootVariableName
public String getSpincastModelRootVariableName()
Description copied from interface: SpincastConfig
Name of the root variables reserved for
Spincast in the response's model.
- Specified by:
getSpincastModelRootVariableName
in interface SpincastConfig
-
getValidationElementDefaultName
public String getValidationElementDefaultName()
Description copied from interface: SpincastConfig
The default name to use for the validation element
that will be available on the response's model when
Form
elements are added.
- Specified by:
getValidationElementDefaultName
in interface SpincastConfig
-
getDictionaryEntryNotFoundBehavior
public DictionaryEntryNotFoundBehavior getDictionaryEntryNotFoundBehavior()
Description copied from interface: SpincastConfig
If a dictionary key is not found, how must Spincast react?
Note that if the key is not found for the current Locale,
Spincast will first check if it exists for the fallback
Locale (the empty Locale).
By default, in debug mode an exception is thrown. Otherwise,
an empty string is returned but an error is logged.
- Specified by:
getDictionaryEntryNotFoundBehavior
in interface SpincastConfig
Copyright © 2019. All rights reserved.