Top Description Fields Constructors Methods
org.apache.derby.iapi.services.property

public Class PropertyUtil

extends Object
Class Inheritance
Imports
org.apache.derby.shared.common.reference.Property, .SQLState, .Attribute, .EngineType, org.apache.derby.shared.common.util.ArrayUtil, org.apache.derby.iapi.services.monitor.Monitor, .ModuleFactory, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.util.StringUtil, .IdUtil, java.util.Properties, .Dictionary, .Enumeration, java.io.Serializable

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.
  1. JVM
  2. APP

getService* methods use the search order
  1. JVM
  2. TRAN
  3. SRV
  4. APP

Field Summary

Modifier and TypeField and Description
public static final int
NOT_SET

Property is not set.

private static final String[]
public static final int
SET_IN_APPLICATION

Property is set in APPLICATION (derby.properties) set

public static final int
SET_IN_DATABASE

Property is set in DATABASE set

public static final int
SET_IN_JVM

Property is set in JVM set

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

The final value decided on
booleanProperty
(String
The property name
p
,
Serializable
The desired value
v
,
boolean
The default value to use
defaultValue
)

Parse and validate and return a boolean property value.

public static boolean

Returns:

true if match found
existsBuiltinUser
(PersistentSet
object which implements PersistentSet interface (TransactionController)
set
,
String
Normalized authorization identifier
username
)

Return true if username is defined as a built-in user i.e. there exists a property derby.user.

public static String

Returns:

the value bound to the key
getDatabaseProperty
(PersistentSet
The property set to inspect
set
,
String
The key to lookup
key
)

Get a property only looking in the Persistent Transactional (database) set.

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

private static ModuleFactory
getMonitorLite()

Must be private so that user code can't call this entry point.

public static String

Returns:

the value bound to the key
getPropertyFromSet
(Properties
The property set to inspect
set
,
String
The key to lookup
key
)

Get a property from the passed in set.

public static Serializable
public static Serializable
getPropertyFromSet(boolean dbOnly, Dictionary<K, V> set, String key)

public static String
getPropertyFromSet(boolean dbOnly, Properties set, String key)

public static boolean

Returns:

true of the property is set to 'true, TRUE', false otherwise
getServiceBoolean
(PersistentSet
The property set to inspect
set
,
String
The key to lookup
key
,
boolean
The default value to use
defValue
)

Get a service wide property as a boolean.

public static 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
(PersistentSet
The property set
set
,
String
The key to lookup
key
,
int
The min acceptable value
min
,
int
The max acceptable value
max
,
int
The value to use if the key has no match
defaultValue
)

Get a service wide property as a int.

public static 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
(PersistentSet
The target property set
set
,
Properties
The properties
props
,
String
The key to lookup
key
,
int
The min acceptable value
min
,
int
The max acceptable value
max
,
int
The value to use if the key has no match
defaultValue
)

Get a service wide property as a int.

public static String

Returns:

the value of the property or defaultValue if it does not exist.
getServiceProperty
(PersistentSet
The property set to inspect
set
,
String
The key to lookup
key
,
String
The default value to use
defaultValue
)

Find a service wide property with a default.

public static String

Returns:

the value of the property or null if it does not exist.
getServiceProperty
(PersistentSet
The property set to inspect
set
,
String
The key to lookup
key
)

Find a service wide property.

public static String[]

Returns:

the list of properties which are normally stored in service.propertie
getServicePropertyList
()

Get the list of properties which are normally stored in service.properties

public static boolean

Returns:

true of the property is set to 'true, TRUE', false otherwise
getSystemBoolean
(String
The name of the system property
key
)

Get a system wide property as a boolean.

public static boolean

Returns:

return defaultValue if the property is not set, returns true if the property is set to 'true, TRUE', returns false otherwise.
getSystemBoolean
(String
The name of the system property
key
,
boolean
The value to use if the property has not been set
defaultValue
)

Get a system wide property as a boolean.

public static 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.
getSystemInt
(String
The key to lookup
key
,
int
The min acceptable value
min
,
int
The max acceptable value
max
,
int
The value to use if the key has no match
defaultValue
)

s Get a system wide property as a int.

public static int

Returns:

value of the property if, defaultValue if it is not set or set to a non-integer value.
getSystemInt
(String
The key to lookup
key
,
int
The value to use if the key has no match
defaultValue
)

Get a system wide property as a int.

public static String

Returns:

the value of the property or null if it does not exist.
getSystemProperty
(String
The key to lookup
key
)

Find a system wide property.

public static String

Returns:

the value of the property or defaultValue if it does not exist.
getSystemProperty
(String
The propertykey
key
,
String
A default value
defaultValue
)

Find a system wide property with a default.

public static int

Returns:

the final value
handleInt
(String
The string value to be parsed as an int
value
,
int
The minimum legal value
min
,
int
The maximum legal value
max
,
int
The defaultValue to set
defaultValue
)

Parse an string as an int based property value.

public static int

Returns:

The final value decided on
intPropertyValue
(String
The property name
p
,
Serializable
The desired value
v
,
int
The minimum legal value
minValue
,
int
The maximum legal value
maxValue
,
int
The default value to use
defaultValue
)

Parse, validate and return an integer property value.

public static boolean
isDBOnly(Dictionary<K, V> set)

public static boolean
public static boolean

Returns:

true if that property is stored in service.properties
isServiceProperty
(String
The name of a property
key
)

Return true iff the key is the name of a database property that is stored in services.properties.

public static boolean

Returns:

true if the passed-in properties specify NATIVE authentication using LOCAL credentials
localNativeAuthenticationEnabled
(Properties
A set of properties
properties
)

Return true if the passed-in properties specify NATIVE authentication using LOCAL credentials.

public static boolean

Returns:

true if NATIVE authentication has been enabled in the passed-in properties
nativeAuthenticationEnabled
(Properties
A set of properties
properties
)

Return true if NATIVE authentication has been enabled in the passed-in properties.

private static boolean

Returns:

true if NATIVE authentication is turned in that spec
nativeAuthenticationEnabled
(String
An authentication service spec
authenticationProvider
)

Return true if NATIVE authentication is turned on for the passed-in value of Property.AUTHENTICATION_PROVIDER_PARAMETER.

private static boolean
private static boolean

Returns:

true if match found
systemPropertiesExistsBuiltinUser
(String
Normalized authorization identifier
username
)

Return true if username is defined as a system property i.e. there exists a property derby.user.

pack-priv static int
whereSet(String key, Dictionary<K, V> set)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NOT_SETback to summary
public static final int NOT_SET

Property is not set.

servicePropertyListback to summary
private static final String[] servicePropertyList
SET_IN_APPLICATIONback to summary
public static final int SET_IN_APPLICATION

Property is set in APPLICATION (derby.properties) set

SET_IN_DATABASEback to summary
public static final int SET_IN_DATABASE

Property is set in DATABASE set

SET_IN_JVMback to summary
public static final int SET_IN_JVM

Property is set in JVM set

Constructor Detail

PropertyUtilback to summary
public PropertyUtil()

Method Detail

booleanPropertyback to summary
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)
Parameters
p:String

The property name

v:Serializable

The desired value

defaultValue:boolean

The default value to use

Returns:boolean

The final value decided on

Exceptions
StandardException:
Oops
existsBuiltinUserback to summary
public static boolean existsBuiltinUser(PersistentSet set, String username) throws StandardException

Return true if username is defined as a built-in user i.e. there exists a property derby.user.<userid> in the database (or, possibly, in system properties if not forbidden by derby.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:PersistentSet

object which implements PersistentSet interface (TransactionController)

username:String

Normalized authorization identifier

Returns:boolean

true if match found

Exceptions
StandardException:
on error
getDatabasePropertyback to summary
public static String getDatabaseProperty(PersistentSet set, String key) throws StandardException

Get a property only looking in the Persistent Transactional (database) set.

Parameters
set:PersistentSet

The property set to inspect

key:String

The key to lookup

Returns:String

the value bound to the key

Exceptions
StandardException:
Standard Derby error handling.
getMonitorback to summary
private static ModuleFactory getMonitor()

Must be private so that user code can't call this entry point.

getMonitorLiteback to summary
private static ModuleFactory getMonitorLite()

Must be private so that user code can't call this entry point.

getPropertyFromSetback to summary
public static String getPropertyFromSet(Properties set, String key)

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.
Parameters
set:Properties

The property set to inspect

key:String

The key to lookup

Returns:String

the value bound to the key

getPropertyFromSetback to summary
public static Serializable getPropertyFromSet(Dictionary<K, V> set, String key)
getPropertyFromSetback to summary
public static Serializable getPropertyFromSet(boolean dbOnly, Dictionary<K, V> set, String key)
getPropertyFromSetback to summary
public static String getPropertyFromSet(boolean dbOnly, Properties set, String key)
getServiceBooleanback to summary
public static boolean getServiceBoolean(PersistentSet set, String key, boolean defValue) throws StandardException

Get a service wide property as a boolean.

Parameters
set:PersistentSet

The property set to inspect

key:String

The key to lookup

defValue:boolean

The default value to use

Returns:boolean

true of the property is set to 'true, TRUE', false otherwise

Exceptions
StandardException:
Standard Derby error handling.
getServiceIntback to summary
public static int getServiceInt(PersistentSet set, String key, int min, int max, int defaultValue) throws StandardException

Get a service wide property as a int.

Parameters
set:PersistentSet

The property set

key:String

The key to lookup

min:int

The min acceptable value

max:int

The max acceptable value

defaultValue:int

The value to use if the key has no match

Returns:int

value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.

Exceptions
StandardException:
Standard Derby error handling.
getServiceIntback to summary
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.

Parameters
set:PersistentSet

The target property set

props:Properties

The properties

key:String

The key to lookup

min:int

The min acceptable value

max:int

The max acceptable value

defaultValue:int

The value to use if the key has no match

Returns:int

value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.

Exceptions
StandardException:
Standard Derby error handling.
getServicePropertyback to summary
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.

Parameters
set:PersistentSet

The property set to inspect

key:String

The key to lookup

defaultValue:String

The default value to use

Returns:String

the value of the property or defaultValue if it does not exist.

Exceptions
StandardException:
Standard Derby error handling.
getServicePropertyback to summary
public static String getServiceProperty(PersistentSet set, String key) throws StandardException

Find a service wide property. The service is the persistent service associated with the current context stack.

Parameters
set:PersistentSet

The property set to inspect

key:String

The key to lookup

Returns:String

the value of the property or null if it does not exist.

Exceptions
StandardException:
Standard Derby error handling.
getServicePropertyListback to summary
public static String[] getServicePropertyList()

Get the list of properties which are normally stored in service.properties

Returns:String[]

the list of properties which are normally stored in service.propertie

getSystemBooleanback to summary
public static boolean getSystemBoolean(String key)

Get a system wide property as a boolean.

Parameters
key:String

The name of the system property

Returns:boolean

true of the property is set to 'true, TRUE', false otherwise

getSystemBooleanback to summary
public static boolean getSystemBoolean(String key, boolean defaultValue)

Get a system wide property as a boolean.

Parameters
key:String

The name of the system property

defaultValue:boolean

The value to use if the property has not been set

Returns:boolean

return defaultValue if the property is not set, returns true if the property is set to 'true, TRUE', returns false otherwise.

getSystemIntback to summary
public static int getSystemInt(String key, int min, int max, int defaultValue)

s Get a system wide property as a int.

Parameters
key:String

The key to lookup

min:int

The min acceptable value

max:int

The max acceptable value

defaultValue:int

The value to use if the key has no match

Returns:int

value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.

getSystemIntback to summary
public static int getSystemInt(String key, int defaultValue)

Get a system wide property as a int.

Parameters
key:String

The key to lookup

defaultValue:int

The value to use if the key has no match

Returns:int

value of the property if, defaultValue if it is not set or set to a non-integer value.

getSystemPropertyback to summary
public static String getSystemProperty(String key)

Find a system wide property.

Parameters
key:String

The key to lookup

Returns:String

the value of the property or null if it does not exist.

See Also
getSystemProperty(String, String)
getSystemPropertyback to summary
public static String getSystemProperty(String key, String defaultValue)

Find a system wide property with a default. Search order is

  1. JVM property
  2. 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.

Parameters
key:String

The propertykey

defaultValue:String

A default value

Returns:String

the value of the property or defaultValue if it does not exist.

handleIntback to summary
public static int handleInt(String value, int min, int max, int defaultValue)

Parse an string as an int based property value.

Parameters
value:String

The string value to be parsed as an int

min:int

The minimum legal value

max:int

The maximum legal value

defaultValue:int

The defaultValue to set

Returns:int

the final value

intPropertyValueback to summary
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.

Parameters
p:String

The property name

v:Serializable

The desired value

minValue:int

The minimum legal value

maxValue:int

The maximum legal value

defaultValue:int

The default value to use

Returns:int

The final value decided on

Exceptions
StandardException:
Oops
isDBOnlyback to summary
public static boolean isDBOnly(Dictionary<K, V> set)
isDBOnlyback to summary
public static boolean isDBOnly(Properties set)
isServicePropertyback to summary
public static boolean isServiceProperty(String key)

Return true iff the key is the name of a database property that is stored in services.properties.

Parameters
key:String

The name of a property

Returns:boolean

true if that property is stored in service.properties

localNativeAuthenticationEnabledback to summary
public static boolean localNativeAuthenticationEnabled(Properties properties)

Return true if the passed-in properties specify NATIVE authentication using LOCAL credentials.

Parameters
properties:Properties

A set of properties

Returns:boolean

true if the passed-in properties specify NATIVE authentication using LOCAL credentials

nativeAuthenticationEnabledback to summary
public static boolean nativeAuthenticationEnabled(Properties properties)

Return true if NATIVE authentication has been enabled in the passed-in properties.

Parameters
properties:Properties

A set of properties

Returns:boolean

true if NATIVE authentication has been enabled in the passed-in properties

nativeAuthenticationEnabledback to summary
private static boolean nativeAuthenticationEnabled(String authenticationProvider)

Return true if NATIVE authentication is turned on for the passed-in value of Property.AUTHENTICATION_PROVIDER_PARAMETER.

Parameters
authenticationProvider:String

An authentication service spec

Returns:boolean

true if NATIVE authentication is turned in that spec

propertiesContainsBuiltinUserback to summary
private static boolean propertiesContainsBuiltinUser(Properties props, String username)
systemPropertiesExistsBuiltinUserback to summary
private static boolean systemPropertiesExistsBuiltinUser(String username)

Return true if username is defined as a system property i.e. there exists a property derby.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:String

Normalized authorization identifier

Returns:boolean

true if match found

whereSetback to summary
pack-priv static int whereSet(String key, Dictionary<K, V> set)