Class PropConfigStore

java.lang.Object
com.netscape.cmscore.base.PropConfigStore
All Implemented Interfaces:
IConfigStore, Cloneable
Direct Known Subclasses:
AuthenticationConfig, AuthManagerConfig, AuthManagersConfig, AuthorizationConfig, AuthzManagerConfig, AuthzManagersConfig, DatabaseConfig, EngineConfig, JssSubsystemConfig, LDAPAuthenticationConfig, LDAPConfig, LDAPConnectionConfig, PKISocketConfig, PreOpConfig, PublishingConfig, PublishingMapperConfig, PublishingPublisherConfig, PublishingRuleConfig, RandomConfig, SSLConfig, SubsystemConfig, SubsystemsConfig, UGSubsystemConfig

public class PropConfigStore extends Object implements IConfigStore, Cloneable
A class represents a in-memory configuration store. Note this class takes advantage of the recursive nature of property names. The current property prefix is kept in mStoreName and the mSource usually points back to another occurance of the same PropConfigStore, with longer mStoreName. IE


 The chain ends when the store name is reduced down to it's original
 value.
 

Version:
$Revision$, $Date$
  • Field Details

    • logger

      public static final org.slf4j.Logger logger
    • PROP_SUBSTORES

      protected static final String PROP_SUBSTORES
      See Also:
    • mStoreName

      protected String mStoreName
      The name of this substore
    • mSource

      protected SimpleProperties mSource
      The source data for this substore
    • storage

      protected ConfigStorage storage
  • Constructor Details

    • PropConfigStore

      public PropConfigStore()
    • PropConfigStore

      public PropConfigStore(ConfigStorage storage)
    • PropConfigStore

      public PropConfigStore(String storeName)
      Constructs a property configuration store. This must be a brand new store without properties. The subclass must be a SourceConfigStore.

      Parameters:
      storeName - property store name
      Throws:
      EBaseException - failed to create configuration
    • PropConfigStore

      protected PropConfigStore(String name, SimpleProperties source)
      Constructs a configuration store. The constructor is a helper class for substores. Source is the one that stores all the parameters. Each substore only store a substore name, and a reference to the source.

      Parameters:
      name - store name
      source - list of properties
      Throws:
      EBaseException - failed to create configuration
  • Method Details

    • getName

      public String getName()
      Returns the name of this store.

      Specified by:
      getName in interface IConfigStore
      Returns:
      store name
    • getStorage

      public ConfigStorage getStorage()
    • get

      public String get(String name)
      Retrieves a property from the configuration file.

      Specified by:
      get in interface IConfigStore
      Parameters:
      name - property name
      Returns:
      property value
    • put

      public String put(String name, String value)
      Puts a property into the configuration file. The values wont be updated to the file until save method is invoked.

      Specified by:
      put in interface IConfigStore
      Parameters:
      name - property name
      value - property value
    • remove

      public void remove(String name)
      Removes a property from the configuration file.
      Specified by:
      remove in interface IConfigStore
      Parameters:
      name - property name
    • keys

      public Enumeration<String> keys()
      Returns an enumeration of the config store's keys, hidding the store name.
      Specified by:
      keys in interface IConfigStore
      Returns:
      a list of keys
      See Also:
    • getProperties

      public Map<String,String> getProperties()
      Retrieves lexicographically sorted properties as a map.
      Specified by:
      getProperties in interface IConfigStore
      Returns:
      map
    • size

      public int size()
      Return the number of items in this substore
      Specified by:
      size in interface IConfigStore
    • clear

      public void clear()
      Description copied from interface: IConfigStore
      Clear the config store.
      Specified by:
      clear in interface IConfigStore
    • load

      public void load() throws Exception
      Description copied from interface: IConfigStore
      Load config from storage storage (file or LDAP).
      Specified by:
      load in interface IConfigStore
      Throws:
      Exception - If an error occurs while loading.
    • commit

      public void commit(boolean createBackup) throws EBaseException
      Description copied from interface: IConfigStore
      Store config into storage (file or LDAP).
      Specified by:
      commit in interface IConfigStore
      Parameters:
      createBackup - true if a backup file should be created
      Throws:
      EBaseException - failed to commit
    • load

      public void load(InputStream in) throws IOException
      Reads a config store from an input stream.
      Specified by:
      load in interface IConfigStore
      Parameters:
      in - input stream where properties are located
      Throws:
      IOException - failed to load
    • store

      public void store(OutputStream out) throws Exception
      Stores this config store to the specified output stream.
      Specified by:
      store in interface IConfigStore
      Parameters:
      out - outputstream where the properties are saved
      Throws:
      Exception
    • getString

      public String getString(String name) throws EBaseException
      Retrieves a property value.
      Specified by:
      getString in interface IConfigStore
      Parameters:
      name - property key
      Returns:
      property value
      Throws:
      EBaseException - failed to retrieve value
    • getString

      public String getString(String name, String defval) throws EBaseException
      Retrieves a String from the configuration file.

      Specified by:
      getString in interface IConfigStore
      Parameters:
      name - property name
      defval - the default object to return if name does not exist
      Returns:
      property value
      Throws:
      EBaseException - If an internal error occurred
    • putString

      public void putString(String name, String value)
      Puts property value into this configuration store.
      Specified by:
      putString in interface IConfigStore
      Parameters:
      name - property key
      value - property value
    • getByteArray

      public byte[] getByteArray(String name) throws EBaseException
      Retrieves a byte array from the configuration file.

      Specified by:
      getByteArray in interface IConfigStore
      Parameters:
      name - property name
      Returns:
      property value
      Throws:
      IllegalArgumentException - if name is not set or is null.
      EPropertyNotFound - If the property is not present
      EBaseException - If an internal error occurred
    • getByteArray

      public byte[] getByteArray(String name, byte[] defval) throws EBaseException
      Retrieves a byte array from the configuration file.

      Specified by:
      getByteArray in interface IConfigStore
      Parameters:
      name - property name
      defval - the default byte array to return if name does not exist
      Returns:
      property value
      Throws:
      EBaseException - If an internal error occurred
    • putByteArray

      public void putByteArray(String name, byte[] value)
      Puts byte array into this configuration store.
      Specified by:
      putByteArray in interface IConfigStore
      Parameters:
      name - property key
      value - byte array
    • getBoolean

      public boolean getBoolean(String name) throws EBaseException
      Retrieves boolean-based property value.
      Specified by:
      getBoolean in interface IConfigStore
      Parameters:
      name - property key
      Returns:
      boolean value
      Throws:
      EBaseException - failed to retrieve
    • getBoolean

      public boolean getBoolean(String name, boolean defval) throws EBaseException
      Retrieves boolean-based property value.
      Specified by:
      getBoolean in interface IConfigStore
      Parameters:
      name - property key
      defval - default value
      Returns:
      boolean value
      Throws:
      EBaseException - failed to retrieve
    • putBoolean

      public void putBoolean(String name, boolean value)
      Puts boolean value into the configuration store.
      Specified by:
      putBoolean in interface IConfigStore
      Parameters:
      name - property key
      value - property value
    • getInteger

      public int getInteger(String name) throws EBaseException
      Retrieves integer value.
      Specified by:
      getInteger in interface IConfigStore
      Parameters:
      name - property key
      Returns:
      property value
      Throws:
      EBaseException - failed to retrieve value
    • getInteger

      public int getInteger(String name, int defval) throws EBaseException
      Retrieves integer value.
      Specified by:
      getInteger in interface IConfigStore
      Parameters:
      name - property key
      defval - default value
      Returns:
      property value
      Throws:
      EBaseException - failed to retrieve value
    • putInteger

      public void putInteger(String name, int val)
      Puts an integer value.
      Specified by:
      putInteger in interface IConfigStore
      Parameters:
      name - property key
      val - property value
      Throws:
      EBaseException - failed to retrieve value
    • getBigInteger

      public BigInteger getBigInteger(String name) throws EBaseException
      Retrieves big integer value.
      Specified by:
      getBigInteger in interface IConfigStore
      Parameters:
      name - property key
      Returns:
      property value
      Throws:
      EBaseException - failed to retrieve value
    • getBigInteger

      public BigInteger getBigInteger(String name, BigInteger defval) throws EBaseException
      Retrieves integer value.
      Specified by:
      getBigInteger in interface IConfigStore
      Parameters:
      name - property key
      defval - default value
      Returns:
      property value
      Throws:
      EBaseException - failed to retrieve value
    • putBigInteger

      public void putBigInteger(String name, BigInteger val)
      Puts a big integer value.
      Specified by:
      putBigInteger in interface IConfigStore
      Parameters:
      name - property key
      val - default value
    • makeSubStore

      public IConfigStore makeSubStore(String name)
      Creates a new sub store.

      Specified by:
      makeSubStore in interface IConfigStore
      Parameters:
      name - substore name
      Returns:
      substore
    • removeSubStore

      public void removeSubStore(String name)
      Removes a sub store.

      Specified by:
      removeSubStore in interface IConfigStore
      Parameters:
      name - substore name
    • getSubStore

      public IConfigStore getSubStore(String name)
      Retrieves a sub store. A substore contains a list of properties and substores. For example,
          cms.ldap.host=ds.netscape.com
          cms.ldap.port=389
       
      "ldap" is a substore in above example. If the substore property itself is set, this method will treat the value as a reference. For example,
       cms.ldap = kms.ldap
       

      Specified by:
      getSubStore in interface IConfigStore
      Parameters:
      name - substore name
      Returns:
      substore
    • getSubStore

      public <T extends IConfigStore> T getSubStore(String name, Class<T> clazz)
      Specified by:
      getSubStore in interface IConfigStore
    • getPropertyNames

      public Enumeration<String> getPropertyNames()
      Retrieves a list of property names.
      Specified by:
      getPropertyNames in interface IConfigStore
      Returns:
      a list of string-based property names
    • getSubStoreNames

      public Enumeration<String> getSubStoreNames()
      Returns a list of sub store names.

      Specified by:
      getSubStoreNames in interface IConfigStore
      Returns:
      list of substore names
    • getSource

      public SimpleProperties getSource()
      Retrieves the source configuration store where the properties are stored.

      Returns:
      source configuration store
    • printProperties

      public void printProperties()
      For debugging purposes. Prints properties of this substore.
    • getFullName

      protected String getFullName(String name)
      Converts the substore parameters.
      Parameters:
      name - property name
      Returns:
      fill property name
    • clone

      public Object clone()
      Cloning of property configuration store.
      Overrides:
      clone in class Object
      Returns:
      a new configuration store