Package com.netscape.cmscore.base
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
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.Logger
protected SimpleProperties
The source data for this substoreprotected String
The name of this substoreprotected static final String
protected ConfigStorage
-
Constructor Summary
ConstructorsModifierConstructorDescriptionPropConfigStore
(ConfigStorage storage) PropConfigStore
(String storeName) Constructs a property configuration store.protected
PropConfigStore
(String name, SimpleProperties source) Constructs a configuration store. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the config store.clone()
Cloning of property configuration store.void
commit
(boolean createBackup) Store config into storage (file or LDAP).Retrieves a property from the configuration file.getBigInteger
(String name) Retrieves big integer value.getBigInteger
(String name, BigInteger defval) Retrieves integer value.boolean
getBoolean
(String name) Retrieves boolean-based property value.boolean
getBoolean
(String name, boolean defval) Retrieves boolean-based property value.byte[]
getByteArray
(String name) Retrieves a byte array from the configuration file.byte[]
getByteArray
(String name, byte[] defval) Retrieves a byte array from the configuration file.protected String
getFullName
(String name) Converts the substore parameters.int
getInteger
(String name) Retrieves integer value.int
getInteger
(String name, int defval) Retrieves integer value.getName()
Returns the name of this store.Retrieves lexicographically sorted properties as a map.Retrieves a list of property names.Retrieves the source configuration store where the properties are stored.Retrieves a property value.Retrieves a String from the configuration file.getSubStore
(String name) Retrieves a sub store.<T extends IConfigStore>
TgetSubStore
(String name, Class<T> clazz) Returns a list of sub store names.keys()
Returns an enumeration of the config store's keys, hidding the store name.void
load()
Load config from storage storage (file or LDAP).void
load
(InputStream in) Reads a config store from an input stream.makeSubStore
(String name) Creates a new sub store.void
For debugging purposes.Puts a property into the configuration file.void
putBigInteger
(String name, BigInteger val) Puts a big integer value.void
putBoolean
(String name, boolean value) Puts boolean value into the configuration store.void
putByteArray
(String name, byte[] value) Puts byte array into this configuration store.void
putInteger
(String name, int val) Puts an integer value.void
Puts property value into this configuration store.void
Removes a property from the configuration file.void
removeSubStore
(String name) Removes a sub store.int
size()
Return the number of items in this substorevoid
store
(OutputStream out) Stores this config store to the specified output stream.
-
Field Details
-
logger
public static final org.slf4j.Logger logger -
PROP_SUBSTORES
- See Also:
-
mStoreName
The name of this substore -
mSource
The source data for this substore -
storage
-
-
Constructor Details
-
PropConfigStore
public PropConfigStore() -
PropConfigStore
-
PropConfigStore
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
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 namesource
- list of properties- Throws:
EBaseException
- failed to create configuration
-
-
Method Details
-
getName
Returns the name of this store.- Specified by:
getName
in interfaceIConfigStore
- Returns:
- store name
-
getStorage
-
get
Retrieves a property from the configuration file.- Specified by:
get
in interfaceIConfigStore
- Parameters:
name
- property name- Returns:
- property value
-
put
Puts a property into the configuration file. The values wont be updated to the file until save method is invoked.- Specified by:
put
in interfaceIConfigStore
- Parameters:
name
- property namevalue
- property value
-
remove
Removes a property from the configuration file.- Specified by:
remove
in interfaceIConfigStore
- Parameters:
name
- property name
-
keys
Returns an enumeration of the config store's keys, hidding the store name.- Specified by:
keys
in interfaceIConfigStore
- Returns:
- a list of keys
- See Also:
-
getProperties
Retrieves lexicographically sorted properties as a map.- Specified by:
getProperties
in interfaceIConfigStore
- Returns:
- map
-
size
public int size()Return the number of items in this substore- Specified by:
size
in interfaceIConfigStore
-
clear
public void clear()Description copied from interface:IConfigStore
Clear the config store.- Specified by:
clear
in interfaceIConfigStore
-
load
Description copied from interface:IConfigStore
Load config from storage storage (file or LDAP).- Specified by:
load
in interfaceIConfigStore
- Throws:
Exception
- If an error occurs while loading.
-
commit
Description copied from interface:IConfigStore
Store config into storage (file or LDAP).- Specified by:
commit
in interfaceIConfigStore
- Parameters:
createBackup
- true if a backup file should be created- Throws:
EBaseException
- failed to commit
-
load
Reads a config store from an input stream.- Specified by:
load
in interfaceIConfigStore
- Parameters:
in
- input stream where properties are located- Throws:
IOException
- failed to load
-
store
Stores this config store to the specified output stream.- Specified by:
store
in interfaceIConfigStore
- Parameters:
out
- outputstream where the properties are saved- Throws:
Exception
-
getString
Retrieves a property value.- Specified by:
getString
in interfaceIConfigStore
- Parameters:
name
- property key- Returns:
- property value
- Throws:
EBaseException
- failed to retrieve value
-
getString
Retrieves a String from the configuration file.- Specified by:
getString
in 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
Puts property value into this configuration store.- Specified by:
putString
in interfaceIConfigStore
- Parameters:
name
- property keyvalue
- property value
-
getByteArray
Retrieves a byte array from the configuration file.- Specified by:
getByteArray
in interfaceIConfigStore
- Parameters:
name
- property name- Returns:
- property value
- Throws:
IllegalArgumentException
- if name is not set or is null.EBaseException
- If an internal error occurred
-
getByteArray
Retrieves a byte array from the configuration file.- Specified by:
getByteArray
in 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
Puts byte array into this configuration store.- Specified by:
putByteArray
in interfaceIConfigStore
- Parameters:
name
- property keyvalue
- byte array
-
getBoolean
Retrieves boolean-based property value.- Specified by:
getBoolean
in interfaceIConfigStore
- Parameters:
name
- property key- Returns:
- boolean value
- Throws:
EBaseException
- failed to retrieve
-
getBoolean
Retrieves boolean-based property value.- Specified by:
getBoolean
in interfaceIConfigStore
- Parameters:
name
- property keydefval
- default value- Returns:
- boolean value
- Throws:
EBaseException
- failed to retrieve
-
putBoolean
Puts boolean value into the configuration store.- Specified by:
putBoolean
in interfaceIConfigStore
- Parameters:
name
- property keyvalue
- property value
-
getInteger
Retrieves integer value.- Specified by:
getInteger
in interfaceIConfigStore
- Parameters:
name
- property key- Returns:
- property value
- Throws:
EBaseException
- failed to retrieve value
-
getInteger
Retrieves integer value.- Specified by:
getInteger
in interfaceIConfigStore
- Parameters:
name
- property keydefval
- default value- Returns:
- property value
- Throws:
EBaseException
- failed to retrieve value
-
putInteger
Puts an integer value.- Specified by:
putInteger
in interfaceIConfigStore
- Parameters:
name
- property keyval
- property value- Throws:
EBaseException
- failed to retrieve value
-
getBigInteger
Retrieves big integer value.- Specified by:
getBigInteger
in interfaceIConfigStore
- Parameters:
name
- property key- Returns:
- property value
- Throws:
EBaseException
- failed to retrieve value
-
getBigInteger
Retrieves integer value.- Specified by:
getBigInteger
in interfaceIConfigStore
- Parameters:
name
- property keydefval
- default value- Returns:
- property value
- Throws:
EBaseException
- failed to retrieve value
-
putBigInteger
Puts a big integer value.- Specified by:
putBigInteger
in interfaceIConfigStore
- Parameters:
name
- property keyval
- default value
-
makeSubStore
Creates a new sub store.- Specified by:
makeSubStore
in interfaceIConfigStore
- Parameters:
name
- substore name- Returns:
- substore
-
removeSubStore
Removes a sub store.- Specified by:
removeSubStore
in interfaceIConfigStore
- Parameters:
name
- substore name
-
getSubStore
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 interfaceIConfigStore
- Parameters:
name
- substore name- Returns:
- substore
-
getSubStore
- Specified by:
getSubStore
in interfaceIConfigStore
-
getPropertyNames
Retrieves a list of property names.- Specified by:
getPropertyNames
in interfaceIConfigStore
- Returns:
- a list of string-based property names
-
getSubStoreNames
Returns a list of sub store names.- Specified by:
getSubStoreNames
in interfaceIConfigStore
- Returns:
- list of substore names
-
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
-
clone
-