Package org.datanucleus
Class Configuration
java.lang.Object
org.datanucleus.properties.PropertyStore
org.datanucleus.Configuration
- All Implemented Interfaces:
Serializable
Class providing configuration for the context.
Properties are defined by the context, and optionally defined in plugin.xml for any datastore/api plugins.
Property values are stored in maps.
- The first is the default value for the property (where a default is defined). The default comes from either the plugin defining it, or for the API being used (overrides any plugin default).
- The second is the user-provided value (where the user has provided one). This is held in the superclass PropertyStore.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Convenience class wrapping the plugin property specification information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FrequentlyAccessedProperties
Map of default properties, used as a fallback.private NucleusContext
private Map
<String, Configuration.PropertyMapping> Mapping for the properties of the plugins, PropertyMapping, keyed by the property name.private Map
<String, PropertyValidator> private static final long
Fields inherited from class org.datanucleus.properties.PropertyStore
frequentProperties, properties
-
Constructor Summary
ConstructorsConstructorDescriptionConfiguration
(NucleusContext nucCtx) Create a configuration object for the specified NucleusContext. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDefaultBooleanProperty
(String name, String internalName, Boolean value, boolean datastore, boolean managerOverrideable) void
addDefaultIntegerProperty
(String name, String internalName, Integer value, boolean datastore, boolean managerOverrideable) void
addDefaultProperty
(String name, String internalName, String value, String validatorName, boolean datastore, boolean managerOverrideable) boolean
getCaseSensitiveNameForPropertyName
(String propName) Accessor for the case-sensitive name for the passed (lowercase) name.Convenience method to return all properties that are user-specified and should be specified on the StoreManager.Returns the names of the properties that are manager overrideable (using their original cases, not lowercase).Convenience method to return all properties that are overrideable on the PM/EM.Accessor for the persistence properties.Accessor for the persistence properties default values.static Properties
getPropertiesFromPropertiesFile
(String filename) Method to return the persistence properties from the specified properties file.getProperty
(String name) Accessor for the specified property as an Object.getPropertyNamesWithPrefix
(String prefix) Accessor for all properties starting with the provided prefix.getPropertyNameWithInternalPropertyName
(String propName, String propPrefix) Accessor for the case-sensitive (external) name for the passed (likely lowercase) name and prefix.Accessor for the names of the supported persistence properties.protected Object
getValueForPropertyWithValidator
(String value, String validatorName) int
hashCode()
boolean
hasProperty
(String name) Accessor for whether a particular property is defined (but may be null).private boolean
isPropertyForDatastore
(String name) Accessor for whether the specified property name should be stored with the StoreManager.void
Method that removes all properties from this store that are marked as "datastore".void
setDefaultProperties
(Map<String, Object> props) Method to set the persistence property defaults based on what is defined for plugins.void
setPersistenceProperties
(Map<String, Object> props) Set the properties for this configuration.void
setPropertiesUsingFile
(String filename) Method to set the persistence properties using those defined in a file.void
setProperty
(String name, Object value) Convenience method to set a persistence property.void
validatePropertyValue
(String name, Object value) private void
validatePropertyValue
(String name, Object value, String validatorName) Convenience method to validate the value for a property using the provided validator.Methods inherited from class org.datanucleus.properties.PropertyStore
getBooleanObjectProperty, getBooleanProperty, getBooleanProperty, getFrequentProperties, getIntProperty, getStringProperty, hasPropertyNotNull, setPropertyInternal
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
nucCtx
-
propertyMappings
Mapping for the properties of the plugins, PropertyMapping, keyed by the property name. -
defaultProperties
Map of default properties, used as a fallback. Key is lower-case. -
propertyValidators
-
managerOverrideableProperties
-
defaultFrequentProperties
-
-
Constructor Details
-
Configuration
Create a configuration object for the specified NucleusContext. Initialises all basic properties with suitable defaults, including any specified in meta-data in plugins.- Parameters:
nucCtx
- NucleusContext
-
-
Method Details
-
getSupportedProperties
Accessor for the names of the supported persistence properties.- Returns:
- The persistence properties that we support
-
getDatastoreProperties
Convenience method to return all properties that are user-specified and should be specified on the StoreManager.- Returns:
- Datastore properties
-
removeDatastoreProperties
public void removeDatastoreProperties()Method that removes all properties from this store that are marked as "datastore". -
isPropertyForDatastore
Accessor for whether the specified property name should be stored with the StoreManager.- Parameters:
name
- Name of the property- Returns:
- Whether it is for the datastore
-
getInternalNameForProperty
-
getManagerOverrideableProperties
Convenience method to return all properties that are overrideable on the PM/EM.- Returns:
- PM/EM overrideable properties
-
getManagedOverrideablePropertyNames
Returns the names of the properties that are manager overrideable (using their original cases, not lowercase).- Returns:
- The supported manager-overrideable property names
-
getPropertyNameWithInternalPropertyName
Accessor for the case-sensitive (external) name for the passed (likely lowercase) name and prefix.- Parameters:
propName
- The (likely lowercase) namepropPrefix
- The prefix for the property name- Returns:
- The case-sensitive (external) property name
-
getCaseSensitiveNameForPropertyName
Accessor for the case-sensitive name for the passed (lowercase) name. Works on the basis that the propertyMappings keys are stored in the case-senistive form.- Parameters:
propName
- The (lowercase) name- Returns:
- Case sensitive name
-
setDefaultProperties
Method to set the persistence property defaults based on what is defined for plugins. This should only be called after the other setDefaultProperties method is called, which sets up the mappings- Parameters:
props
- Properties to use in the default set
-
addDefaultBooleanProperty
-
addDefaultIntegerProperty
-
addDefaultProperty
-
getValueForPropertyWithValidator
-
hasProperty
Description copied from class:PropertyStore
Accessor for whether a particular property is defined (but may be null).- Overrides:
hasProperty
in classPropertyStore
- Parameters:
name
- Property name- Returns:
- Whether the property is defined
-
getProperty
Accessor for the specified property as an Object. Returns user-specified value if provided, otherwise the default value, otherwise null.- Overrides:
getProperty
in classPropertyStore
- Parameters:
name
- Name of the property- Returns:
- Value for the property
-
setPropertiesUsingFile
Method to set the persistence properties using those defined in a file.- Parameters:
filename
- Name of the file containing the properties
-
getPersistencePropertiesDefaults
Accessor for the persistence properties default values. This returns the defaulted properties- Returns:
- The persistence properties
-
getPersistenceProperties
Accessor for the persistence properties. This returns just the user-supplied properties, not the defaulted properties- Returns:
- The persistence properties
-
getPropertyNamesWithPrefix
Accessor for all properties starting with the provided prefix.- Parameters:
prefix
- Prefix (lowercase, since all properties are stored in lowercase)- Returns:
- The properties with this prefix
-
setPersistenceProperties
Set the properties for this configuration. Note : this has this name so it has a getter/setter pair for use by things like Spring.- Parameters:
props
- The persistence properties- See Also:
-
setProperty
Convenience method to set a persistence property. Uses any validator defined for the property to govern whether the value is suitable.- Parameters:
name
- Name of the propertyvalue
- Value
-
validatePropertyValue
-
validatePropertyValue
Convenience method to validate the value for a property using the provided validator.- Parameters:
name
- The property namevalue
- The valuevalidatorName
- Name of the validator class- Throws:
IllegalArgumentException
- if doesnt validate correctly
-
equals
-
hashCode
public int hashCode() -
getPropertiesFromPropertiesFile
Method to return the persistence properties from the specified properties file. The lines of the file will be of formatmypropertyname=myvalue
- Parameters:
filename
- Name of the file containing the properties- Returns:
- the Persistence Properties in this file
- Throws:
NucleusUserException
- if file not readable
-