Package com.netscape.cmscore.base
Class PropConfigStore
- java.lang.Object
-
- com.netscape.cmscore.base.PropConfigStore
-
- All Implemented Interfaces:
IConfigStore,java.lang.Cloneable
- Direct Known Subclasses:
AuthenticationConfig,AuthManagerConfig,AuthManagersConfig,AuthorizationConfig,AuthzManagerConfig,AuthzManagersConfig,DatabaseConfig,EngineConfig,JssSubsystemConfig,LDAPAuthenticationConfig,LDAPConfig,LDAPConnectionConfig,PKISocketConfig,PreOpConfig,RandomConfig,SSLConfig,SubsystemConfig,SubsystemsConfig,UGSubsystemConfig
public class PropConfigStore extends java.lang.Object implements IConfigStore, java.lang.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. IEcms.ca0.http.service0 -> mSource=PropConfigStore -> cms.ca0.http -> mSource=PropConfigStore -> cms.ca0 -> mSource=PropConfigStore -> cms -> mSource=SourceConfigStore -> PropertiesThe chain ends when the store name is reduced down to it's original value.- Version:
- $Revision$, $Date$
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.Loggerloggerprotected SimplePropertiesmSourceThe source data for this substoreprotected java.lang.StringmStoreNameThe name of this substoreprotected static java.lang.StringPROP_SUBSTORESprotected ConfigStoragestorage
-
Constructor Summary
Constructors Modifier Constructor Description PropConfigStore()PropConfigStore(ConfigStorage storage)PropConfigStore(java.lang.String storeName)Constructs a property configuration store.protectedPropConfigStore(java.lang.String name, SimpleProperties source)Constructs a configuration store.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the config store.java.lang.Objectclone()Cloning of property configuration store.voidcommit(boolean createBackup)Store config into storage (file or LDAP).java.lang.Stringget(java.lang.String name)Retrieves a property from the configuration file.java.math.BigIntegergetBigInteger(java.lang.String name)Retrieves big integer value.java.math.BigIntegergetBigInteger(java.lang.String name, java.math.BigInteger defval)Retrieves integer value.booleangetBoolean(java.lang.String name)Retrieves boolean-based property value.booleangetBoolean(java.lang.String name, boolean defval)Retrieves boolean-based property value.byte[]getByteArray(java.lang.String name)Retrieves a byte array from the configuration file.byte[]getByteArray(java.lang.String name, byte[] defval)Retrieves a byte array from the configuration file.protected java.lang.StringgetFullName(java.lang.String name)Converts the substore parameters.intgetInteger(java.lang.String name)Retrieves integer value.intgetInteger(java.lang.String name, int defval)Retrieves integer value.java.lang.StringgetName()Returns the name of this store.java.util.Map<java.lang.String,java.lang.String>getProperties()Retrieves lexicographically sorted properties as a map.java.util.Enumeration<java.lang.String>getPropertyNames()Retrieves a list of property names.SimplePropertiesgetSource()Retrieves the source configuration store where the properties are stored.ConfigStoragegetStorage()java.lang.StringgetString(java.lang.String name)Retrieves a property value.java.lang.StringgetString(java.lang.String name, java.lang.String defval)Retrieves a String from the configuration file.IConfigStoregetSubStore(java.lang.String name)Retrieves a sub store.<T extends IConfigStore>
TgetSubStore(java.lang.String name, java.lang.Class<T> clazz)java.util.Enumeration<java.lang.String>getSubStoreNames()Returns a list of sub store names.java.util.Enumeration<java.lang.String>keys()Returns an enumeration of the config store's keys, hidding the store name.voidload()Load config from storage storage (file or LDAP).voidload(java.io.InputStream in)Reads a config store from an input stream.IConfigStoremakeSubStore(java.lang.String name)Creates a new sub store.voidprintProperties()For debugging purposes.java.lang.Stringput(java.lang.String name, java.lang.String value)Puts a property into the configuration file.voidputBigInteger(java.lang.String name, java.math.BigInteger val)Puts a big integer value.voidputBoolean(java.lang.String name, boolean value)Puts boolean value into the configuration store.voidputByteArray(java.lang.String name, byte[] value)Puts byte array into this configuration store.voidputInteger(java.lang.String name, int val)Puts an integer value.voidputString(java.lang.String name, java.lang.String value)Puts property value into this configuration store.voidremove(java.lang.String name)Removes a property from the configuration file.voidremoveSubStore(java.lang.String name)Removes a sub store.intsize()Return the number of items in this substorevoidstore(java.io.OutputStream out)Stores this config store to the specified output stream.
-
-
-
Field Detail
-
logger
public static final org.slf4j.Logger logger
-
PROP_SUBSTORES
protected static final java.lang.String PROP_SUBSTORES
- See Also:
- Constant Field Values
-
mStoreName
protected java.lang.String mStoreName
The name of this substore
-
mSource
protected SimpleProperties mSource
The source data for this substore
-
storage
protected ConfigStorage storage
-
-
Constructor Detail
-
PropConfigStore
public PropConfigStore()
-
PropConfigStore
public PropConfigStore(ConfigStorage storage)
-
PropConfigStore
public PropConfigStore(java.lang.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(java.lang.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:
storeName- store nameprop- list of properties- Throws:
EBaseException- failed to create configuration
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this store.- Specified by:
getNamein interfaceIConfigStore- Returns:
- store name
-
getStorage
public ConfigStorage getStorage()
-
get
public java.lang.String get(java.lang.String name)
Retrieves a property from the configuration file.- Specified by:
getin interfaceIConfigStore- Parameters:
name- property name- Returns:
- property value
-
put
public java.lang.String put(java.lang.String name, java.lang.String value)Puts a property into the configuration file. The values wont be updated to the file until save method is invoked.- Specified by:
putin interfaceIConfigStore- Parameters:
name- property namevalue- property value
-
remove
public void remove(java.lang.String name)
Removes a property from the configuration file.- Specified by:
removein interfaceIConfigStore- Parameters:
name- property name
-
keys
public java.util.Enumeration<java.lang.String> keys()
Returns an enumeration of the config store's keys, hidding the store name.- Specified by:
keysin interfaceIConfigStore- Returns:
- a list of keys
- See Also:
Hashtable.elements(),Enumeration
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Retrieves lexicographically sorted properties as a map.- Specified by:
getPropertiesin interfaceIConfigStore- Returns:
- map
-
size
public int size()
Return the number of items in this substore- Specified by:
sizein interfaceIConfigStore
-
clear
public void clear()
Description copied from interface:IConfigStoreClear the config store.- Specified by:
clearin interfaceIConfigStore
-
load
public void load() throws java.lang.ExceptionDescription copied from interface:IConfigStoreLoad config from storage storage (file or LDAP).- Specified by:
loadin interfaceIConfigStore- Throws:
java.lang.Exception- If an error occurs while loading.
-
commit
public void commit(boolean createBackup) throws EBaseExceptionDescription copied from interface:IConfigStoreStore config into storage (file or LDAP).- Specified by:
commitin interfaceIConfigStore- Parameters:
createBackup- true if a backup file should be created- Throws:
EBaseException- failed to commit
-
load
public void load(java.io.InputStream in) throws java.io.IOExceptionReads a config store from an input stream.- Specified by:
loadin interfaceIConfigStore- Parameters:
in- input stream where properties are located- Throws:
java.io.IOException- failed to load
-
store
public void store(java.io.OutputStream out) throws java.lang.ExceptionStores this config store to the specified output stream.- Specified by:
storein interfaceIConfigStore- Parameters:
out- outputstream where the properties are saved- Throws:
java.lang.Exception
-
getString
public java.lang.String getString(java.lang.String name) throws EBaseExceptionRetrieves a property value.- Specified by:
getStringin interfaceIConfigStore- Parameters:
name- property key- Returns:
- property value
- Throws:
EBaseException- failed to retrieve value
-
getString
public java.lang.String getString(java.lang.String name, java.lang.String defval) throws EBaseExceptionRetrieves a String from the configuration file.- Specified by:
getStringin interfaceIConfigStore- Parameters:
name- property namedefval- the default object to return if name does not exist- Returns:
- property value
- Throws:
EBaseException- If an internal error occurred
-
putString
public void putString(java.lang.String name, java.lang.String value)Puts property value into this configuration store.- Specified by:
putStringin interfaceIConfigStore- Parameters:
name- property keyvalue- property value
-
getByteArray
public byte[] getByteArray(java.lang.String name) throws EBaseExceptionRetrieves a byte array from the configuration file.- Specified by:
getByteArrayin interfaceIConfigStore- Parameters:
name- property name- Returns:
- property value
- Throws:
java.lang.IllegalArgumentException- if name is not set or is null.EPropertyNotFound- If the property is not presentEBaseException- If an internal error occurred
-
getByteArray
public byte[] getByteArray(java.lang.String name, byte[] defval) throws EBaseExceptionRetrieves a byte array from the configuration file.- Specified by:
getByteArrayin interfaceIConfigStore- Parameters:
name- property namedefval- 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(java.lang.String name, byte[] value)Puts byte array into this configuration store.- Specified by:
putByteArrayin interfaceIConfigStore- Parameters:
name- property keyvalue- byte array
-
getBoolean
public boolean getBoolean(java.lang.String name) throws EBaseExceptionRetrieves boolean-based property value.- Specified by:
getBooleanin interfaceIConfigStore- Parameters:
name- property key- Returns:
- boolean value
- Throws:
EBaseException- failed to retrieve
-
getBoolean
public boolean getBoolean(java.lang.String name, boolean defval) throws EBaseExceptionRetrieves boolean-based property value.- Specified by:
getBooleanin interfaceIConfigStore- Parameters:
name- property keydefval- default value- Returns:
- boolean value
- Throws:
EBaseException- failed to retrieve
-
putBoolean
public void putBoolean(java.lang.String name, boolean value)Puts boolean value into the configuration store.- Specified by:
putBooleanin interfaceIConfigStore- Parameters:
name- property keyvalue- property value
-
getInteger
public int getInteger(java.lang.String name) throws EBaseExceptionRetrieves integer value.- Specified by:
getIntegerin interfaceIConfigStore- Parameters:
name- property key- Returns:
- property value
- Throws:
EBaseException- failed to retrieve value
-
getInteger
public int getInteger(java.lang.String name, int defval) throws EBaseExceptionRetrieves integer value.- Specified by:
getIntegerin interfaceIConfigStore- Parameters:
name- property keydefval- default value- Returns:
- property value
- Throws:
EBaseException- failed to retrieve value
-
putInteger
public void putInteger(java.lang.String name, int val)Puts an integer value.- Specified by:
putIntegerin interfaceIConfigStore- Parameters:
name- property keyval- property value- Throws:
EBaseException- failed to retrieve value
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.String name) throws EBaseExceptionRetrieves big integer value.- Specified by:
getBigIntegerin interfaceIConfigStore- Parameters:
name- property key- Returns:
- property value
- Throws:
EBaseException- failed to retrieve value
-
getBigInteger
public java.math.BigInteger getBigInteger(java.lang.String name, java.math.BigInteger defval) throws EBaseExceptionRetrieves integer value.- Specified by:
getBigIntegerin interfaceIConfigStore- Parameters:
name- property keydefval- default value- Returns:
- property value
- Throws:
EBaseException- failed to retrieve value
-
putBigInteger
public void putBigInteger(java.lang.String name, java.math.BigInteger val)Puts a big integer value.- Specified by:
putBigIntegerin interfaceIConfigStore- Parameters:
name- property keyval- default value
-
makeSubStore
public IConfigStore makeSubStore(java.lang.String name)
Creates a new sub store.- Specified by:
makeSubStorein interfaceIConfigStore- Parameters:
name- substore name- Returns:
- substore
-
removeSubStore
public void removeSubStore(java.lang.String name)
Removes a sub store.- Specified by:
removeSubStorein interfaceIConfigStore- Parameters:
name- substore name
-
getSubStore
public IConfigStore getSubStore(java.lang.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:
getSubStorein interfaceIConfigStore- Parameters:
name- substore name- Returns:
- substore
-
getSubStore
public <T extends IConfigStore> T getSubStore(java.lang.String name, java.lang.Class<T> clazz)
- Specified by:
getSubStorein interfaceIConfigStore
-
getPropertyNames
public java.util.Enumeration<java.lang.String> getPropertyNames()
Retrieves a list of property names.- Specified by:
getPropertyNamesin interfaceIConfigStore- Returns:
- a list of string-based property names
-
getSubStoreNames
public java.util.Enumeration<java.lang.String> getSubStoreNames()
Returns a list of sub store names.- Specified by:
getSubStoreNamesin interfaceIConfigStore- 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 java.lang.String getFullName(java.lang.String name)
Converts the substore parameters.- Parameters:
name- property name- Returns:
- fill property name
-
clone
public java.lang.Object clone()
Cloning of property configuration store.- Overrides:
clonein classjava.lang.Object- Returns:
- a new configuration store
-
-