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:
  • Field Details

  • Constructor Details

    • 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 Details

    • 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".
    • isPropertyForDatastore

      private boolean isPropertyForDatastore(String name)
      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

      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)
      Accessor for the case-sensitive (external) name for the passed (likely lowercase) name and prefix.
      Parameters:
      propName - The (likely lowercase) name
      propPrefix - 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 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
    • 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:
    • 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)
    • validatePropertyValue

      private void validatePropertyValue(String name, Object value, String validatorName)
      Convenience method to validate the value for a property using the provided validator.
      Parameters:
      name - The property name
      value - The value
      validatorName - Name of the validator class
      Throws:
      IllegalArgumentException - if doesnt validate correctly
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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 format
       mypropertyname=myvalue
       
      Parameters:
      filename - Name of the file containing the properties
      Returns:
      the Persistence Properties in this file
      Throws:
      NucleusUserException - if file not readable