| 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 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
public class JPConfiguratorImpl implements IJPConfigurator |
| 53 |
|
{ |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
5 |
final public static Logger LOG = Logger.getLogger(JPConfiguratorImpl.class); |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
142 |
private JPatternsConfigBean m_defaultFrameworkConfig = null; |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
142 |
private JPatternsConfigBean m_customFrameworkConfig = null; |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
142 |
private JPatternsConfigsBean m_mergedFrameworkConfig = null; |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
142 |
private JPatternsConfigsBean m_mergedDefaultConsumerConfig = null; |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
142 |
private JPatternsConfigsBean m_mergedCustomConsumerConfig = null; |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
142 |
private JPatternsConfigsBean m_mergedConsumerConfig = null; |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
142 |
private List<File> m_consumerConfigurationFiles = new ArrayList<File>(); |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
142 |
private List<File> m_consumerConfigurationCustomFiles = new ArrayList<File>(); |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
5 |
private static Boolean useOnlyCustomFrameworkConfigIfPresent = null; |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
5 |
private static Boolean useOnlyCustomConsumerConfigIfPresent = null; |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
public JPConfiguratorImpl() |
| 128 |
|
{ |
| 129 |
142 |
super(); |
| 130 |
142 |
initConfiguration(); |
| 131 |
142 |
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
protected void initConfiguration() |
| 139 |
|
{ |
| 140 |
|
|
| 141 |
157 |
final IPropertiesManager manager = PropertiesBasedFactory.getInstance().getPropertiesManager(); |
| 142 |
157 |
final PropertiesProvider propsProvider = PropertiesProvider.getInstance(manager, false); |
| 143 |
157 |
useOnlyCustomFrameworkConfigIfPresent = |
| 144 |
|
propsProvider.getBooleanProperty(PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_FRAMEWORK_XML); |
| 145 |
157 |
useOnlyCustomConsumerConfigIfPresent = |
| 146 |
|
propsProvider.getBooleanProperty(PropertiesProvider.JPProperties.USE_ONLY_CUSTOM_CONSUMER_XML); |
| 147 |
|
|
| 148 |
157 |
initFrameworkConfiguration(); |
| 149 |
157 |
initConsumerConfiguration(); |
| 150 |
157 |
} |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
protected void initFrameworkConfiguration() |
| 156 |
|
{ |
| 157 |
182 |
m_defaultFrameworkConfig = obtainJPatternsConfig(getJPatternsFrameworkConfigurationFileName()); |
| 158 |
182 |
m_customFrameworkConfig = obtainJPatternsConfig(getJPatternsFrameworkCustomConfigurationFileName()); |
| 159 |
182 |
mergeFrameworkConfigurations(); |
| 160 |
177 |
} |
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
protected void mergeFrameworkConfigurations() |
| 178 |
|
{ |
| 179 |
182 |
final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder(); |
| 180 |
|
|
| 181 |
182 |
if (!defaultJPatternsFrameworkConfigurationPresents()) |
| 182 |
|
{ |
| 183 |
5 |
throw new IllegalStateException("The default framework configuration should be present."); |
| 184 |
|
} |
| 185 |
177 |
if (!customJPatternsFrameworkConfigurationPresents()) |
| 186 |
|
{ |
| 187 |
92 |
if (defaultJPatternsFrameworkConfigurationPresents()) |
| 188 |
|
{ |
| 189 |
92 |
final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>(); |
| 190 |
92 |
beans.add(m_defaultFrameworkConfig); |
| 191 |
92 |
m_mergedFrameworkConfig = builder.build(beans); |
| 192 |
92 |
return; |
| 193 |
|
} |
| 194 |
|
else |
| 195 |
|
{ |
| 196 |
|
|
| 197 |
0 |
throw new IllegalStateException("The default framework configuration should be present."); |
| 198 |
|
} |
| 199 |
|
} |
| 200 |
|
|
| 201 |
85 |
if (customJPatternsFrameworkConfigurationPresents() && defaultJPatternsFrameworkConfigurationPresents() && |
| 202 |
|
null != useOnlyCustomFrameworkConfigIfPresent && useOnlyCustomFrameworkConfigIfPresent) |
| 203 |
|
{ |
| 204 |
5 |
final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>(); |
| 205 |
5 |
beans.add(m_customFrameworkConfig); |
| 206 |
5 |
m_mergedFrameworkConfig = builder.build(beans); |
| 207 |
5 |
return; |
| 208 |
|
} |
| 209 |
|
|
| 210 |
80 |
if ((null != useOnlyCustomFrameworkConfigIfPresent && !useOnlyCustomFrameworkConfigIfPresent) || |
| 211 |
|
null == useOnlyCustomFrameworkConfigIfPresent) |
| 212 |
|
{ |
| 213 |
|
|
| 214 |
80 |
CastorUtils.makePrioritized(m_customFrameworkConfig.getCastorConfig()); |
| 215 |
80 |
final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>(); |
| 216 |
80 |
beans.add(m_customFrameworkConfig); |
| 217 |
80 |
beans.add(m_defaultFrameworkConfig); |
| 218 |
80 |
m_mergedFrameworkConfig = builder.build(beans); |
| 219 |
|
} |
| 220 |
80 |
} |
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
protected void initConsumerConfiguration() |
| 230 |
|
{ |
| 231 |
172 |
final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder(); |
| 232 |
|
|
| 233 |
|
|
| 234 |
172 |
final String defaultConsumerDir = getJPatternsConsumerConfigurationDirName(); |
| 235 |
172 |
List<String> classPathesStrings = null; |
| 236 |
172 |
if (null != defaultConsumerDir && defaultConsumerDir.length() != 0) |
| 237 |
|
{ |
| 238 |
172 |
classPathesStrings = ClassPathUtils.getClassPathes(defaultConsumerDir); |
| 239 |
172 |
} |
| 240 |
|
else |
| 241 |
|
{ |
| 242 |
0 |
classPathesStrings = ClassPathUtils.getClassPathes(); |
| 243 |
|
} |
| 244 |
|
|
| 245 |
172 |
if (null == classPathesStrings || classPathesStrings.isEmpty()) |
| 246 |
|
{ |
| 247 |
0 |
throw new IllegalStateException("The class path is not set correctly."); |
| 248 |
|
} |
| 249 |
172 |
m_consumerConfigurationFiles = FileUtils.findFilesByREInClassPath(classPathesStrings, JPConstants.PATTERN); |
| 250 |
|
|
| 251 |
|
|
| 252 |
172 |
final String consumerCustomDir = getJPatternsConsumerCustomConfigurationDirName(); |
| 253 |
172 |
if (null == consumerCustomDir) |
| 254 |
|
{ |
| 255 |
0 |
LOG.debug("The consumer custom configuration is not provided. The appropriate JPatternsConfig object are not initialized."); |
| 256 |
0 |
} |
| 257 |
|
else |
| 258 |
|
{ |
| 259 |
172 |
final List<String> customClassPathesStrings = ClassPathUtils.getClassPathes(consumerCustomDir); |
| 260 |
172 |
if (null == customClassPathesStrings || customClassPathesStrings.isEmpty()) |
| 261 |
|
{ |
| 262 |
|
|
| 263 |
0 |
return; |
| 264 |
|
} |
| 265 |
172 |
m_consumerConfigurationCustomFiles = FileUtils.findFilesByREInClassPath(customClassPathesStrings, JPConstants.PATTERN); |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
|
| 269 |
172 |
if (null != m_consumerConfigurationFiles) |
| 270 |
|
{ |
| 271 |
172 |
final List<JPatternsConfig> configs = obtainJPatternsConfigs(m_consumerConfigurationFiles); |
| 272 |
172 |
final List<JPatternsConfigBaseBean> defaultConsumerConfigs = new ArrayList<JPatternsConfigBaseBean>(); |
| 273 |
172 |
for (JPatternsConfig config : configs) |
| 274 |
|
{ |
| 275 |
202 |
defaultConsumerConfigs.add(builder.build(config)); |
| 276 |
202 |
} |
| 277 |
172 |
m_mergedDefaultConsumerConfig = builder.build(defaultConsumerConfigs); |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
|
| 281 |
172 |
if (null != m_consumerConfigurationCustomFiles) |
| 282 |
|
{ |
| 283 |
172 |
final List<JPatternsConfig> customConfigs = obtainJPatternsConfigs(m_consumerConfigurationCustomFiles); |
| 284 |
|
|
| 285 |
172 |
final List<JPatternsConfigBaseBean> customConsumerConfigs = new ArrayList<JPatternsConfigBaseBean>(); |
| 286 |
172 |
for (JPatternsConfig config : customConfigs) |
| 287 |
|
{ |
| 288 |
0 |
customConsumerConfigs.add(builder.build(config)); |
| 289 |
0 |
} |
| 290 |
172 |
m_mergedCustomConsumerConfig = builder.build(customConsumerConfigs); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
172 |
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 |
|
|
| 299 |
172 |
mergeConsumerConfigurations(); |
| 300 |
167 |
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
protected void mergeConsumerConfigurations() |
| 318 |
|
{ |
| 319 |
|
|
| 320 |
172 |
if (!customJPatternsConsumerConfigurationPresents()) |
| 321 |
|
{ |
| 322 |
172 |
if (defaultJPatternsConsumerConfigurationPresents()) |
| 323 |
|
{ |
| 324 |
167 |
m_mergedConsumerConfig = m_mergedDefaultConsumerConfig; |
| 325 |
167 |
} |
| 326 |
|
else |
| 327 |
|
{ |
| 328 |
|
|
| 329 |
5 |
throw new IllegalStateException("The default consumer configuration should be present."); |
| 330 |
|
} |
| 331 |
|
} |
| 332 |
|
|
| 333 |
167 |
if (customJPatternsConsumerConfigurationPresents() && defaultJPatternsConsumerConfigurationPresents() && |
| 334 |
|
null != useOnlyCustomConsumerConfigIfPresent && useOnlyCustomConsumerConfigIfPresent) |
| 335 |
|
{ |
| 336 |
0 |
m_mergedConsumerConfig = m_mergedCustomConsumerConfig; |
| 337 |
|
} |
| 338 |
|
|
| 339 |
167 |
if ((null != useOnlyCustomConsumerConfigIfPresent && !useOnlyCustomConsumerConfigIfPresent) || |
| 340 |
|
null == useOnlyCustomConsumerConfigIfPresent) |
| 341 |
|
{ |
| 342 |
|
|
| 343 |
167 |
CastorUtils.makePrioritized(m_mergedCustomConsumerConfig); |
| 344 |
167 |
final List<JPatternsConfigBaseBean> beans = new ArrayList<JPatternsConfigBaseBean>(); |
| 345 |
167 |
beans.add(m_mergedCustomConsumerConfig); |
| 346 |
167 |
beans.add(m_mergedDefaultConsumerConfig); |
| 347 |
167 |
final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder(); |
| 348 |
167 |
m_mergedConsumerConfig = builder.build(beans); |
| 349 |
|
} |
| 350 |
167 |
} |
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
protected List<JPatternsConfig> obtainJPatternsConfigs(final List<File> files) |
| 359 |
|
{ |
| 360 |
354 |
if (null == files) |
| 361 |
|
{ |
| 362 |
5 |
throw new IllegalArgumentException("The List of File objects can not be null."); |
| 363 |
|
} |
| 364 |
349 |
final List<JPatternsConfig> result = new ArrayList<JPatternsConfig>(); |
| 365 |
349 |
for (final File file : files) |
| 366 |
|
{ |
| 367 |
362 |
final JPatternsConfig config = CastorUtils.getJPatternsConfig(file); |
| 368 |
362 |
if (null != config) |
| 369 |
|
{ |
| 370 |
362 |
result.add(config); |
| 371 |
|
} |
| 372 |
362 |
} |
| 373 |
349 |
return result; |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
|
| 387 |
|
|
| 388 |
|
|
| 389 |
|
protected JPatternsConfigBean obtainJPatternsConfig(final String name) |
| 390 |
|
{ |
| 391 |
379 |
InputArgumentUtils.checkStrings(true, name); |
| 392 |
374 |
JPatternsConfig result = null; |
| 393 |
374 |
final IJPatternsConfigBeansBuilder builder = PropertiesBasedFactory.getInstance().getJPatternsConfigBaseBeanBuilder(); |
| 394 |
|
|
| 395 |
374 |
final URL url = ResourceUtils.getResource(name); |
| 396 |
374 |
if (url != null) |
| 397 |
|
{ |
| 398 |
272 |
final File file = new File(url.getFile()); |
| 399 |
272 |
result = CastorUtils.getJPatternsConfig(file); |
| 400 |
272 |
if (null != result) |
| 401 |
|
{ |
| 402 |
272 |
LOG.debug("The JPatterns configuration was obtained using the classloaders (ResourceUtils.getResource) for the name " + |
| 403 |
|
name); |
| 404 |
272 |
if (null == builder) |
| 405 |
|
{ |
| 406 |
0 |
throw new IllegalStateException("The IJPatternsConfigBeansBuilder instance can not be null."); |
| 407 |
|
} |
| 408 |
272 |
return builder.build(result); |
| 409 |
|
} |
| 410 |
|
} |
| 411 |
|
|
| 412 |
102 |
final File file = new File(name); |
| 413 |
102 |
if (file.isFile()) |
| 414 |
|
{ |
| 415 |
|
|
| 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 |
102 |
return null; |
| 425 |
|
} |
| 426 |
|
|
| 427 |
|
|
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 431 |
|
|
| 432 |
|
|
| 433 |
|
|
| 434 |
|
|
| 435 |
|
|
| 436 |
|
|
| 437 |
|
|
| 438 |
|
public String getJPatternsFrameworkConfigurationFileName() |
| 439 |
|
{ |
| 440 |
197 |
final String jvmDefault = System.getProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM); |
| 441 |
197 |
if (null != jvmDefault && !"".equals(jvmDefault.trim())) |
| 442 |
|
{ |
| 443 |
187 |
LOG.debug("Please be noticed the JVM param based value for the default XML is used. This value is : " + jvmDefault); |
| 444 |
187 |
return jvmDefault; |
| 445 |
|
} |
| 446 |
10 |
final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager(); |
| 447 |
10 |
if (null == propsManager) |
| 448 |
|
{ |
| 449 |
0 |
throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null."); |
| 450 |
|
} |
| 451 |
10 |
final String propsValue = |
| 452 |
|
propsManager.getBundle(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM); |
| 453 |
10 |
if (null != propsValue && !"".equals(propsValue.trim())) |
| 454 |
|
{ |
| 455 |
5 |
LOG.debug("The properties defined value is used for the JPatterns framework default configuration."); |
| 456 |
5 |
return propsValue; |
| 457 |
|
} |
| 458 |
5 |
LOG.debug("The default not JVM based value is used : " + |
| 459 |
|
JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME); |
| 460 |
5 |
return JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME; |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
|
public String getJPatternsFrameworkCustomConfigurationFileName() |
| 469 |
|
{ |
| 470 |
197 |
final String jvmDefault = System.getProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM); |
| 471 |
197 |
if (null != jvmDefault && !"".equals(jvmDefault.trim())) |
| 472 |
|
{ |
| 473 |
187 |
LOG.debug("Please be noticed the JVM param based value for the default custom XML is used. This value is : " + jvmDefault); |
| 474 |
187 |
return jvmDefault; |
| 475 |
|
} |
| 476 |
10 |
final IPropertiesManager propsManager = PropertiesBasedFactory.getInstance().getPropertiesManager(); |
| 477 |
10 |
if (null == propsManager) |
| 478 |
|
{ |
| 479 |
0 |
throw new IllegalStateException("Smth. wrong with the core initialization. Properties manager can not be null."); |
| 480 |
|
} |
| 481 |
10 |
final String propsValue = |
| 482 |
|
propsManager.getBundle(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM); |
| 483 |
10 |
if (null != propsValue && !"".equals(propsValue.trim())) |
| 484 |
|
{ |
| 485 |
5 |
LOG.debug("The properties defined value is used for the JPatterns framework custom configuration."); |
| 486 |
5 |
return propsValue; |
| 487 |
|
} |
| 488 |
5 |
LOG.debug("The default custom not JVM based value is used : " + |
| 489 |
|
JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME); |
| 490 |
5 |
return JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME; |
| 491 |
|
} |
| 492 |
|
|
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
public List<File> getJPatternsConsumerConfigurationFiles() |
| 497 |
|
{ |
| 498 |
10 |
return m_consumerConfigurationFiles; |
| 499 |
|
} |
| 500 |
|
|
| 501 |
|
|
| 502 |
|
|
| 503 |
|
|
| 504 |
|
public List<File> getJPatternsConsumerCustomConfigurationFiles() |
| 505 |
|
{ |
| 506 |
0 |
return m_consumerConfigurationCustomFiles; |
| 507 |
|
} |
| 508 |
|
|
| 509 |
|
|
| 510 |
|
|
| 511 |
|
|
| 512 |
|
|
| 513 |
|
|
| 514 |
|
|
| 515 |
|
|
| 516 |
|
|
| 517 |
|
|
| 518 |
|
|
| 519 |
|
|
| 520 |
|
public String getJPatternsConsumerCustomConfigurationDirName() |
| 521 |
|
{ |
| 522 |
172 |
final String jvmDefautlt = System.getProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM); |
| 523 |
172 |
if (null != jvmDefautlt && !"".equals(jvmDefautlt.trim())) |
| 524 |
|
{ |
| 525 |
172 |
LOG.debug("Please be noticed the JVM param based value for the custom consumer XML is used. This value is : " + jvmDefautlt); |
| 526 |
172 |
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 |
|
|
| 546 |
|
|
| 547 |
|
|
| 548 |
|
|
| 549 |
|
|
| 550 |
|
|
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
public String getJPatternsConsumerConfigurationDirName() |
| 556 |
|
{ |
| 557 |
172 |
final String jvmDefautlt = System.getProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_CONSUMER_CONFIG_DIR_NAME_JVM_PARAM); |
| 558 |
172 |
if (null != jvmDefautlt && !"".equals(jvmDefautlt.trim())) |
| 559 |
|
{ |
| 560 |
172 |
LOG.debug("Please be noticed the JVM param based value for the default consumer XML is used. This value is : " + jvmDefautlt); |
| 561 |
172 |
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 |
|
|
| 581 |
|
|
| 582 |
|
public boolean defaultJPatternsFrameworkConfigurationPresents() |
| 583 |
|
{ |
| 584 |
364 |
return (m_defaultFrameworkConfig != null); |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
|
| 588 |
|
|
| 589 |
|
|
| 590 |
|
public boolean customJPatternsFrameworkConfigurationPresents() |
| 591 |
|
{ |
| 592 |
267 |
return (m_customFrameworkConfig != null); |
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
|
| 596 |
|
|
| 597 |
|
|
| 598 |
|
public boolean defaultJPatternsConsumerConfigurationPresents() |
| 599 |
|
{ |
| 600 |
172 |
return (m_mergedDefaultConsumerConfig != null && null != m_mergedDefaultConsumerConfig.getListOfSectionItems() && |
| 601 |
|
!m_mergedDefaultConsumerConfig.getListOfSectionItems().isEmpty()); |
| 602 |
|
} |
| 603 |
|
|
| 604 |
|
|
| 605 |
|
|
| 606 |
|
|
| 607 |
|
public boolean customJPatternsConsumerConfigurationPresents() |
| 608 |
|
{ |
| 609 |
339 |
return (m_mergedCustomConsumerConfig != null && null != m_mergedCustomConsumerConfig.getListOfSectionItems() && |
| 610 |
|
!m_mergedCustomConsumerConfig.getListOfSectionItems().isEmpty()); |
| 611 |
|
} |
| 612 |
|
|
| 613 |
|
|
| 614 |
|
|
| 615 |
|
|
| 616 |
|
public JPatternsConfigsBean getJPatternsFrameworkConfiguration() |
| 617 |
|
{ |
| 618 |
41 |
return m_mergedFrameworkConfig; |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
|
| 622 |
|
|
| 623 |
|
|
| 624 |
|
public JPatternsConfigsBean getJPatternsConsumerConfiguration() |
| 625 |
|
{ |
| 626 |
173 |
return m_mergedConsumerConfig; |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
|
| 630 |
|
|
| 631 |
|
|
| 632 |
|
|
| 633 |
|
|
| 634 |
|
protected static void setUseOnlyCustomFrameworkConfigIfPresent(final Boolean value) |
| 635 |
|
{ |
| 636 |
10 |
useOnlyCustomFrameworkConfigIfPresent = value; |
| 637 |
10 |
} |
| 638 |
|
} |