- java.lang.Object
-
- org.datanucleus.properties.PropertyStore
-
- org.datanucleus.Configuration
-
- All Implemented Interfaces:
Serializable
public class Configuration extends PropertyStore implements 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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.datanucleus.properties.PropertyStore
frequentProperties, properties
-
-
Constructor Summary
Constructors Constructor Description Configuration(NucleusContext nucCtx)Create a configuration object for the specified NucleusContext.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDefaultBooleanProperty(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)booleanequals(Object obj)StringgetCaseSensitiveNameForPropertyName(String propName)Map<String,Object>getDatastoreProperties()Convenience method to return all properties that are user-specified and should be specified on the StoreManager.StringgetInternalNameForProperty(String name)Set<String>getManagedOverrideablePropertyNames()Returns the names of the properties that are manager overrideable (using their original cases, not lowercase).Map<String,Object>getManagerOverrideableProperties()Convenience method to return all properties that are overrideable on the PM/EM.Map<String,Object>getPersistenceProperties()Accessor for the persistence properties.Map<String,Object>getPersistencePropertiesDefaults()Accessor for the persistence properties default values.ObjectgetProperty(String name)Accessor for the specified property as an Object.Set<String>getPropertyNamesWithPrefix(String prefix)StringgetPropertyNameWithInternalPropertyName(String propName, String propPrefix)Set<String>getSupportedProperties()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).voidremoveDatastoreProperties()Method that removes all properties from this store that are marked as "datastore".voidsetDefaultProperties(Map props)Method to set the persistence property defaults based on what is defined for plugins.voidsetPersistenceProperties(Map 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)-
Methods inherited from class org.datanucleus.properties.PropertyStore
getBooleanObjectProperty, getBooleanProperty, getBooleanProperty, getFrequentProperties, getIntProperty, getStringProperty, hasPropertyNotNull, setPropertyInternal
-
-
-
-
Constructor Detail
-
Configuration
public Configuration(NucleusContext nucCtx)
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 Detail
-
getSupportedProperties
public Set<String> getSupportedProperties()
Accessor for the names of the supported persistence properties.- Returns:
- The persistence properties that we support
-
getDatastoreProperties
public Map<String,Object> 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".
-
getManagerOverrideableProperties
public Map<String,Object> getManagerOverrideableProperties()
Convenience method to return all properties that are overrideable on the PM/EM.- Returns:
- PM/EM overrideable properties
-
getManagedOverrideablePropertyNames
public Set<String> 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
public String getPropertyNameWithInternalPropertyName(String propName, String propPrefix)
-
getCaseSensitiveNameForPropertyName
public String getCaseSensitiveNameForPropertyName(String propName)
-
setDefaultProperties
public void setDefaultProperties(Map props)
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
public void addDefaultBooleanProperty(String name, String internalName, Boolean value, boolean datastore, boolean managerOverrideable)
-
addDefaultIntegerProperty
public void addDefaultIntegerProperty(String name, String internalName, Integer value, boolean datastore, boolean managerOverrideable)
-
addDefaultProperty
public void addDefaultProperty(String name, String internalName, String value, String validatorName, boolean datastore, boolean managerOverrideable)
-
getValueForPropertyWithValidator
protected Object getValueForPropertyWithValidator(String value, String validatorName)
-
hasProperty
public boolean hasProperty(String name)
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
public Object getProperty(String name)
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
public void setPropertiesUsingFile(String filename)
Method to set the persistence properties using those defined in a file.- Parameters:
filename- Name of the file containing the properties
-
getPersistencePropertiesDefaults
public Map<String,Object> getPersistencePropertiesDefaults()
Accessor for the persistence properties default values. This returns the defaulted properties- Returns:
- The persistence properties
-
getPersistenceProperties
public Map<String,Object> getPersistenceProperties()
Accessor for the persistence properties. This returns just the user-supplied properties, not the defaulted properties- Returns:
- The persistence properties
- See Also:
getPersistenceProperties()
-
setPersistenceProperties
public void setPersistenceProperties(Map props)
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:
getPersistencePropertiesDefaults()
-
setProperty
public void setProperty(String name, Object value)
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
-
-