Class 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.
    Components can then access these properties using any of the convenience accessors for boolean, Boolean, long, int, Object, String types. When accessing properties the user-provided value is taken first (if available), otherwise the default value is used (or null).
    See Also:
    Serialized Form
    • 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".
      • getInternalNameForProperty

        public String getInternalNameForProperty​(String name)
      • 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: PropertyStore
        Accessor for whether a particular property is defined (but may be null).
        Overrides:
        hasProperty in class PropertyStore
        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 class PropertyStore
        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()
      • getPropertyNamesWithPrefix

        public Set<String> getPropertyNamesWithPrefix​(String prefix)
      • 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 property
        value - Value
      • validatePropertyValue

        public void validatePropertyValue​(String name,
                                          Object value)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object