Clover coverage report - Maven Clover report
Coverage timestamp: Mon Sep 3 2007 08:24:07 EEST
file stats: LOC: 638   Methods: 21
NCLOC: 363   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JPConfiguratorImpl.java 57.1% 79.3% 95.2% 74.5%
coverage coverage
 1    package com.sourceforge.jpatterns.core.configuration;
 2   
 3    import com.sourceforge.jpatterns.core.JPConstants;
 4    import com.sourceforge.jpatterns.core.configuration.exceptions.JPInitializationException;
 5    import com.sourceforge.jpatterns.core.configuration.model.IJPatternsConfigBeansBuilder;
 6    import com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigBaseBean;
 7    import com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigBean;
 8    import com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigsBean;
 9    import com.sourceforge.jpatterns.schema.JPatternsConfig;
 10    import com.sourceforge.jpatterns.utils.CastorUtils;
 11    import com.zmicer.utils.ClassPathUtils;
 12    import com.zmicer.utils.FileUtils;
 13    import com.zmicer.utils.InputArgumentUtils;
 14    import com.zmicer.utils.ResourceUtils;
 15    import org.apache.log4j.Logger;
 16   
 17    import java.io.File;
 18    import java.net.URL;
 19    import java.util.ArrayList;
 20    import java.util.List;
 21   
 22    /**
 23    * The default implementation of the <code>IJPConfiguration</code> interface.
 24    * <br/>
 25    * The instance we need to use is configured at the
 26    * properties file, so there is a way for the developer to override this implementation by the custom one.
 27    * <br/>
 28    * Be noticed the consumer custom dir could be rather complicated: use the
 29    * <code>System.getProperty(PATH_SEPARATOR_KEY)</code> to specify the complicated pathes. it could be provided using JVM parameter (first
 30    * priority) and props key/value (the second priority). Please review the following constants to be involved into it:
 31    * {@link com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM}
 32    * {@link com.sourceforge.jpatterns.core.JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_PROPS_PARAM}
 33    * <br/>
 34    * Please review the following Java Docs to understand the concepts of overriding:
 35    * {@link com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML}
 36    * {@link com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML}
 37    * todo: [zmicer] add the possibility to set the values for the custom framework/consumer configuration at the properties file.
 38    *
 39    * <br/>
 40    * note [zmicer]: please review the class members - there are lots of them, they are necessary for the storing the information we may be
 41    * intersted in the future - so we would be able easily to extend the interface with another method.
 42    * todo [zmicer]: please reconsider the interface <code>IJPConfigurator</code> methods - seems to be some of them are not necessary.
 43    *
 44    * note [zmicer]: check if it is possible to make the reload of the JPatterns configuration on the flight? It could be really necessary for
 45    * the building some web services related functionality (when the configuration is specified and provided by the web service, and we need
 46    * to shedule the reloading).
 47    *
 48    * $Author:: zmicer $<br/>
 49    * $Rev:: 67 $<br/> * $Date:: 2007-08-28 21:37:07 #$<br/>
 50    * $Date:: 2007-08-28 21:37:07 #$<br/>
 51    */
 52    public class JPConfiguratorImpl implements IJPConfigurator
 53    {
 54    /**
 55    * Logger instance.
 56    */
 57    final public static Logger LOG = Logger.getLogger(JPConfiguratorImpl.class);
 58   
 59    /**
 60    * The castor based bean stored the configuration of the framework itself (default configuration).
 61    */
 62    private JPatternsConfigBean m_defaultFrameworkConfig = null;
 63   
 64    /**
 65    * The castor based bean stored the configuration of the framework itself (custom configuration).
 66    * <br/>
 67    * We are storing both configurations for the following reasons:
 68    * 1. potentially methods could be added are able to deal with the both configurations
 69    * 2. unit tests for the JPCOnfigurationImpl would use this functionality to check everything properly
 70    */
 71    private JPatternsConfigBean m_customFrameworkConfig = null;
 72   
 73    /**
 74    * The castor based bean stored the configuration of the framework itself (merged configuration).
 75    */
 76    private JPatternsConfigsBean m_mergedFrameworkConfig = null;
 77   
 78    /**
 79    * The castor based bean stored the configuration of the consumer settings themself (merged default configuration).
 80    * <br/>
 81    * One instance of JPatternsConfig - includes all the settings from {@link m_defaultConsumerConfigs}
 82    */
 83    private JPatternsConfigsBean m_mergedDefaultConsumerConfig = null;
 84   
 85    /**
 86    * The castor based bean stores the configuration of the consumer settings themself (merged custom configuration).
 87    * <br/>
 88    * One instance of JPatternsConfig - includes all the settings from {@link m_customConsumerConfigs}
 89    */
 90    private JPatternsConfigsBean m_mergedCustomConsumerConfig = null;
 91   
 92    /**
 93    * Merged consumer config ready to be used.
 94    */
 95    private JPatternsConfigsBean m_mergedConsumerConfig = null;
 96   
 97    /**
 98    * Stores the List of the String object - names of the consumer configuration XML files names. It was decided to store this in any case
 99    * (could be useful for tests and debugging of the framework)
 100    */
 101    private List<File> m_consumerConfigurationFiles = new ArrayList<File>();
 102   
 103    /**
 104    * Stores the List of the String object - names of the consumer configuration XML files names. It was decided to store this in any case
 105    * (could be useful for tests and debugging of the framework)
 106    */
 107    private List<File> m_consumerConfigurationCustomFiles = new ArrayList<File>();
 108   
 109    /**
 110    * The value of the property useOnlyCustomFrameworkConfigIfPresent
 111    */
 112    private static Boolean useOnlyCustomFrameworkConfigIfPresent = null;
 113   
 114    /**
 115    * The value of the property useOnlyCustomConsumerConfigIfPresent
 116    */
 117    private static Boolean useOnlyCustomConsumerConfigIfPresent = null;
 118   
 119    /**
 120    * Default public constructor to allow this functionality to be consructed using the factory and IoC.
 121    * <br/>
 122    * The constructor is public to allow instantiating the JPCOnfigurationImpl using the properties files
 123    *
 124    * todo [zmicer]: think if this is correct way to initialize the configuration. The init method is not defined at the interface.
 125    * Also this class could not be called "strong" singleton implementation, so there are ways to hack it. Please investigate and adjust.
 126    */
 127  30 public JPConfiguratorImpl()
 128    {
 129  30 super();
 130  30 initConfiguration();
 131    }
 132   
 133    /**
 134    * Init xml configuration. Please be noticed it is called at the construction time. So it should initialize all the fields of this class
 135    * before starting using other methods.
 136    *
 137    */
 138  33 protected void initConfiguration()
 139    {
 140    // init static fields we would use later for determining the behaviour of the JPConfiguratorImpl
 141  33 final IPropertiesManager manager = PropertiesBasedFactory.getInstance().getPropertiesManager();
 142  33 final PropertiesProvider propsProvider = PropertiesProvider.getInstance(manager, false);
 143  33 useOnlyCustomFrameworkConfigIfPresent =
 144    propsProvider.getBooleanProperty(PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML);
 145  33 useOnlyCustomConsumerConfigIfPresent =
 146    propsProvider.getBooleanProperty(PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML);
 147   
 148  33 initFrameworkConfiguration();
 149  33 initConsumerConfiguration();
 150    }
 151   
 152    /**
 153    * Init the framework configuration.
 154    */
 155  38 protected void initFrameworkConfiguration()
 156    {
 157  38 m_defaultFrameworkConfig = obtainJPatternsConfig(getJPatternsFrameworkConfigurationFileName());
 158  38 m_customFrameworkConfig = obtainJPatternsConfig(getJPatternsFrameworkCustomConfigurationFileName());
 159  38 mergeFrameworkConfigurations();
 160    }
 161   
 162    /**
 163    * Perform the merging of the framework configurations.
 164    * <br/>
 165    * the following rules have power here:
 166    * 1. in the case custom configuration is not present the default configuration would be used as the merged one.
 167    * 2. in the case default configuration is not present - the exception appeared.
 168    * 3. in the case both configurations present and the value of the property
 169    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML</code> is true -
 170    * the custom configuration is used as the merged one.
 171    * 4. in the case the property is not defined - we consider its value is <code>false</code>
 172    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML</code>
 173    * 5. in the case both configurations present and the value of the property
 174    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML</code> is
 175    * <code>false</code> - configurations are merged using the implementation of the JPatternsConfigBeansBuilder.
 176    */
 177  38 protected void mergeFrameworkConfigurations()
 178    {
 179  38 final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder();
 180    // 01:
 181  38 if (!defaultJPatternsFrameworkConfigurationPresents())
 182    {
 183  1 throw new IllegalStateException("The default framework configuration should be present.");
 184    }
 185  37 if (!customJPatternsFrameworkConfigurationPresents())
 186    {
 187  20 if (defaultJPatternsFrameworkConfigurationPresents())
 188    {
 189  20 final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>();
 190  20 beans.add(m_defaultFrameworkConfig);
 191  20 m_mergedFrameworkConfig = builder.build(beans);
 192  20 return;
 193    }
 194    else
 195    {
 196    // 02:
 197  0 throw new IllegalStateException("The default framework configuration should be present.");
 198    }
 199    }
 200    // 03:
 201  17 if (customJPatternsFrameworkConfigurationPresents() && defaultJPatternsFrameworkConfigurationPresents() &&
 202    null != useOnlyCustomFrameworkConfigIfPresent && useOnlyCustomFrameworkConfigIfPresent)
 203    {
 204  1 final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>();
 205  1 beans.add(m_customFrameworkConfig);
 206  1 m_mergedFrameworkConfig = builder.build(beans);
 207  1 return;
 208    }
 209    // 04, 05:
 210  16 if ((null != useOnlyCustomFrameworkConfigIfPresent && !useOnlyCustomFrameworkConfigIfPresent) ||
 211    null == useOnlyCustomFrameworkConfigIfPresent)
 212    {
 213    // need to merge the properties. The custom one would override the default framework configuration.
 214  16 CastorUtils.makePrioritized(m_customFrameworkConfig.getCastorConfig());
 215  16 final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>();
 216  16 beans.add(m_customFrameworkConfig);
 217  16 beans.add(m_defaultFrameworkConfig);
 218  16 m_mergedFrameworkConfig = builder.build(beans);
 219    }
 220    }
 221   
 222    /**
 223    * Init (obtain, merge etc.) the consumer based configuration.
 224    * <br/>
 225    * Be noticed the consumer custom dir could be rather complicated: use the
 226    * <code>System.getProperty(PATH_SEPARATOR_KEY)</code> to specify the complicated pathes.
 227    * todo [zmicer]: implement the opportunity to set the directory where the default JPatterns consumer configuration to obtain
 228    */
 229  36 protected void initConsumerConfiguration()
 230    {
 231  36 final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder();
 232    // the todo above placement.
 233    // 00: init the consumer default configuration (was found at the classpath)
 234  36 final String defaultConsumerDir = getJPatternsConsumerConfigurationDirName();
 235  36 List<String> classPathesStrings = null;
 236  36 if (null != defaultConsumerDir && defaultConsumerDir.length() != 0)
 237    {
 238  36 classPathesStrings = ClassPathUtils.getClassPathes(defaultConsumerDir);
 239    }
 240    else
 241    {
 242  0 classPathesStrings = ClassPathUtils.getClassPathes();
 243    }
 244   
 245  36 if (null == classPathesStrings || classPathesStrings.isEmpty())
 246    {
 247  0 throw new IllegalStateException("The class path is not set correctly.");
 248    }
 249  36 m_consumerConfigurationFiles = FileUtils.findFilesByREInClassPath(classPathesStrings, JPConstants.PATTERN);
 250   
 251    // 01: use the consumer custom configuration
 252  36 final String consumerCustomDir = getJPatternsConsumerCustomConfigurationDirName();
 253  36 if (null == consumerCustomDir)
 254    {
 255  0 LOG.debug("The consumer custom configuration is not provided. The appropriate JPatternsConfig object are not initialized.");
 256    }
 257    else
 258    {
 259  36 final List<String> customClassPathesStrings = ClassPathUtils.getClassPathes(consumerCustomDir);
 260  36 if (null == customClassPathesStrings || customClassPathesStrings.isEmpty())
 261    {
 262    // custom consumer classpath could be set to the null/empty string etc.
 263  0 return;
 264    }
 265  36 m_consumerConfigurationCustomFiles = FileUtils.findFilesByREInClassPath(customClassPathesStrings, JPConstants.PATTERN);
 266    }
 267   
 268    // 02: set the merged default consumer configuration.
 269  36 if (null != m_consumerConfigurationFiles)
 270    {
 271  36 final List<JPatternsConfig> configs = obtainJPatternsConfigs(m_consumerConfigurationFiles);
 272  36 final List<JPatternsConfigBaseBean> defaultConsumerConfigs = new ArrayList<JPatternsConfigBaseBean>();
 273  36 for (JPatternsConfig config : configs)
 274    {
 275  42 defaultConsumerConfigs.add(builder.build(config));
 276    }
 277  36 m_mergedDefaultConsumerConfig = builder.build(defaultConsumerConfigs);
 278    }
 279   
 280    // 03: set the custom consumer configuration.
 281  36 if (null != m_consumerConfigurationCustomFiles)
 282    {
 283  36 final List<JPatternsConfig> customConfigs = obtainJPatternsConfigs(m_consumerConfigurationCustomFiles);
 284   
 285  36 final List<JPatternsConfigBaseBean> customConsumerConfigs = new ArrayList<JPatternsConfigBaseBean>();
 286  36 for (JPatternsConfig config : customConfigs)
 287    {
 288  0 customConsumerConfigs.add(builder.build(config));
 289    }
 290  36 m_mergedCustomConsumerConfig = builder.build(customConsumerConfigs);
 291    }
 292   
 293  36 if (null == m_mergedDefaultConsumerConfig && null == m_mergedCustomConsumerConfig)
 294    {
 295  0 throw new JPInitializationException("There is not consumer configuration provided. It is incorrect state for the JPatterns.");
 296    }
 297   
 298    // 04: merge these configurations
 299  36 mergeConsumerConfigurations();
 300    }
 301   
 302    /**
 303    * Perform the merging of the consumer configurations.
 304    * <br/>
 305    * the following rules have power here:
 306    * 1. in the case custom configuration is not present the default configuration would be used as the merged one.
 307    * 2. in the case default configuration is not present - the exception appeared.
 308    * 3. in the case both configurations present and the value of the property
 309    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML</code> is true -
 310    * the custom configuration is used as the merged one.
 311    * 4. in the case the property is not defined - we consider its value is <code>false</code>
 312    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML</code>
 313    * 5. in the case both configurations present and the value of the property
 314    * <code>com.sourceforge.jpatterns.core.configuration.PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML</code> is
 315    * <code>false</code> - configurations are merged using the implementation of the JPatternsConfigBeansBuilder.
 316    */
 317  36 protected void mergeConsumerConfigurations()
 318    {
 319    // 01:
 320  36 if (!customJPatternsConsumerConfigurationPresents())
 321    {
 322  36 if (defaultJPatternsConsumerConfigurationPresents())
 323    {
 324  35 m_mergedConsumerConfig = m_mergedDefaultConsumerConfig;
 325    }
 326    else
 327    {
 328    // 02:
 329  1 throw new IllegalStateException("The default consumer configuration should be present.");
 330    }
 331    }
 332    // 03:
 333  35 if (customJPatternsConsumerConfigurationPresents() && defaultJPatternsConsumerConfigurationPresents() &&
 334    null != useOnlyCustomConsumerConfigIfPresent && useOnlyCustomConsumerConfigIfPresent)
 335    {
 336  0 m_mergedConsumerConfig = m_mergedCustomConsumerConfig;
 337    }
 338    // 04, 05:
 339  35 if ((null != useOnlyCustomConsumerConfigIfPresent && !useOnlyCustomConsumerConfigIfPresent) ||
 340    null == useOnlyCustomConsumerConfigIfPresent)
 341    {
 342    // need to merge the properties. The custom one would override the default framework configuration.
 343  35 CastorUtils.makePrioritized(m_mergedCustomConsumerConfig);
 344  35 final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>();
 345  35 beans.add(m_mergedCustomConsumerConfig);
 346  35 beans.add(m_mergedDefaultConsumerConfig);
 347  35 final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder();
 348  35 m_mergedConsumerConfig = builder.build(beans);
 349    }
 350    }
 351   
 352    /**
 353    * Obtain the List of {@link JPatternsConfig} objects by the List of the File objects specified.
 354    *
 355    * @param files the List of the File objects Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
 356    * @return the List of JPatternsConfig objects
 357    */
 358  74 protected List<JPatternsConfig> obtainJPatternsConfigs(final List<File> files)
 359    {
 360  74 if (null == files)
 361    {
 362  1 throw new IllegalArgumentException("The List of File objects can not be null.");
 363    }
 364  73 final List<JPatternsConfig> result = new ArrayList<JPatternsConfig>();
 365  73 for (final File file : files)
 366    {
 367  74 final JPatternsConfig config = CastorUtils.getJPatternsConfig(file);
 368  74 if (null != config)
 369    {
 370  74 result.add(config);
 371    }
 372    }
 373  73 return result;
 374    }
 375   
 376    /**
 377    * Obtain the <code>JPatternsConfig</code> using the provided file name (it could be: 1. just file name without passes,
 378    * 2. the full file name 3. relative name)
 379    * <br/>
 380    * The following order for obtaining this {@link com.sourceforge.jpatterns.schema.JPatternsConfig} class is used:
 381    * <ul>
 382    * <li>Using the classloaders</li>
 383    * <li>Trying to open the file with the provided name using <code>File</code></li>
 384    * </ul>
 385    *
 386    * @param name the name of the file to be obtain. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
 387    * @return the castor <code>JPatternsConfig</code> woth the settings we need for the further working.
 388    */
 389  79 protected JPatternsConfigBean obtainJPatternsConfig(final String name)
 390    {
 391  79 InputArgumentUtils.checkStrings(true, name);
 392  78 JPatternsConfig result = null;
 393  78 final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder();
 394    //00 classloaders
 395  78 final URL url = ResourceUtils.getResource(name);
 396  78 if (url != null)
 397    {
 398  56 final File file = new File(url.getFile());
 399  56 result = CastorUtils.getJPatternsConfig(file);
 400  56 if (null != result)
 401    {
 402  56 LOG.debug("The JPatterns configuration was obtained using the classloaders (ResourceUtils.getResource) for the name " +
 403    name);
 404  56 if (null == builder)
 405    {
 406  0 throw new IllegalStateException("The IJPatternsConfigBeansBuilder instance can not be null.");
 407    }
 408  56 return builder.build(result);
 409    }
 410    }
 411    // 01 just thinking it is the full file name
 412  22 final File file = new File(name);
 413  22 if (file.isFile())
 414    {
 415    // the case when e.g. JVM param was set to the full/relative path to override the default one
 416  0 result = CastorUtils.getJPatternsConfig(file);
 417  0 if (null != result)
 418    {
 419  0 LOG.debug("The JPatterns configuration was obtained using the File for the name " +
 420    name);
 421  0 return builder.build(result);
 422    }
 423    }
 424  22 return null;
 425    }
 426   
 427    /**
 428    * @see IJPConfigurator#getJPatternsFrameworkConfigurationFileName()
 429    * <br/>
 430    * The way this name is obtained:
 431    * 1. In the case JVM parameter is specified - it is returns. Please be noticed the JVM parameter could specify both file name and
 432    * full pathed file name
 433    * todo [zmicer]: check if this item is fully supported here.
 434    * 2. Then the properties based value is checked.
 435    * <code>JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM<code>
 436    * 3. Then the default name {@link JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME} is returned.
 437    */
 438  41 public String getJPatternsFrameworkConfigurationFileName()
 439    {
 440  41 final String jvmDefault = System.getProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM);
 441  41 if (null != jvmDefault && !"".equals(jvmDefault.trim()))
 442    {
 443  39 LOG.debug("Please be noticed the JVM param based value for the default XML is used. This value is : " + jvmDefault);
 444  39 return jvmDefault;
 445    }
 446  2 final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager();
 447  2 if (null == propsManager)
 448    {
 449  0 throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null.");
 450    }
 451  2 final String propsValue =
 452    propsManager.getBundle(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM);
 453  2 if (null != propsValue && !"".equals(propsValue.trim()))
 454    {
 455  1 LOG.debug("The properties defined value is used for the JPatterns framework default configuration.");
 456  1 return propsValue;
 457    }
 458  1 LOG.debug("The default not JVM based value is used : " +
 459    JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME);
 460  1 return JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME;
 461    }
 462   
 463    /**
 464    * @see IJPConfigurator#getJPatternsFrameworkCustomConfigurationFileName()
 465    * <br/>
 466    * Take an attention at this above method: getJPatternsFrameworkConfigurationFileName
 467    */
 468  41 public String getJPatternsFrameworkCustomConfigurationFileName()
 469    {
 470  41 final String jvmDefault = System.getProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM);
 471  41 if (null != jvmDefault && !"".equals(jvmDefault.trim()))
 472    {
 473  39 LOG.debug("Please be noticed the JVM param based value for the default custom XML is used. This value is : " + jvmDefault);
 474  39 return jvmDefault;
 475    }
 476  2 final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager();
 477  2 if (null == propsManager)
 478    {
 479  0 throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null.");
 480    }
 481  2 final String propsValue =
 482    propsManager.getBundle(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM);
 483  2 if (null != propsValue && !"".equals(propsValue.trim()))
 484    {
 485  1 LOG.debug("The properties defined value is used for the JPatterns framework custom configuration.");
 486  1 return propsValue;
 487    }
 488  1 LOG.debug("The default custom not JVM based value is used : " +
 489    JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME);
 490  1 return JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME;
 491    }
 492   
 493    /**
 494    * @see com.sourceforge.jpatterns.core.configuration.IJPConfigurator#getJPatternsConsumerConfigurationFiles()
 495    */
 496  2 public List<File> getJPatternsConsumerConfigurationFiles()
 497    {
 498  2 return m_consumerConfigurationFiles;
 499    }
 500   
 501    /**
 502    * @see com.sourceforge.jpatterns.core.configuration.IJPConfigurator#getJPatternsConsumerCustomConfigurationFiles()
 503    */
 504  0 public List<File> getJPatternsConsumerCustomConfigurationFiles()
 505    {
 506  0 return m_consumerConfigurationCustomFiles;
 507    }
 508   
 509    /**
 510    * The first priority takes the JVM parameter, then - the properties file value.
 511    * <br/>
 512    * 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
 513    * <code>com.zmicer.utils.ClassPathUtils#getClassPathes()</code> for it. Also
 514    * <code>com.zmicer.utils.FileUtils#findFilesByREInClassPath(java.util.List<java.lang.String>, java.util.regex.Pattern)</code>
 515    * could help in providing the info.
 516    *
 517    * @return the String value pointing to the dir where the consumer specific custom configuration (not the xml pointed at the
 518    * classpath) are present.
 519    */
 520  36 public String getJPatternsConsumerCustomConfigurationDirName()
 521    {
 522  36 final String jvmDefautlt = System.getProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM);
 523  36 if (null != jvmDefautlt && !"".equals(jvmDefautlt.trim()))
 524    {
 525  36 LOG.debug("Please be noticed the JVM param based value for the custom consumer XML is used. This value is : " + jvmDefautlt);
 526  36 return jvmDefautlt;
 527    }
 528  0 final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager();
 529  0 if (null == propsManager)
 530    {
 531  0 throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null.");
 532    }
 533  0 final String propsValue =
 534    propsManager.getBundle(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_PROPS_PARAM);
 535  0 if (null != propsValue && !"".equals(propsValue.trim()))
 536    {
 537  0 LOG.debug("The properties defined value is used for the consumer custom configuration.");
 538  0 return propsValue;
 539    }
 540  0 LOG.debug("The consumer custom configuration is not provided.");
 541  0 return null;
 542    }
 543   
 544    /**
 545    * The first priority takes the JVM parameter, then - the properties file value.
 546    * <br/>
 547    * 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
 548    * <code>com.zmicer.utils.ClassPathUtils#getClassPathes()</code> for it. Also
 549    * <code>com.zmicer.utils.FileUtils#findFilesByREInClassPath(java.util.List<java.lang.String>, java.util.regex.Pattern)</code>
 550    * could help in providing the info.
 551    *
 552    * @return the String value pointing to the dir where the consumer specific custom configuration (not the xml pointed at the
 553    * classpath) are present.
 554    */
 555  36 public String getJPatternsConsumerConfigurationDirName()
 556    {
 557  36 final String jvmDefautlt = System.getProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM);
 558  36 if (null != jvmDefautlt && !"".equals(jvmDefautlt.trim()))
 559    {
 560  36 LOG.debug("Please be noticed the JVM param based value for the default consumer XML is used. This value is : " + jvmDefautlt);
 561  36 return jvmDefautlt;
 562    }
 563  0 final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager();
 564  0 if (null == propsManager)
 565    {
 566  0 throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null.");
 567    }
 568  0 final String propsValue =
 569    propsManager.getBundle(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_CONSUMER_CONFIG_DIR_NAME_PROPS_PARAM);
 570  0 if (null != propsValue && !"".equals(propsValue.trim()))
 571    {
 572  0 LOG.debug("The properties defined value is used for the consumer custom configuration.");
 573  0 return propsValue;
 574    }
 575  0 LOG.debug("The consumer custom configuration is not provided.");
 576  0 return null;
 577    }
 578   
 579    /**
 580    * @see IJPConfigurator#defaultJPatternsFrameworkConfigurationPresents()
 581    */
 582  76 public boolean defaultJPatternsFrameworkConfigurationPresents()
 583    {
 584  76 return (m_defaultFrameworkConfig != null);
 585    }
 586   
 587    /**
 588    * @see IJPConfigurator#customJPatternsConsumerConfigurationPresents()
 589    */
 590  55 public boolean customJPatternsFrameworkConfigurationPresents()
 591    {
 592  55 return (m_customFrameworkConfig != null);
 593    }
 594   
 595    /**
 596    * @see IJPConfigurator#defaultJPatternsConsumerConfigurationPresents()
 597    */
 598  36 public boolean defaultJPatternsConsumerConfigurationPresents()
 599    {
 600  36 return (m_mergedDefaultConsumerConfig != null && null != m_mergedDefaultConsumerConfig.getListOfSectionItems() &&
 601    !m_mergedDefaultConsumerConfig.getListOfSectionItems().isEmpty());
 602    }
 603   
 604    /**
 605    * @see IJPConfigurator#customJPatternsConsumerConfigurationPresents()
 606    */
 607  71 public boolean customJPatternsConsumerConfigurationPresents()
 608    {
 609  71 return (m_mergedCustomConsumerConfig != null && null != m_mergedCustomConsumerConfig.getListOfSectionItems() &&
 610    !m_mergedCustomConsumerConfig.getListOfSectionItems().isEmpty());
 611    }
 612   
 613    /**
 614    * @see com.sourceforge.jpatterns.core.configuration.IJPConfigurator#getJPatternsFrameworkConfiguration()
 615    */
 616  9 public JPatternsConfigsBean getJPatternsFrameworkConfiguration()
 617    {
 618  9 return m_mergedFrameworkConfig;
 619    }
 620   
 621    /**
 622    * @see com.sourceforge.jpatterns.core.configuration.IJPConfigurator#getJPatternsConsumerConfiguration()
 623    */
 624  37 public JPatternsConfigsBean getJPatternsConsumerConfiguration()
 625    {
 626  37 return m_mergedConsumerConfig;
 627    }
 628   
 629    /**
 630    * Set the value for the property useOnlyCustomFrameworkConfigIfPresent
 631    *
 632    * @param value the value to be set to this property. Could be null - it means that the property is not defined at all.
 633    */
 634  2 protected static void setUseOnlyCustomFrameworkConfigIfPresent(final Boolean value)
 635    {
 636  2 useOnlyCustomFrameworkConfigIfPresent = value;
 637    }
 638    }