Class ConfigPropertiesCascadeBase
java.lang.Object
edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase
- Direct Known Subclasses:
GrouperCacheConfig,GrouperClientConfig,GrouperConfig,GrouperHibernateConfigClient,GrouperLoaderConfig,GrouperUiApiTextConfig,GrouperUiConfigInApi,GrouperWsConfigInApi,SubjectConfig
Base class for a cascaded config. Extend this class to have a config
based on a certain file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static enumconfig file type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanassertPropertyValueBoolean(String key, boolean required) make sure a value is boolean in propertiesbooleanassertPropertyValueClass(String key, Class<?> classType, boolean required) make sure a property is a class of a certain typebooleanmake sure a value exists in propertiesstatic voidassign that things are initted, so database config is ok to use and errors should be thrownstatic voidabstract voidif there are things that are calculated, clear them out (e.g. if an override is set)static voidbooleanconfigExistsNotInBaseOrDatabase(String propertyName) see if property name exists not in base or database (config file or db or override)booleancontainsKey(String key) if the key is there, whether or not the value is blankprotected booleanprotected Class<?>if its ok to put the config file in the same directory as a jar, then return a class in the jar hereprotected abstract Stringconfig key of the hierarchy valueprotected abstract Stringget the main config classpath, e.g. grouper.propertiesprotected abstract Stringget the example config classpath, e.g. grouper.example.propertiesprotected abstract Stringconfig key of the time in seconds to check configprotected Integerwhen we build the config object, get the time to check config in secondsbooleanhasExpressionLanguage(String propertyName) protected Propertieshelp subclasses manipulate properties.get the underlying properties for the config uistatic booleanis in databaseprotected static voidmake sure LOG is there, after things are initializedprotected static voidmake sure LOG is there, after things are initializedprotected booleanget the properties object for this config fileprotected static PropertiespropertiesFromResourceName(String resourceName, boolean exceptionIfNotExist) read properties from a resource, dont modify the properties returned since they are cachedprotected static PropertiespropertiesFromResourceName(String resourceName, boolean exceptionIfNotExist, Class<?> classInSiblingJar) read properties from a resource, dont modify the properties returned since they are cachedprotected PropertiespropertiesHelper(boolean setValues) get the properties object for this config filepropertiesMap(Pattern pattern) find all keys/values with a certain pattern in a properties file.override map for properties for testingoverride map for properties in thread local to be used in a web server or the like, based on property class this is static since the properties class can get reloaded, but these shouldntpropertyConfigIds(Pattern pattern) find all config ids that match a pattern and return the configId (first match)get a boolean and validate from grouper.client.properties or null if not therebooleanpropertyValueBoolean(String key, boolean defaultValue) get a boolean and validate from grouper.client.propertiesprotected BooleanpropertyValueBoolean(String key, Boolean defaultValue, boolean required) get a boolean and validate from the config filebooleanget a boolean and validate from grouper.client.propertiespropertyValueInt(String key) get a boolean and validate from grouper.client.propertiesintpropertyValueInt(String key, int defaultValue) get a boolean and validate from grouper.client.propertiesprotected IntegerpropertyValueInt(String key, Integer defaultValue, boolean required) get an int and validate from the config fileintget a boolean and validate from grouper.client.propertiesget the property value as a string or null if not therepropertyValueString(String key, String defaultValue) get the property value as a stringprotected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResultpropertyValueString(String key, String defaultValue, boolean required) get the property value as a stringprotected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResultpropertyValueStringHelper(String key, String defaultValue, boolean required) get the property value as a stringget the property value as a stringrawExpressionLanguage(String propertyName) protected static <T extends ConfigPropertiesCascadeBase>
TretrieveConfig(Class<T> configClass) retrieve a config from the config file or from cacheprotected ConfigPropertiesCascadeBasesee if there is one in cache, if so, use it, if not, get from config filesprotected ConfigPropertiesCascadeBaseget the config object from config filesretrieveFromConfigFiles(boolean includeBaseConfig) get the config object from config files.protected static StringsubstituteCommonVars(String string) substitute common vars like $space$ and $newline$protected voidyou can refer to other properties with $$propertyName$$protected StringsubstituteLocalReferencesOneField(Object thePropertiesOrConfigPropertiesCascadeBase, String value) protected StringsubstituteLocalReferencesOneSubstitution(Object thePropertiesOrConfigPropertiesCascadeBase, String value) static StringsubstituteUnicode(String value)
-
Constructor Details
-
ConfigPropertiesCascadeBase
public ConfigPropertiesCascadeBase()
-
-
Method Details
-
assignInitted
public static void assignInitted()assign that things are initted, so database config is ok to use and errors should be thrown -
internalProperties
help subclasses manipulate properties. note, this is only for subclasses...- Returns:
- properties
-
retrieveConfig
retrieve a config from the config file or from cache- Type Parameters:
T- class which is the return type of config class- Parameters:
configClass-- Returns:
- the config object never null
-
getClassInSiblingJar
if its ok to put the config file in the same directory as a jar, then return a class in the jar here- Returns:
- the class or null if not available
-
getSecondsToCheckConfigKey
config key of the time in seconds to check config. -1 means dont check again- Returns:
- config key
-
clearCache
public static void clearCache() -
clearCacheThisOnly
public static void clearCacheThisOnly() -
clearCachedCalculatedValues
public abstract void clearCachedCalculatedValues()if there are things that are calculated, clear them out (e.g. if an override is set) -
propertiesThreadLocalOverrideMap
override map for properties in thread local to be used in a web server or the like, based on property class this is static since the properties class can get reloaded, but these shouldnt- Returns:
- the override map
-
propertyNames
- Returns:
- the set of names
-
propertiesOverrideMap
override map for properties for testing- Returns:
- the override map
-
properties
get the properties object for this config file- Returns:
- the properties
-
propertiesHelper
get the properties object for this config file- Parameters:
setValues- if we should set the values for the properties. if not, the values might not be correct, but this will be more performant depending on how many EL properties there are- Returns:
- the properties
-
substituteLocalReferencesAndUnicode
you can refer to other properties with $$propertyName$$- Parameters:
result-
-
propertyValueStringRequired
get the property value as a string- Parameters:
key-- Returns:
- the property value
-
propertyValueString
get the property value as a string- Parameters:
key-defaultValue-- Returns:
- the property value
-
propertyValueString
get the property value as a string or null if not there- Parameters:
key-- Returns:
- the property value
-
propertyValueString
protected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResult propertyValueString(String key, String defaultValue, boolean required) get the property value as a string- Parameters:
key-defaultValue-required- true if required, if doesnt exist, throw exception- Returns:
- the property value
-
propertyValueStringHelper
protected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResult propertyValueStringHelper(String key, String defaultValue, boolean required) get the property value as a string- Parameters:
key-defaultValue-required- true if required, if doesnt exist, throw exception- Returns:
- the property value
-
substituteCommonVars
substitute common vars like $space$ and $newline$- Parameters:
string-- Returns:
- the string
-
getTimeToCheckConfigSeconds
when we build the config object, get the time to check config in seconds- Returns:
- the time to check config foe changes (in seconds)
-
isInDatabase
public static boolean isInDatabase()is in database- Returns:
- if in database
-
retrieveFromConfigFiles
get the config object from config files- Returns:
- the config object
-
retrieveFromConfigFiles
get the config object from config files. You should call the method that gets these from cache, probably shouldnt call this method except for config in UI reasons- Parameters:
includeBaseConfig- true if we include base config- Returns:
- the config object
-
internalRetrieveConfigFiles
get the underlying properties for the config ui- Returns:
- the config files
-
logInfo
make sure LOG is there, after things are initialized- Parameters:
logMessage-t-
-
logError
make sure LOG is there, after things are initialized- Parameters:
logMessage-t-
-
retrieveFromConfigFileOrCache
see if there is one in cache, if so, use it, if not, get from config files- Returns:
- the config from file or cache
-
needToCheckIfFilesNeedReloading
protected boolean needToCheckIfFilesNeedReloading()- Returns:
- true if need to reload this config, false if not
-
filesNeedReloadingBasedOnContents
protected boolean filesNeedReloadingBasedOnContents()- Returns:
- true if need to reload this config, false if not
-
getMainConfigFileName
- Returns:
- e.g. grouper.properties
-
getMainConfigClasspath
get the main config classpath, e.g. grouper.properties- Returns:
- the classpath of the main config file
-
getHierarchyConfigKey
config key of the hierarchy value- Returns:
- the classpath of the main config file
-
getMainExampleConfigClasspath
get the example config classpath, e.g. grouper.example.properties- Returns:
- the classpath of the example config file
-
propertyValueBoolean
get a boolean and validate from grouper.client.properties- Parameters:
key-defaultValue-- Returns:
- the string
-
containsKey
if the key is there, whether or not the value is blank- Parameters:
key-- Returns:
- true or false
-
propertyValueBoolean
get a boolean and validate from grouper.client.properties or null if not there- Parameters:
key-- Returns:
- the boolean or null
-
propertyValueBoolean
get a boolean and validate from the config file- Parameters:
key-defaultValue-required-- Returns:
- the string
-
propertyValueInt
get an int and validate from the config file- Parameters:
key-defaultValue-required-- Returns:
- the string
-
propertyValueBooleanRequired
get a boolean and validate from grouper.client.properties- Parameters:
key-- Returns:
- the string
-
propertyValueIntRequired
get a boolean and validate from grouper.client.properties- Parameters:
key-- Returns:
- the string
-
propertyValueInt
get a boolean and validate from grouper.client.properties- Parameters:
key-defaultValue-- Returns:
- the string
-
propertyValueInt
get a boolean and validate from grouper.client.properties- Parameters:
key-- Returns:
- the int or null if there
-
propertiesFromResourceName
protected static Properties propertiesFromResourceName(String resourceName, boolean exceptionIfNotExist) read properties from a resource, dont modify the properties returned since they are cached- Parameters:
resourceName-exceptionIfNotExist-- Returns:
- the properties or null if not exist
-
propertiesFromResourceName
protected static Properties propertiesFromResourceName(String resourceName, boolean exceptionIfNotExist, Class<?> classInSiblingJar) read properties from a resource, dont modify the properties returned since they are cached- Parameters:
resourceName-exceptionIfNotExist-classInSiblingJar- if also looking for config next to a jar- Returns:
- the properties or null if not exist
-
assertPropertyValueRequired
make sure a value exists in properties- Parameters:
key-- Returns:
- true if ok, false if not
-
assertPropertyValueBoolean
make sure a value is boolean in properties- Parameters:
key-required-- Returns:
- true if ok, false if not
-
assertPropertyValueClass
make sure a property is a class of a certain type- Parameters:
key-classType-required-- Returns:
- true if ok
-
propertiesMap
find all keys/values with a certain pattern in a properties file. return the keys. if none, will return the empty set, not null set- Parameters:
pattern-- Returns:
- the keys. if none, will return the empty set, not null set
-
propertyConfigIds
find all config ids that match a pattern and return the configId (first match)- Parameters:
pattern- e.g. "^grouperOsgiPlugin\\.([^.]+)\\.jarName$- Returns:
- the config ids. if none, will return the empty set, not null set
-
substituteLocalReferencesOneField
protected String substituteLocalReferencesOneField(Object thePropertiesOrConfigPropertiesCascadeBase, String value) - Parameters:
thePropertiesOrConfigPropertiesCascadeBase- to get data fromvalue-- Returns:
- the subsituted string
-
substituteUnicode
-
substituteLocalReferencesOneSubstitution
protected String substituteLocalReferencesOneSubstitution(Object thePropertiesOrConfigPropertiesCascadeBase, String value) - Parameters:
thePropertiesOrConfigPropertiesCascadeBase- to get data from. either Properties or ConfigPropertiesCascadeBAsevalue-- Returns:
- the subsituted string
-
hasExpressionLanguage
-
rawExpressionLanguage
-
configExistsNotInBaseOrDatabase
see if property name exists not in base or database (config file or db or override)- Parameters:
propertyName-- Returns:
- if configured other than base
-