com.sourceforge.jpatterns.core.configuration
Class JPConfiguratorImpl

java.lang.Object
  extended by com.sourceforge.jpatterns.core.configuration.JPConfiguratorImpl
All Implemented Interfaces:
IJPConfigurator

public class JPConfiguratorImpl
extends Object
implements IJPConfigurator

The default implementation of the IJPConfiguration interface.
The instance we need to use is configured at the properties file, so there is a way for the developer to override this implementation by the custom one.
Be noticed the consumer custom dir could be rather complicated: use the System.getProperty(PATH_SEPARATOR_KEY) to specify the complicated pathes. it could be provided using JVM parameter (first priority) and props key/value (the second priority). Please review the following constants to be involved into it: com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_PROPS_PARAM
Please review the following Java Docs to understand the concepts of overriding: com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML todo: [zmicer] add the possibility to set the values for the custom framework/consumer configuration at the properties file.
note [zmicer]: please review the class members - there are lots of them, they are necessary for the storing the information we may be intersted in the future - so we would be able easily to extend the interface with another method. todo [zmicer]: please reconsider the interface IJPConfigurator methods - seems to be some of them are not necessary. note [zmicer]: check if it is possible to make the reload of the JPatterns configuration on the flight? It could be really necessary for the building some web services related functionality (when the configuration is specified and provided by the web service, and we need to shedule the reloading). $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
JPConfiguratorImpl()
          Default public constructor to allow this functionality to be consructed using the factory and IoC.
 
Method Summary
 boolean customJPatternsConsumerConfigurationPresents()
           
 boolean customJPatternsFrameworkConfigurationPresents()
           
 boolean defaultJPatternsConsumerConfigurationPresents()
           
 boolean defaultJPatternsFrameworkConfigurationPresents()
           
 JPatternsConfigsBean getJPatternsConsumerConfiguration()
           
 String getJPatternsConsumerConfigurationDirName()
          The first priority takes the JVM parameter, then - the properties file value.
 List<File> getJPatternsConsumerConfigurationFiles()
           
 String getJPatternsConsumerCustomConfigurationDirName()
          The first priority takes the JVM parameter, then - the properties file value.
 List<File> getJPatternsConsumerCustomConfigurationFiles()
           
 JPatternsConfigsBean getJPatternsFrameworkConfiguration()
           
 String getJPatternsFrameworkConfigurationFileName()
           
 String getJPatternsFrameworkCustomConfigurationFileName()
           
protected  void initConfiguration()
          Init xml configuration.
protected  void initConsumerConfiguration()
          Init (obtain, merge etc.) the consumer based configuration.
protected  void initFrameworkConfiguration()
          Init the framework configuration.
protected  void mergeConsumerConfigurations()
          Perform the merging of the consumer configurations.
protected  void mergeFrameworkConfigurations()
          Perform the merging of the framework configurations.
protected  JPatternsConfigBean obtainJPatternsConfig(String name)
          Obtain the JPatternsConfig using the provided file name (it could be: 1. just file name without passes, 2. the full file name 3. relative name)
The following order for obtaining this JPatternsConfig class is used: Using the classloaders Trying to open the file with the provided name using File
protected  List<com.sourceforge.jpatterns.schema.JPatternsConfig> obtainJPatternsConfigs(List<File> files)
          Obtain the List of JPatternsConfig objects by the List of the File objects specified.
protected static void setUseOnlyCustomFrameworkConfigIfPresent(Boolean value)
          Set the value for the property useOnlyCustomFrameworkConfigIfPresent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Logger instance.

Constructor Detail

JPConfiguratorImpl

public JPConfiguratorImpl()
Default public constructor to allow this functionality to be consructed using the factory and IoC.
The constructor is public to allow instantiating the JPCOnfigurationImpl using the properties files todo [zmicer]: think if this is correct way to initialize the configuration. The init method is not defined at the interface. Also this class could not be called "strong" singleton implementation, so there are ways to hack it. Please investigate and adjust.

Method Detail

initConfiguration

protected void initConfiguration()
Init xml configuration. Please be noticed it is called at the construction time. So it should initialize all the fields of this class before starting using other methods.


initFrameworkConfiguration

protected void initFrameworkConfiguration()
Init the framework configuration.


mergeFrameworkConfigurations

protected void mergeFrameworkConfigurations()
Perform the merging of the framework configurations.
the following rules have power here: 1. in the case custom configuration is not present the default configuration would be used as the merged one. 2. in the case default configuration is not present - the exception appeared. 3. in the case both configurations present and the value of the property com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML is true - the custom configuration is used as the merged one. 4. in the case the property is not defined - we consider its value is false com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML 5. in the case both configurations present and the value of the property com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML is false - configurations are merged using the implementation of the JPatternsConfigBeansBuilder.


initConsumerConfiguration

protected void initConsumerConfiguration()
Init (obtain, merge etc.) the consumer based configuration.
Be noticed the consumer custom dir could be rather complicated: use the System.getProperty(PATH_SEPARATOR_KEY) to specify the complicated pathes. todo [zmicer]: implement the opportunity to set the directory where the default JPatterns consumer configuration to obtain


mergeConsumerConfigurations

protected void mergeConsumerConfigurations()
Perform the merging of the consumer configurations.
the following rules have power here: 1. in the case custom configuration is not present the default configuration would be used as the merged one. 2. in the case default configuration is not present - the exception appeared. 3. in the case both configurations present and the value of the property com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML is true - the custom configuration is used as the merged one. 4. in the case the property is not defined - we consider its value is false com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML 5. in the case both configurations present and the value of the property com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML is false - configurations are merged using the implementation of the JPatternsConfigBeansBuilder.


obtainJPatternsConfigs

protected List<com.sourceforge.jpatterns.schema.JPatternsConfig> obtainJPatternsConfigs(List<File> files)
Obtain the List of JPatternsConfig objects by the List of the File objects specified.

Parameters:
files - the List of the File objects Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the List of JPatternsConfig objects

obtainJPatternsConfig

protected JPatternsConfigBean obtainJPatternsConfig(String name)
Obtain the JPatternsConfig using the provided file name (it could be: 1. just file name without passes, 2. the full file name 3. relative name)
The following order for obtaining this JPatternsConfig class is used:

Parameters:
name - the name of the file to be obtain. Can not be null (otherwise IllegalArgumentException would appear).
Returns:
the castor JPatternsConfig woth the settings we need for the further working.

getJPatternsFrameworkConfigurationFileName

public String getJPatternsFrameworkConfigurationFileName()
Specified by:
getJPatternsFrameworkConfigurationFileName in interface IJPConfigurator
Returns:
the name of the configuration file is used for the configuration of the working JPatterns itself
Please review the Java Docs of the concrete implementation to obtain the algorithms for getting this name.
See Also:

The way this name is obtained: 1. In the case JVM parameter is specified - it is returns. Please be noticed the JVM parameter could specify both file name and full pathed file name todo [zmicer]: check if this item is fully supported here. 2. Then the properties based value is checked. JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM 3. Then the default name {@link JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME} is returned.

getJPatternsFrameworkCustomConfigurationFileName

public String getJPatternsFrameworkCustomConfigurationFileName()
Specified by:
getJPatternsFrameworkCustomConfigurationFileName in interface IJPConfigurator
Returns:
the name of the configuration file is used for the configuration of the working JPatterns itself (custom configuration) Returns the custom configuration.
See Also:

Take an attention at this above method: getJPatternsFrameworkConfigurationFileName

getJPatternsConsumerConfigurationFiles

public List<File> getJPatternsConsumerConfigurationFiles()
Specified by:
getJPatternsConsumerConfigurationFiles in interface IJPConfigurator
Returns:
the List of String objects representing the configuration file names is provided by the consumers of the JPatterns (simply speaking the configuration of the third party factories, and another patterns, the configuration which is necessary to be parsed by JPatterns to make this framework help other developers - consumers of the framework)
See Also:
IJPConfigurator.getJPatternsConsumerConfigurationFiles()

getJPatternsConsumerCustomConfigurationFiles

public List<File> getJPatternsConsumerCustomConfigurationFiles()
Specified by:
getJPatternsConsumerCustomConfigurationFiles in interface IJPConfigurator
Returns:
the List of String objects representing the configuration file names is provided by the consumers of the JPatterns (simply speaking the configuration of the third party factories, and another patterns, the configuration which is necessary to be parsed by JPatterns to make this framework help other developers - consumers of the framework).
Returns the custom configuration.
See Also:
IJPConfigurator.getJPatternsConsumerCustomConfigurationFiles()

getJPatternsConsumerCustomConfigurationDirName

public String getJPatternsConsumerCustomConfigurationDirName()
The first priority takes the JVM parameter, then - the properties file value.
Please be noticed this string could be either dir or the list of dirs or the list of dirs and xml files. Please review the com.zmicer.utils.ClassPathUtils#getClassPathes() for it. Also com.zmicer.utils.FileUtils#findFilesByREInClassPath(java.util.List, java.util.regex.Pattern) could help in providing the info.

Returns:
the String value pointing to the dir where the consumer specific custom configuration (not the xml pointed at the classpath) are present.

getJPatternsConsumerConfigurationDirName

public String getJPatternsConsumerConfigurationDirName()
The first priority takes the JVM parameter, then - the properties file value.
Please be noticed this string could be either dir or the list of dirs or the list of dirs and xml files. Please review the com.zmicer.utils.ClassPathUtils#getClassPathes() for it. Also com.zmicer.utils.FileUtils#findFilesByREInClassPath(java.util.List, java.util.regex.Pattern) could help in providing the info.

Returns:
the String value pointing to the dir where the consumer specific custom configuration (not the xml pointed at the classpath) are present.

defaultJPatternsFrameworkConfigurationPresents

public boolean defaultJPatternsFrameworkConfigurationPresents()
Specified by:
defaultJPatternsFrameworkConfigurationPresents in interface IJPConfigurator
Returns:
true in the case the default XML framework configuration is presents.
See Also:
IJPConfigurator.defaultJPatternsFrameworkConfigurationPresents()

customJPatternsFrameworkConfigurationPresents

public boolean customJPatternsFrameworkConfigurationPresents()
Specified by:
customJPatternsFrameworkConfigurationPresents in interface IJPConfigurator
Returns:
true in the case the system custom configuration is presents (the value was provided via the JVM parameter using the com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM or this file with the name com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME exists)
See Also:
IJPConfigurator.customJPatternsConsumerConfigurationPresents()

defaultJPatternsConsumerConfigurationPresents

public boolean defaultJPatternsConsumerConfigurationPresents()
Specified by:
defaultJPatternsConsumerConfigurationPresents in interface IJPConfigurator
Returns:
true in the case the default XML framework configuration is presents.
See Also:
IJPConfigurator.defaultJPatternsConsumerConfigurationPresents()

customJPatternsConsumerConfigurationPresents

public boolean customJPatternsConsumerConfigurationPresents()
Specified by:
customJPatternsConsumerConfigurationPresents in interface IJPConfigurator
Returns:
true in the case the system custom configuration is presents (the value was provided via the JVM parameter using the com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM or this file with the name com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME exists)
See Also:
IJPConfigurator.customJPatternsConsumerConfigurationPresents()

getJPatternsFrameworkConfiguration

public JPatternsConfigsBean getJPatternsFrameworkConfiguration()
Specified by:
getJPatternsFrameworkConfiguration in interface IJPConfigurator
Returns:
the entry point for the system configuration is used for the JPatterns itself.
Please be noticed this configuration is a merged one: the default and custom configuration are used
See Also:
IJPConfigurator.getJPatternsFrameworkConfiguration()

getJPatternsConsumerConfiguration

public JPatternsConfigsBean getJPatternsConsumerConfiguration()
Specified by:
getJPatternsConsumerConfiguration in interface IJPConfigurator
Returns:
the JPatternsConfig storing all the users configuration.
Please be noticed this configuration is a merged one: the default and custom configuration files are used (there are lots of the configurations files could be at the default pathes and at the custom specific pathes)
See Also:
IJPConfigurator.getJPatternsConsumerConfiguration()

setUseOnlyCustomFrameworkConfigIfPresent

protected static void setUseOnlyCustomFrameworkConfigIfPresent(Boolean value)
Set the value for the property useOnlyCustomFrameworkConfigIfPresent

Parameters:
value - the value to be set to this property. Could be null - it means that the property is not defined at all.


Copyright © 2007 jzmicer.team. All Rights Reserved.