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 classConvenience class wrapping the plugin property specification information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FrequentlyAccessedPropertiesMap of default properties, used as a fallback.private NucleusContextprivate Map<String, Configuration.PropertyMapping> Mapping for the properties of the plugins, PropertyMapping, keyed by the property name.private Map<String, PropertyValidator> private static final longFields inherited from class PropertyStore
frequentProperties, properties -
Constructor Summary
ConstructorsConstructorDescriptionConfiguration(NucleusContext nucCtx) Create a configuration object for the specified NucleusContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultBooleanProperty(String name, String internalName, Boolean value, boolean datastore, boolean managerOverrideable) voidaddDefaultIntegerProperty(String name, String internalName, Integer value, boolean datastore, boolean managerOverrideable) voidaddDefaultProperty(String name, String internalName, String value, String validatorName, boolean datastore, boolean managerOverrideable) booleangetCaseSensitiveNameForPropertyName(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 PropertiesgetPropertiesFromPropertiesFile(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 ObjectgetValueForPropertyWithValidator(String value, String validatorName) inthashCode()booleanhasProperty(String name) Accessor for whether a particular property is defined (but may be null).private booleanisPropertyForDatastore(String name) Accessor for whether the specified property name should be stored with the StoreManager.voidMethod that removes all properties from this store that are marked as "datastore".voidsetDefaultProperties(Map<String, Object> props) Method to set the persistence property defaults based on what is defined for plugins.voidsetPersistenceProperties(Map<String, Object> props) Set the properties for this configuration.voidsetPropertiesUsingFile(String filename) Method to set the persistence properties using those defined in a file.voidsetProperty(String name, Object value) Convenience method to set a persistence property.voidvalidatePropertyValue(String name, Object value) private voidvalidatePropertyValue(String name, Object value, String validatorName) Convenience method to validate the value for a property using the provided validator.Methods inherited from class 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
-
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
-
getDatastoreProperties
-
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
-
getManagedOverrideablePropertyNames
-
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
-
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:PropertyStoreAccessor for whether a particular property is defined (but may be null).- Overrides:
hasPropertyin 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:
getPropertyin 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
-
getPersistenceProperties
-
getPropertyNamesWithPrefix
-
setPersistenceProperties
-
setProperty
-
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
-
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
-