Package org.datanucleus
Class Configuration
- 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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
equals(Object obj)
String
getCaseSensitiveNameForPropertyName(String propName)
Accessor for the case-sensitive name for the passed (lowercase) name.Map<String,Object>
getDatastoreProperties()
Convenience method to return all properties that are user-specified and should be specified on the StoreManager.String
getInternalNameForProperty(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.static Properties
getPropertiesFromPropertiesFile(String filename)
Method to return the persistence properties from the specified properties file.Object
getProperty(String name)
Accessor for the specified property as an Object.Set<String>
getPropertyNamesWithPrefix(String prefix)
Accessor for all properties starting with the provided prefix.String
getPropertyNameWithInternalPropertyName(String propName, String propPrefix)
Accessor for the case-sensitive (external) name for the passed (likely lowercase) name and prefix.Set<String>
getSupportedProperties()
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).void
removeDatastoreProperties()
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)
-
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)
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
public String getCaseSensitiveNameForPropertyName(String propName)
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
public void setDefaultProperties(Map<String,Object> 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: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
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:
getProperty
in 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
-
getPropertyNamesWithPrefix
public Set<String> getPropertyNamesWithPrefix(String prefix)
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
public void setPersistenceProperties(Map<String,Object> 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:
getPersistenceProperties()
-
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
-
getPropertiesFromPropertiesFile
public static Properties getPropertiesFromPropertiesFile(String filename)
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
-
-