Class PropertyUtil
java.lang.Object
org.apache.derby.iapi.services.property.PropertyUtil
There are 5 property objects within a JBMS system.
1) JVM - JVM set - those in System.getProperties
2) APP - Application set - derby.properties file
3) SRV - Persistent Service set - Those stored in service.properties
4) TRAN - Persistent Transactional set - Those stored via the AccessManager interface
5) BOOT - Set by a boot method (rare)
This class has a set of static methods to find a property using a consistent search order
from the above set.
getSystem*() methods use the search order.
getService* methods use the search order
getSystem*() methods use the search order.
- JVM
- APP
getService* methods use the search order
- JVM
- TRAN
- SRV
- APP
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Property is not set.private static final String[]
static final int
Property is set in APPLICATION (derby.properties) setstatic final int
Property is set in DATABASE setstatic final int
Property is set in JVM set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
booleanProperty
(String p, Serializable v, boolean defaultValue) Parse and validate and return a boolean property value.static boolean
existsBuiltinUser
(PersistentSet set, String username) Returntrue
ifusername
is defined as a built-in user i.e. there exists a propertyderby.user.
<userid> in the database (or, possibly, in system properties if not forbidden byderby.database.propertiesOnly
).static String
getDatabaseProperty
(PersistentSet set, String key) Get a property only looking in the Persistent Transactional (database) set.private static ModuleFactory
Privileged Monitor lookup.private static ModuleFactory
Privileged Monitor lookup.static Serializable
getPropertyFromSet
(boolean dbOnly, Dictionary set, String key) static String
getPropertyFromSet
(boolean dbOnly, Properties set, String key) static Serializable
getPropertyFromSet
(Dictionary set, String key) static String
getPropertyFromSet
(Properties set, String key) Get a property from the passed in set.static boolean
getServiceBoolean
(PersistentSet set, String key, boolean defValue) Get a service wide property as a boolean.static int
getServiceInt
(PersistentSet set, String key, int min, int max, int defaultValue) Get a service wide property as a int.static int
getServiceInt
(PersistentSet set, Properties props, String key, int min, int max, int defaultValue) Get a service wide property as a int.static String
getServiceProperty
(PersistentSet set, String key) Find a service wide property.static String
getServiceProperty
(PersistentSet set, String key, String defaultValue) Find a service wide property with a default.static String[]
Get the list of properties which are normally stored in service.propertiesstatic boolean
getSystemBoolean
(String key) Get a system wide property as a boolean.static boolean
getSystemBoolean
(String key, boolean defaultValue) Get a system wide property as a boolean.static int
getSystemInt
(String key, int defaultValue) Get a system wide property as a int.static int
getSystemInt
(String key, int min, int max, int defaultValue) s Get a system wide property as a int.static String
getSystemProperty
(String key) Find a system wide property.static String
getSystemProperty
(String key, String defaultValue) Find a system wide property with a default.static int
Parse an string as an int based property value.static int
intPropertyValue
(String p, Serializable v, int minValue, int maxValue, int defaultValue) Parse, validate and return an integer property value.static boolean
isDBOnly
(Dictionary set) static boolean
isDBOnly
(Properties set) static boolean
isServiceProperty
(String key) Return true iff the key is the name of a database property that is stored in services.properties.static boolean
localNativeAuthenticationEnabled
(Properties properties) Return true if the passed-in properties specify NATIVE authentication using LOCAL credentials.private static boolean
nativeAuthenticationEnabled
(String authenticationProvider) Return true if NATIVE authentication is turned on for the passed-in value of Property.AUTHENTICATION_PROVIDER_PARAMETER.static boolean
nativeAuthenticationEnabled
(Properties properties) Return true if NATIVE authentication has been enabled in the passed-in properties.private static boolean
propertiesContainsBuiltinUser
(Properties props, String username) private static boolean
systemPropertiesExistsBuiltinUser
(String username) Return true if username is defined as a system property i.e. there exists a propertyderby.user.
<userid> in the system properties.(package private) static int
whereSet
(String key, Dictionary set)
-
Field Details
-
servicePropertyList
-
SET_IN_JVM
public static final int SET_IN_JVMProperty is set in JVM set- See Also:
-
SET_IN_DATABASE
public static final int SET_IN_DATABASEProperty is set in DATABASE set- See Also:
-
SET_IN_APPLICATION
public static final int SET_IN_APPLICATIONProperty is set in APPLICATION (derby.properties) set- See Also:
-
NOT_SET
public static final int NOT_SETProperty is not set.- See Also:
-
-
Constructor Details
-
PropertyUtil
public PropertyUtil()
-
-
Method Details
-
whereSet
-
isDBOnly
-
isDBOnly
-
getServicePropertyList
Get the list of properties which are normally stored in service.properties -
getSystemProperty
Find a system wide property.- Returns:
- the value of the property or null if it does not exist.
- See Also:
-
getSystemProperty
Find a system wide property with a default. Search order is- JVM property
- derby.properties
This method can be used by a system that is not running Derby, just to maintain the same lookup logic and security manager concerns for finding derby.properties and reading system properties.
- Returns:
- the value of the property or defaultValue if it does not exist.
-
getPropertyFromSet
Get a property from the passed in set. The passed in set is either:- The properties object passed into ModuleControl.boot() after the database has been booted. This set will be a DoubleProperties object with the per-database transaction set as the read set and the service.properties as the write set.
- The Dictionary set returned/passed in by a method of BasicService.Properties.
This method uses the same search order as the getService() calls. -
getPropertyFromSet
-
getPropertyFromSet
-
getPropertyFromSet
-
getDatabaseProperty
Get a property only looking in the Persistent Transactional (database) set.- Throws:
StandardException
- Standard Derby error handling.
-
getServiceProperty
public static String getServiceProperty(PersistentSet set, String key, String defaultValue) throws StandardException Find a service wide property with a default. Search order is The service is the persistent service associated with the current context stack.- Returns:
- the value of the property or defaultValue if it does not exist.
- Throws:
StandardException
- Standard Derby error handling.
-
getServiceProperty
Find a service wide property. The service is the persistent service associated with the current context stack.- Returns:
- the value of the property or null if it does not exist.
- Throws:
StandardException
- Standard Derby error handling.
-
getSystemBoolean
Get a system wide property as a boolean.- Parameters:
key
- The name of the system property- Returns:
- true of the property is set to 'true, TRUE', false otherwise
-
getSystemBoolean
Get a system wide property as a boolean.- Parameters:
key
- The name of the system propertydefaultValue
- The value to use if the property has not been set- Returns:
- return defaultValue if the property is not set, returns true if the property is set to 'true, TRUE', returns false otherwise.
-
getServiceBoolean
public static boolean getServiceBoolean(PersistentSet set, String key, boolean defValue) throws StandardException Get a service wide property as a boolean.- Returns:
- true of the property is set to 'true, TRUE', false otherwise
- Throws:
StandardException
- Standard Derby error handling.
-
getSystemInt
s Get a system wide property as a int.- Returns:
- value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.
-
getServiceInt
public static int getServiceInt(PersistentSet set, String key, int min, int max, int defaultValue) throws StandardException Get a service wide property as a int.- Returns:
- value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.
- Throws:
StandardException
- Standard Derby error handling.
-
getServiceInt
public static int getServiceInt(PersistentSet set, Properties props, String key, int min, int max, int defaultValue) throws StandardException Get a service wide property as a int. The passed in Properties set overrides any system, applcation or per-database properties.- Returns:
- value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.
- Throws:
StandardException
- Standard Derby error handling.
-
getSystemInt
Get a system wide property as a int.- Returns:
- value of the property if, defaultValue if it is not set or set to a non-integer value.
-
handleInt
Parse an string as an int based property value. -
booleanProperty
public static boolean booleanProperty(String p, Serializable v, boolean defaultValue) throws StandardException Parse and validate and return a boolean property value. If the value is invalid raise an exception.The following are valid property values.
- null - returns defaultValue
- "true" - returns true (in any case without the quotes)
- "false" - return true (in any case without the quotes)
- Throws:
StandardException
- Oops
-
intPropertyValue
public static int intPropertyValue(String p, Serializable v, int minValue, int maxValue, int defaultValue) throws StandardException Parse, validate and return an integer property value. If the value is invalid raise an exception. If the value passed in is null return a default value.- Throws:
StandardException
- Oops
-
isServiceProperty
Return true iff the key is the name of a database property that is stored in services.properties. -
existsBuiltinUser
public static boolean existsBuiltinUser(PersistentSet set, String username) throws StandardException Returntrue
ifusername
is defined as a built-in user i.e. there exists a propertyderby.user.
<userid> in the database (or, possibly, in system properties if not forbidden byderby.database.propertiesOnly
). Note that <userid> found in a property will be normalized to case normal form before comparison is performed against username, which is presumed normalized already.- Parameters:
set
- object which implements PersistentSet interface (TransactionController)username
- Normalized authorization identifier- Returns:
true
if match found- Throws:
StandardException
-
nativeAuthenticationEnabled
Return true if NATIVE authentication has been enabled in the passed-in properties. -
nativeAuthenticationEnabled
Return true if NATIVE authentication is turned on for the passed-in value of Property.AUTHENTICATION_PROVIDER_PARAMETER. -
localNativeAuthenticationEnabled
Return true if the passed-in properties specify NATIVE authentication using LOCAL credentials. -
systemPropertiesExistsBuiltinUser
Return true if username is defined as a system property i.e. there exists a propertyderby.user.
<userid> in the system properties. Note that <userid> will be normalized to case normal form before comparison is performed against username, which is presumed normalized already.- Parameters:
username
- Normalized authorization identifier- Returns:
true
if match found
-
propertiesContainsBuiltinUser
-
getMonitor
Privileged Monitor lookup. Must be private so that user code can't call this entry point. -
getMonitorLite
Privileged Monitor lookup. Must be private so that user code can't call this entry point.
-