public.javadoc.org.spincast.plugins.configpropsfile.SpincastConfigPropsFileBased.html Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of spincast-website Show documentation
                Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
                
            
SpincastConfigPropsFileBased (org.spincast:spincast-framework 0.9.21 API) 
org.spincast.plugins.configpropsfile
Class SpincastConfigPropsFileBased
- java.lang.Object
 
- 
- org.spincast.plugins.config.SpincastConfig
 
- 
- org.spincast.plugins.configpropsfile.SpincastConfigPropsFileBased
 
 
 
- 
- All Implemented Interfaces:
 
- ISpincastConfig, IFreeKeyConfig
 
public class SpincastConfigPropsFileBased
extends SpincastConfig
implements ISpincastConfig, IFreeKeyConfig
This configuration implementation will try to find a
 properties file to load the configurations.
 
- 
- 
Field Summary
Fields  
Modifier and Type 
Field and Description 
 
static String 
APP_PROPERTIES_KEY_ENVIRONMENT_IS_DEBUG  
 
static String 
APP_PROPERTIES_KEY_ENVIRONMENT_NAME  
 
static String 
APP_PROPERTIES_KEY_HTTP_SERVER_PORT  
 
static String 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_KEYPASS  
 
static String 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_PATH  
 
static String 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_STOREPASS  
 
static String 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_TYPE  
 
static String 
APP_PROPERTIES_KEY_HTTPS_SERVER_PORT  
 
static String 
APP_PROPERTIES_KEY_SERVER_HOST  
 
protected org.slf4j.Logger 
logger  
 
 
- 
Constructor Summary
Constructors  
Constructor and Description 
 
SpincastConfigPropsFileBased(ISpincastUtils spincastUtils,
                            String[] mainArgs,
                            ISpincastConfigPropsFileBasedConfig pluginConfig)
Constructor
 
 
 
- 
Method Summary
All Methods Instance Methods Concrete Methods  
Modifier and Type 
Method and Description 
 
protected Properties 
getAppProperties()
Here is the algorithm used to find the configuration file :
 
 1) If getSpecificAppPropertiesFilePath() is not null,
    we use it as the path.
 
 
String 
getConfig(String key)
Gets a String configuration and throws an exception if the
 specified key is not found.
 
 
protected Object 
getConfig(String key,
         Object defaultValue,
         boolean useDefaultValue)
Gets a configuration.
 
 
String 
getConfig(String key,
         String defaultValue)
Gets a String configuration and uses the specified default value if the
 key is not found.
 
 
Boolean 
getConfigBoolean(String key)
Gets a boolean configuration and throws an exception if the
 specified key is not found.
 
 
Boolean 
getConfigBoolean(String key,
                Boolean defaultValue)
Gets a boolean configuration and uses the specified default value if the
 key is not found.
 
 
Integer 
getConfigInteger(String key)
Gets a integer configuration and throws an exception if the
 specified key is not found.
 
 
Integer 
getConfigInteger(String key,
                Integer defaultValue)
Gets a integer configuration and uses the specified default value if the
 key is not found.
 
 
protected String 
getConfigKeyEnvironmentIsDebug()  
 
protected String 
getConfigKeyEnvironmentName()  
 
protected String 
getConfigKeyHttpServerPort()  
 
protected String 
getConfigKeyHttpsServerKeystoreKeyPass()  
 
protected String 
getConfigKeyHttpsServerKeystorePath()  
 
protected String 
getConfigKeyHttpsServerKeystoreStorePass()  
 
protected String 
getConfigKeyHttpsServerKeystoreType()  
 
protected String 
getConfigKeyHttpsServerPort()  
 
protected String 
getConfigKeyServerHost()  
 
String 
getEnvironmentName()
Returns the name of the environment.
 
 
protected String 
getFoundPropertiesFilePath()
The path to the acutally found .properties file.
 
 
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.
 
 
protected String[] 
getMainArgs()  
 
protected ISpincastConfigPropsFileBasedConfig 
getPluginConfig()  
 
String 
getServerHost()
The host/IP on which the server will listen to.
 
 
protected String 
getSpecificAppPropertiesFilePath()  
 
protected ISpincastUtils 
getSpincastUtils()  
 
boolean 
isDebugEnabled()
Let this to true on development environment,
 where errors can be publicly displayed, where cache can
 be disabled, etc.
 
 
protected String 
lookForPropsFileSpecificPath()
Look for a specific .properties file.
 
 
- 
Methods inherited from class org.spincast.plugins.config.SpincastConfig
getContentTypesToSkipGziping, getDefaultLocale, getRouteForwardingMaxNumber, getServerMaxRequestBodyBytes, getSpincastWritableDir, isRoutesCaseSensitive 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.spincast.core.config.ISpincastConfig
getContentTypesToSkipGziping, getDefaultLocale, getRouteForwardingMaxNumber, getServerMaxRequestBodyBytes, getSpincastWritableDir, isRoutesCaseSensitive 
 
 
- 
- 
Field Detail
- 
logger
protected final org.slf4j.Logger logger
 
- 
APP_PROPERTIES_KEY_ENVIRONMENT_NAME
public static final String APP_PROPERTIES_KEY_ENVIRONMENT_NAME
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_ENVIRONMENT_IS_DEBUG
public static final String APP_PROPERTIES_KEY_ENVIRONMENT_IS_DEBUG
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_SERVER_HOST
public static final String APP_PROPERTIES_KEY_SERVER_HOST
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTP_SERVER_PORT
public static final String APP_PROPERTIES_KEY_HTTP_SERVER_PORT
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTPS_SERVER_PORT
public static final String APP_PROPERTIES_KEY_HTTPS_SERVER_PORT
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_PATH
public static final String APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_PATH
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_TYPE
public static final String APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_TYPE
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_STOREPASS
public static final String APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_STOREPASS
- See Also:
 
- Constant Field Values
 
 
- 
APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_KEYPASS
public static final String APP_PROPERTIES_KEY_HTTPS_SERVER_KEYSTORE_KEYPASS
- See Also:
 
- Constant Field Values
 
 
 
- 
Constructor Detail
- 
SpincastConfigPropsFileBased
@Inject
public SpincastConfigPropsFileBased(ISpincastUtils spincastUtils,
                                             @Nullable
                                             String[] mainArgs,
                                             ISpincastConfigPropsFileBasedConfig pluginConfig)
Constructor
 
 
- 
Method Detail
- 
getPluginConfig
protected ISpincastConfigPropsFileBasedConfig getPluginConfig()
 
- 
getSpincastUtils
protected ISpincastUtils getSpincastUtils()
 
- 
getMainArgs
protected String[] getMainArgs()
 
- 
getSpecificAppPropertiesFilePath
protected String getSpecificAppPropertiesFilePath()
 
- 
lookForPropsFileSpecificPath
protected String lookForPropsFileSpecificPath()
Look for a specific .properties file.
 
 You can override this to implement your own strategy
 to locate the .properties file to use.
 
- 
getFoundPropertiesFilePath
protected String getFoundPropertiesFilePath()
The path to the acutally found .properties file.
- Returns:
 
- the path of the file or 
null if
 none was found. 
 
- 
getConfigKeyEnvironmentName
protected String getConfigKeyEnvironmentName()
 
- 
getConfigKeyEnvironmentIsDebug
protected String getConfigKeyEnvironmentIsDebug()
 
- 
getConfigKeyServerHost
protected String getConfigKeyServerHost()
 
- 
getConfigKeyHttpServerPort
protected String getConfigKeyHttpServerPort()
 
- 
getConfigKeyHttpsServerPort
protected String getConfigKeyHttpsServerPort()
 
- 
getConfigKeyHttpsServerKeystorePath
protected String getConfigKeyHttpsServerKeystorePath()
 
- 
getConfigKeyHttpsServerKeystoreType
protected String getConfigKeyHttpsServerKeystoreType()
 
- 
getConfigKeyHttpsServerKeystoreStorePass
protected String getConfigKeyHttpsServerKeystoreStorePass()
 
- 
getConfigKeyHttpsServerKeystoreKeyPass
protected String getConfigKeyHttpsServerKeystoreKeyPass()
 
- 
getAppProperties
protected Properties getAppProperties()
Here is the algorithm used to find the configuration file :
 
 1) If getSpecificAppPropertiesFilePath() is not null,
    we use it as the path.
    
 2) Otherwise, we try to find the configuration file next to the ".jar"
    itself.
    
 3) It we didn't found the configuration file next to the ".jar" file,
    or if there is no .jar file (the code is running from an IDE, for example),
    then we fallback to the default configurations which are defined in the
    SpincastConfig base class.
 
- 
getConfig
public String getConfig(String key)
Gets a String configuration and throws an exception if the
 specified key is not found.
- Specified by:
 
getConfig in interface IFreeKeyConfig 
 
- 
getConfig
public String getConfig(String key,
                        String defaultValue)
Gets a String configuration and uses the specified default value if the
 key is not found.
- Specified by:
 
getConfig in interface IFreeKeyConfig 
 
- 
getConfigBoolean
public Boolean getConfigBoolean(String key)
Gets a boolean configuration and throws an exception if the
 specified key is not found.
- Specified by:
 
getConfigBoolean in interface IFreeKeyConfig 
 
- 
getConfigBoolean
public Boolean getConfigBoolean(String key,
                                Boolean defaultValue)
Gets a boolean configuration and uses the specified default value if the
 key is not found.
- Specified by:
 
getConfigBoolean in interface IFreeKeyConfig 
 
- 
getConfigInteger
public Integer getConfigInteger(String key)
Gets a integer configuration and throws an exception if the
 specified key is not found.
- Specified by:
 
getConfigInteger in interface IFreeKeyConfig 
 
- 
getConfigInteger
public Integer getConfigInteger(String key,
                                Integer defaultValue)
Gets a integer configuration and uses the specified default value if the
 key is not found.
- Specified by:
 
getConfigInteger in interface IFreeKeyConfig 
 
- 
getConfig
protected Object getConfig(String key,
                           Object defaultValue,
                           boolean useDefaultValue)
Gets a configuration.
 
 If 'useDefaultValue' is false, throws an exception if the key is not found.
 Otherwise, returns the 'defaultValue'.
 
- 
getEnvironmentName
public String getEnvironmentName()
Description copied from interface: ISpincastConfig
Returns the name of the environment.
 
 The default value is local.
- Specified by:
 
getEnvironmentName in interface ISpincastConfig 
- Overrides:
 
getEnvironmentName in class SpincastConfig 
- Returns:
 
- the name of the environment
 
 
- 
isDebugEnabled
public boolean isDebugEnabled()
Description copied from interface: ISpincastConfig
Let this to true on development environment,
 where errors can be publicly displayed, where cache can
 be disabled, etc. In production set it to false
 
 The default value is true.
- Specified by:
 
isDebugEnabled in interface ISpincastConfig 
- Overrides:
 
isDebugEnabled in class SpincastConfig 
- Returns:
 
true if debug mode is enabled. 
 
- 
getServerHost
public String getServerHost()
Description copied from interface: ISpincastConfig
The host/IP on which the server will listen to.
 
 The default value is 0.0.0.0.
- Specified by:
 
getServerHost in interface ISpincastConfig 
- Overrides:
 
getServerHost in class SpincastConfig 
- Returns:
 
- the host/IP
 
 
- 
getHttpServerPort
public int getHttpServerPort()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpServerPort in class SpincastConfig 
- Returns:
 
- the HTTP port
 
 
- 
getHttpsServerPort
public int getHttpsServerPort()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpsServerPort in class SpincastConfig 
- Returns:
 
- the HTTPS port
 
 
- 
getHttpsKeyStorePath
public String getHttpsKeyStorePath()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpsKeyStorePath in class SpincastConfig 
- Returns:
 
- the path to the 
KeyStore 
 
- 
getHttpsKeyStoreType
public String getHttpsKeyStoreType()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpsKeyStoreType in class SpincastConfig 
- Returns:
 
- the type of the 
KeyStore 
 
- 
getHttpsKeyStoreStorePass
public String getHttpsKeyStoreStorePass()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpsKeyStoreStorePass in class SpincastConfig 
- Returns:
 
- the "storepass" of the 
KeyStore 
 
- 
getHttpsKeyStoreKeypass
public String getHttpsKeyStoreKeypass()
Description copied from interface: ISpincastConfig
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 ISpincastConfig 
- Overrides:
 
getHttpsKeyStoreKeypass in class SpincastConfig 
- Returns:
 
- the "keypass" of the 
KeyStore 
 
 
 
Copyright © 2016. All rights reserved.
    © 2015 - 2025 Weber Informatics LLC | Privacy Policy