Class SpincastConfigDefault
- All Implemented Interfaces:
SpincastConfig
- Direct Known Subclasses:
AppConfig,AppConfigDefault,SpincastConfigTestingDefault
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
FieldsFields inherited from class org.spincast.plugins.config.ConfigFinder
configs, logger, rawConfigs -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSpincastConfigDefault(SpincastConfigPluginConfig spincastConfigPluginConfig, boolean testingMode) Constructor -
Method Summary
Modifier and TypeMethodDescriptionEven if gziping of the response is enabled, those Content-Types still won't be gzipped.Name of the Cookie to to use save a Flash Message id.Name of the Cookie to use to save the userLocale.Name of the Cookie to use to save the id of the userTimeZone.Name of the Cookie to use to validate if cookies are enabled.The default Locale to use if no other Locale can be found as a "best match", for the current request.intWhen using the.cache()method on a route builder, this is the default number of seconds to use.When using the.cache()method on a route builder, this is the default number of seconds to use by the CDNs.getDefaultStaticResourceCacheConfig(boolean isDynamicResource) The default cache configurations for the static resource.intIfaddGlobalTemplateVariablesAdderFilterreturnstrue, then this is the position at which the filter will be added.The default TimeZone to use if no other TimeZone can be found as a "best match", for the current request.If a dictionary key is not found, how must Spincast react?Returns the name of the environment.protected StringintThe HTTP (unsecure) port on which the server will listen on.The "keypass" of theKeyStore, for SSL.The path to theKeyStore, for SSL.The "storepass" of theKeyStore, for SSL.The type of theKeyStore, for SSL.intThe HTTPS (secure) port on which the server will listen on.intGets the maximum index of an element of an array, when parsing aJsonPath.intintGets the maximum number ofkeysin a Map that can be parsed asJsonPathsto create aJsonObject.final StringThe public hostfinal intThe public portfinal StringThree of the rare "final" methods in Spincast!protected URIYou should override this config!!!!The name of the queryString parameter to use for a Flash Message id, when cookies are not available.intThe maximum number of time a request can be forwarded to another route.The host/IP on which the server will listen to.longMaximum number of bytes a request's body can have.Name of the root variables reserved for Spincast in the response's model.protected StringThe path to the writable directory.A directory where temp files can be written by Spincast.The default name to use for the validation element that will be available on the response's model whenFormelements are added.Will callgetSpincastWritableDirPath()to get the path to use for the writable directory.protected voidinit()booleanShould the GlobalTemplateVariablesAdderFilter be automatically added to all routes?booleanWhen using the.cache()method on a route builder, is the cache private by default?booleanLet this totrueon a development environment, where errors can be publicly displayed, where cache can be disabled, where class redefinition can be done, etc.booleanIftrue, Spincast will always try to set a cookie to validate if cookies are enabled on the client.booleanShouldHTTP/2be enabled on the embeddedServer, if its supports it? Note that Undertow, the default server provided with Spincast, does support it.booleanAre the URLS case-sensitive or not, during the route matching process? The default value isfalse.booleanReturnstrueif the context has been created for running tests.booleanBy default, ifSpincastConfig.getPublicServerHost()returns"localhost",SpincastConfig.getEnvironmentName()is not"local"andSpincastConfig.isDevelopmentMode()is false, an exception is thrown when the application starts.booleanIftrue, 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 Details
-
ENVIRONMENT_NAME_DEFAULT
- See Also:
-
-
Constructor Details
-
SpincastConfigDefault
@Inject protected SpincastConfigDefault(SpincastConfigPluginConfig spincastConfigPluginConfig, boolean testingMode) Constructor
-
-
Method Details
-
init
@Inject protected void init() -
getEnvironmentName
Description copied from interface:SpincastConfigReturns the name of the environment. The default value islocal.- Specified by:
getEnvironmentNamein interfaceSpincastConfig- Returns:
- the name of the environment
-
getHttpServerPort
public int getHttpServerPort()Description copied from interface:SpincastConfigThe HTTP (unsecure) port on which the server will listen on. If <= 0, it won't be used. The default value is44419so HTTP is enabled by default.- Specified by:
getHttpServerPortin interfaceSpincastConfig- Returns:
- the HTTP port
-
getHttpsServerPort
public int getHttpsServerPort()Description copied from interface:SpincastConfigThe HTTPS (secure) port on which the server will listen on. If <= 0, it won't be used. The default value is-1so HTTPS is not enabled by default.- Specified by:
getHttpsServerPortin interfaceSpincastConfig- Returns:
- the HTTPS port
-
getHttpsKeyStorePath
Description copied from interface:SpincastConfigThe path to theKeyStore, for SSL. Can be a classpath path or and absolute path. The classpath will be checked first. Only used ifgetHttpsServerPort()returns a port > 0. The default value isnull.- Specified by:
getHttpsKeyStorePathin interfaceSpincastConfig- Returns:
- the path to the
KeyStore
-
getHttpsKeyStoreType
Description copied from interface:SpincastConfigThe type of theKeyStore, for SSL. For example: "JKS". Only used ifgetHttpsServerPort()returns a port > 0. The default value isnull.- Specified by:
getHttpsKeyStoreTypein interfaceSpincastConfig- Returns:
- the type of the
KeyStore
-
getHttpsKeyStoreStorePass
Description copied from interface:SpincastConfigThe "storepass" of theKeyStore, for SSL. Only used ifgetHttpsServerPort()returns a port > 0. The default value isnull.- Specified by:
getHttpsKeyStoreStorePassin interfaceSpincastConfig- Returns:
- the "storepass" of the
KeyStore
-
getHttpsKeyStoreKeyPass
Description copied from interface:SpincastConfigThe "keypass" of theKeyStore, for SSL. Only used ifgetHttpsServerPort()returns a port > 0. The default value isnull.- Specified by:
getHttpsKeyStoreKeyPassin interfaceSpincastConfig- Returns:
- the "keypass" of the
KeyStore
-
getPublicURI
-
getPublicServerScheme
Three of the rare "final" methods in Spincast!- Specified by:
getPublicServerSchemein interfaceSpincastConfig
-
getPublicServerHost
Description copied from interface:SpincastConfigThe public host- Specified by:
getPublicServerHostin interfaceSpincastConfig
-
getPublicServerPort
public final int getPublicServerPort()Description copied from interface:SpincastConfigThe public port- Specified by:
getPublicServerPortin interfaceSpincastConfig
-
getPublicUrlBase
You should override this config!!!!- Specified by:
getPublicUrlBasein interfaceSpincastConfig
-
getHostForDefaultPublicServerSchemeHostPort
-
getServerHost
Description copied from interface:SpincastConfigThe host/IP on which the server will listen to. The default value is0.0.0.0.- Specified by:
getServerHostin interfaceSpincastConfig- Returns:
- the host/IP
-
isDevelopmentMode
public boolean isDevelopmentMode()Description copied from interface:SpincastConfigLet this totrueon 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
falseThe default value is
true.- Specified by:
isDevelopmentModein interfaceSpincastConfig- Returns:
trueif debug mode is enabled.
-
isTestingMode
public boolean isTestingMode()Description copied from interface:SpincastConfigReturnstrueif the context has been created for running tests.For example, this would by default disable the scheduled tasks to be registered.
- Specified by:
isTestingModein interfaceSpincastConfig
-
isRoutesCaseSensitive
public boolean isRoutesCaseSensitive()Description copied from interface:SpincastConfigAre the URLS case-sensitive or not, during the route matching process? The default value isfalse.- Specified by:
isRoutesCaseSensitivein interfaceSpincastConfig- Returns:
- if they are case-sensitive
- See Also:
-
getServerMaxRequestBodyBytes
public long getServerMaxRequestBodyBytes()Description copied from interface:SpincastConfigMaximum number of bytes a request's body can have. "-1" means no limit. The default value is104857600(100MB).- Specified by:
getServerMaxRequestBodyBytesin interfaceSpincastConfig- Returns:
- the maximum number of bytes
-
isEnableHttp2
public boolean isEnableHttp2()Description copied from interface:SpincastConfigShouldHTTP/2be enabled on the embeddedServer, if its supports it? Note that Undertow, the default server provided with Spincast, does support it.Defaults to
true.- Specified by:
isEnableHttp2in interfaceSpincastConfig
-
getContentTypesToSkipGziping
Description copied from interface:SpincastConfigEven 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:
getContentTypesToSkipGzipingin interfaceSpincastConfig- Returns:
- the Content-Types that shouldn't be gzipped.
-
getWritableRootDir
Will callgetSpincastWritableDirPath()to get the path to use for the writable directory. If this method returnsnull, a directory will be created under thejava.io.tmpdirdirectory.- Specified by:
getWritableRootDirin interfaceSpincastConfig- Returns:
- a directory with write permissions for Spincast.
-
getTempDir
Description copied from interface:SpincastConfigA directory where temp files can be written by Spincast.This directory will be emptied each time the application starts!
- Specified by:
getTempDirin interfaceSpincastConfig
-
getSpincastWritableDirPath
The path to the writable directory.The path can be relative or absolute.
- Returns:
- the path or
nullto use the default location (using the "java.io.tmpdir" folder).
-
getDefaultLocale
Description copied from interface:SpincastConfigThe default Locale to use if no other Locale can be found as a "best match", for the current request. The default value isLocale.US.- Specified by:
getDefaultLocalein interfaceSpincastConfig- Returns:
- the default Locale
-
getDefaultTimeZone
Description copied from interface:SpincastConfigThe default TimeZone to use if no other TimeZone can be found as a "best match", for the current request. The default value isUTC.- Specified by:
getDefaultTimeZonein interfaceSpincastConfig- Returns:
- the default TimeZone
-
getRouteForwardingMaxNumber
public int getRouteForwardingMaxNumber()Description copied from interface:SpincastConfigThe maximum number of time a request can be forwarded to another route. After this number, an exception will be thrown. The default value is2.- Specified by:
getRouteForwardingMaxNumberin interfaceSpincastConfig- Returns:
- the maximum number of time
-
getDefaultRouteCacheFilterSecondsNbr
public int getDefaultRouteCacheFilterSecondsNbr()Description copied from interface:SpincastConfigWhen using the.cache()method on a route builder, this is the default number of seconds to use.- Specified by:
getDefaultRouteCacheFilterSecondsNbrin interfaceSpincastConfig
-
isDefaultRouteCacheFilterPrivate
public boolean isDefaultRouteCacheFilterPrivate()Description copied from interface:SpincastConfigWhen using the.cache()method on a route builder, is the cache private by default?- Specified by:
isDefaultRouteCacheFilterPrivatein interfaceSpincastConfig
-
getDefaultRouteCacheFilterSecondsNbrCdns
Description copied from interface:SpincastConfigWhen using the.cache()method on a route builder, this is the default number of seconds to use by the CDNs.- Specified by:
getDefaultRouteCacheFilterSecondsNbrCdnsin interfaceSpincastConfig
-
isWriteToDiskDynamicStaticResource
public boolean isWriteToDiskDynamicStaticResource()Description copied from interface:SpincastConfigIftrue, 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:
isWriteToDiskDynamicStaticResourcein interfaceSpincastConfig
-
isAddDefaultTemplateVariablesFilter
public boolean isAddDefaultTemplateVariablesFilter()Description copied from interface:SpincastConfigShould the GlobalTemplateVariablesAdderFilter be automatically added to all routes?This filter bind some default variables to be used by the templating engine.
- Specified by:
isAddDefaultTemplateVariablesFilterin interfaceSpincastConfig
-
getDefaultTemplateVariablesFilterPosition
public int getDefaultTemplateVariablesFilterPosition()Description copied from interface:SpincastConfigIfaddGlobalTemplateVariablesAdderFilterreturnstrue, then this is the position at which the filter will be added.- Specified by:
getDefaultTemplateVariablesFilterPositionin interfaceSpincastConfig
-
getDefaultStaticResourceCacheConfig
Description copied from interface:SpincastConfigThe 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:
getDefaultStaticResourceCacheConfigin interfaceSpincastConfig- Parameters:
isDynamicResource- iftrue, 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
nullso no cache headers are sent at all.
-
getMaxNumberOfKeysWhenConvertingMapToJsonObject
public int getMaxNumberOfKeysWhenConvertingMapToJsonObject()Description copied from interface:SpincastConfigGets the maximum number ofkeysin a Map that can be parsed asJsonPathsto create aJsonObject.This maximum is to prevent malicious user to POST a very big number of
keysand harm the server.- Specified by:
getMaxNumberOfKeysWhenConvertingMapToJsonObjectin interfaceSpincastConfig
-
getKeyMaxLengthWhenConvertingMapToJsonObject
public int getKeyMaxLengthWhenConvertingMapToJsonObject()Description copied from interface:SpincastConfigGets the maximum length of akeyin a Map that can be parsed asJsonPathsusing thecreatemethod.This maximum is to prevent malicious user to POST very long and complex
keysand harm the server.- Specified by:
getKeyMaxLengthWhenConvertingMapToJsonObjectin interfaceSpincastConfig
-
getJsonPathArrayIndexMax
public int getJsonPathArrayIndexMax()Description copied from interface:SpincastConfigGets the maximum index of an element of an array, when parsing aJsonPath.- Specified by:
getJsonPathArrayIndexMaxin interfaceSpincastConfig
-
isValidateLocalhostHost
public boolean isValidateLocalhostHost()Description copied from interface:SpincastConfigBy default, ifSpincastConfig.getPublicServerHost()returns"localhost",SpincastConfig.getEnvironmentName()is not"local"andSpincastConfig.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:
isValidateLocalhostHostin interfaceSpincastConfig
-
isEnableCookiesValidator
public boolean isEnableCookiesValidator()Description copied from interface:SpincastConfigIftrue, Spincast will always try to set a cookie to validate if cookies are enabled on the client.This is enabled by default
- Specified by:
isEnableCookiesValidatorin interfaceSpincastConfig
-
getQueryParamFlashMessageId
Description copied from interface:SpincastConfigThe name of the queryString parameter to use for a Flash Message id, when cookies are not available.- Specified by:
getQueryParamFlashMessageIdin interfaceSpincastConfig
-
getCookieNameFlashMessage
Description copied from interface:SpincastConfigName of the Cookie to to use save a Flash Message id.- Specified by:
getCookieNameFlashMessagein interfaceSpincastConfig
-
getCookieNameLocale
Description copied from interface:SpincastConfigName of the Cookie to use to save the userLocale.The default is "spincast_locale"
- Specified by:
getCookieNameLocalein interfaceSpincastConfig
-
getCookieNameTimeZoneId
Description copied from interface:SpincastConfigName of the Cookie to use to save the id of the userTimeZone.The default is "spincast_timezone"
- Specified by:
getCookieNameTimeZoneIdin interfaceSpincastConfig
-
getCookiesValidatorCookieName
Description copied from interface:SpincastConfigName of the Cookie to use to validate if cookies are enabled.The default is "spincast_cookies_enabled".
- Specified by:
getCookiesValidatorCookieNamein interfaceSpincastConfig
-
getSpincastModelRootVariableName
Description copied from interface:SpincastConfigName of the root variables reserved for Spincast in the response's model.- Specified by:
getSpincastModelRootVariableNamein interfaceSpincastConfig
-
getValidationElementDefaultName
Description copied from interface:SpincastConfigThe default name to use for the validation element that will be available on the response's model whenFormelements are added.- Specified by:
getValidationElementDefaultNamein interfaceSpincastConfig
-
getDictionaryEntryNotFoundBehavior
Description copied from interface:SpincastConfigIf 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:
getDictionaryEntryNotFoundBehaviorin interfaceSpincastConfig
-