|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sourceforge.jpatterns.core.configuration.PropertiesManagerImpl
public class PropertiesManagerImpl
This class manages deals with the properties files JPatterns uses.
Please do not put here any functionality which could be customizable later. Only the functionality fitting the approach:
we have default and custom properties files which are taken from the classpath. In the case custom configuration contains the same
keys - they would override the default configuration.
Potentially the part of this PropertyManager could be used at the JInit.
Please be noticed the very important method is the following:
com.sourceforge.jpatterns.core.configuration.PropertiesManagerImpl#getBundle(java.lang.String)
, and this method
firstly checks the default configuration, and then checks the overriden, custom configuration.
todo [zmicer]: think if this could be moved to the common functionality. Think over the PropertiesProvider class - why do we really need\
two these classes? Please finish investigating.
todo [zmicer]: introduce the opportunity to setup the necessary names from outside - it would allow us to use this approach as the common
functionality.
todo [zmicer]: please check in which way the is used here: 0001\src\testdata\jpatterns_custom.properties
$Author:: zmicer $
$Rev:: 67 $
* $Date:: 2007-08-28 21:37:07 #$
$Date:: 2007-08-28 21:37:07 #$
Field Summary | |
---|---|
static org.apache.log4j.Logger |
LOG
Logger instance. |
Constructor Summary | |
---|---|
PropertiesManagerImpl()
The reason this class has the constructor and implements "singleton" - we are worrying if we need interface for it later. |
Method Summary | |
---|---|
protected void |
checkIsInitialized()
Perform the check if the functionality was initialized. |
boolean |
customConfigPresents()
|
boolean |
defaultConfigPresents()
|
String |
getBundle(Class key)
Get bundle for the provided key - it is a class. |
String |
getBundle(String key)
Return the bundle value using the ResourceBundle already retrieved. |
Object |
getBundledObject(Class key)
Get bundled object by the key provided. |
Object |
getBundledObject(String key)
Get bundled object by the String key provided. |
String |
getCustomBundle(String key)
Get the value from the custom bundle. this was provided in any case - potentially it could be used at the unit tests etc. |
String |
getDefaultBundle(String key)
Get the value from the default bundle. this was provided in any case - potentially it could be used at the unit tests etc. |
Set<String> |
getMergedKeys()
|
void |
initConfigs()
Init the resource bundles configuration (methods getDefaultBundleFileName and getCustomBundleFileName are used
for the retrieving the actual nname of the properties to be obtained during the initialization process)
Protected to allow to cover that with the unit tests |
protected void |
initUseOnlyCustomConfigIfPresent()
Initialize the useOnlyCustomPropsIfPresent field. |
boolean |
useOnlyCustomConfigIfPresent()
This method returns the value of the props signing if custom properties file totally overrides the default, and if it is present, then the values from the default properties are not used at all. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.log4j.Logger LOG
Constructor Detail |
---|
public PropertiesManagerImpl()
Method Detail |
---|
protected void checkIsInitialized()
IllegalStateException
in the case the functionality
was not intialized. Should be used for all the "state read/write" methods just to be sure all is ok.
public void initConfigs()
getDefaultBundleFileName and getCustomBundleFileName
are used
for the retrieving the actual nname of the properties to be obtained during the initialization process)
public boolean customConfigPresents()
customConfigPresents
in interface IPropertiesManager
IPropertiesManager.customConfigPresents()
public boolean defaultConfigPresents()
defaultConfigPresents
in interface IPropertiesManager
IPropertiesManager.defaultConfigPresents()
public boolean useOnlyCustomConfigIfPresent()
IPropertiesManager
com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_PROPERTIES
useOnlyCustomConfigIfPresent
in interface IPropertiesManager
IPropertiesManager.useOnlyCustomConfigIfPresent()
protected void initUseOnlyCustomConfigIfPresent()
public String getBundle(String key)
IPropertiesManager
getBundle
in interface IPropertiesManager
key
- for the value we need. Can not be null (otherwise IllegalArgumentException
would appear).
IPropertiesManager.getBundle(java.lang.String)
public String getBundle(Class key)
IPropertiesManager
getBundle
in interface IPropertiesManager
key
- for the value we need, Class object. Can not be null (otherwise IllegalArgumentException
would appear).
IPropertiesManager.getBundle(Class)
public Object getBundledObject(Class key)
IPropertiesManager
JPConfigException
would appear.
getBundledObject
in interface IPropertiesManager
key
- the class for which we should obtain appropriate implementation (usually it is class of the interface of abstract class
implementation of which we would obtain.)
IPropertiesManager.getBundledObject(Class)
public Object getBundledObject(String key)
IPropertiesManager
JPConfigException
would appear.
getBundledObject
in interface IPropertiesManager
key
- the class for which we should obtain appropriate implementation (usually it is String - base name of the interface of
abstract class implementation of which we would obtain.)
IPropertiesManager.getBundledObject(String)
public String getDefaultBundle(String key)
IPropertiesManager
getDefaultBundle
in interface IPropertiesManager
key
- to be processed. Can not be null (otherwise IllegalArgumentException
would appear).
IPropertiesManager.getDefaultBundle(java.lang.String)
public String getCustomBundle(String key)
IPropertiesManager
getCustomBundle
in interface IPropertiesManager
key
- to be processed. Can not be null (otherwise IllegalArgumentException
would appear).
IPropertiesManager.getCustomBundle(java.lang.String)
public Set<String> getMergedKeys()
getMergedKeys
in interface IPropertiesManager
com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_PROPERTIES
)
todo: [zmicer] think over the caching these values between the initialization periods - just to increase the performance of the
framework initialization!
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |