Coverage Report - net.admin4j.config.PropertyConfigurator
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyConfigurator
66%
121/181
55%
48/86
8.5
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  *
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  *
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.config;
 15  
 
 16  
 import java.io.File;
 17  
 import java.io.FileInputStream;
 18  
 import java.io.FileNotFoundException;
 19  
 import java.io.IOException;
 20  
 import java.io.InputStream;
 21  
 import java.util.Properties;
 22  
 import java.util.Set;
 23  
 import java.util.StringTokenizer;
 24  
 
 25  
 import net.admin4j.deps.commons.lang3.StringUtils;
 26  
 import net.admin4j.ui.filters.consolidator.HttpRequestConsolidator;
 27  
 import net.admin4j.util.Admin4jRuntimeException;
 28  
 import net.admin4j.util.PropertyUtils;
 29  
 import net.admin4j.util.notify.NotifierUtils;
 30  
 
 31  
 import org.slf4j.Logger;
 32  
 import org.slf4j.LoggerFactory;
 33  
 
 34  
 /**
 35  
  * Will configure Admin4J from a properties file.
 36  
  *
 37  
  * <p>
 38  
  * Configuration properties can be specified in two ways:
 39  
  * </p>
 40  
  * <li>By setting system property 'admin4j.configuration.file' equal to a
 41  
  * properties file name containing the admin4j configuration</li> <li>Placing a
 42  
  * file called 'admin4j.properties' in the classpath.</li>
 43  
  *
 44  
  * <p>
 45  
  * If both the system property is specified and an admin4j.properties file is
 46  
  * placed in the classpath, the system property takes precedence.
 47  
  * </p>
 48  
  *
 49  
  * <p>
 50  
  * Allowed properties are as follows:
 51  
  * </p>
 52  
  * <li>exception.info.storage.format - Optional (xml/database). Default XML.</li>
 53  
  * <li>exception.info.xml.file - Optional - default none; exception info won't
 54  
  * be stored and won't persist between recycles.</li> <li>
 55  
  * performance.info.storage.format - Optional (xml/database). Default XML.</li>
 56  
  * <li>performance.info.xml.file - Optional - default none; performance info
 57  
  * won't be stored and won't persist between recycles.</li> <li>
 58  
  * performance.uri.consolidator - Optional - default none; URIs won't be
 59  
  * consolidated for performance tracking.</li> <li>
 60  
  * additional.log.manager.classes - Optional - default none; Comma delimited
 61  
  * list of classes that implement LogManager interface.</li> <li>
 62  
  * base.freemarker.template.dir - Optional - default none; Specifies a
 63  
  * development directory containing admin4j FTL. Useful in development.</li> <li>
 64  
  * exception.time.tracking.in.days - Optional - default @see
 65  
  * net.admin4j.exception.ExceptionTrackerCleanupTask. Specifies when tracked
 66  
  * exceptions are purged if not encountered.</li> <li>
 67  
  * exception.exempted.exception.types - Optional - default none. Comma delimited
 68  
  * list specifying exception classes that are not tracked.</li> <li>
 69  
  * file.explorer.restrict.to.base.dir - (true/false) Optional - default true. If
 70  
  * true, file exploring will be restricted to the base directory and its
 71  
  * subdirectories.</li> <li>file.explorer.restrict.from.exec - (true/false)
 72  
  * Optional - default true. If true, file exploring will not permit execution of
 73  
  * those files that are executable.</li> <li>file.explorer.restrict.from.write -
 74  
  * (true/false) Optional - default true. If true, file exploring will not allow
 75  
  * file uploads.</li> <li>file.explorer.base.dir.name - Optional - default
 76  
  * ${user.dir}. Specifies the directory that will originate file exploring.</li>
 77  
  * <li>hotspot.sleep.interval.millis - Optional - default @see
 78  
  * net.admin4j.ui.servlets.HotSpotDisplayServlet. Length of HotSpot sleep
 79  
  * interval in milliseconds.</li> <li>memory.sleep.interval.millis - Optional -
 80  
  * default @see net.admin4j.ui.servlets.MemoryMonitorStartupServlet. Length of
 81  
  * Memory monitor sleep interval in milliseconds.</li> <li>memory.threshold.pct
 82  
  * - Optional - default @see
 83  
  * net.admin4j.ui.servlets.MemoryMonitorStartupServlet. Percent memory usage
 84  
  * required to trigger a notification.</li> <li>
 85  
  * memory.nbr.intervals.between.warnings - Optional - default @see
 86  
  * net.admin4j.ui.servlets.MemoryMonitorStartupServlet. Number of intervals
 87  
  * between notifications should the memory problem persist.</li> <li>
 88  
  * memory.nbr.low.watermark.intervals - Optional - default @see
 89  
  * net.admin4j.ui.servlets.MemoryMonitorStartupServlet. Number of low watermark
 90  
  * observations reported with a low memory notice.</li> <li>
 91  
  * memory.low.watermark.monitor.interval.millis - Optional - default @see
 92  
  * net.admin4j.ui.servlets.MemoryMonitorStartupServlet. Millis between low
 93  
  * watermark observations.</li> <li>thread.sleep.interval.millis - Optional -
 94  
  * default @see net.admin4j.ui.servlets.ThreadMonitorStartupServlet. Length of
 95  
  * Thread monitor sleep interval in milliseconds.</li> <li>
 96  
  * thread.max.blocked.threads - Optional - default @see
 97  
  * net.admin4j.ui.servlets.ThreadMonitorStartupServlet. Number of blocked
 98  
  * threads needed to trigger notification.</li> <li>
 99  
  * web.transaction.error.logger.name - Optional - default @see
 100  
  * net.admin4j.ui.filters.ErrorLoggingFilter. Logger name used for web
 101  
  * transaction errors.</li> <li>
 102  
  * web.transaction.performance.notification.threshold.in.millis - Optional -
 103  
  * default none. If set, web transactions with execution time greater than or
 104  
  * equal to this setting will result in notification.</li> <li>
 105  
  * error.notification.time.interval.millis - Optional - default none. If set,
 106  
  * web transaction errors of the same type will be surpressed for the given time
 107  
  * period.</li> <li>error.exempted.exception.types - Optional - default none.
 108  
  * Comma delimited list specifying exception classes that will not result in
 109  
  * notification.</li> <li>sql.nbr.retained.sql.statements - Optional - default
 110  
  * 50. Number of top resource intensive SQL statements retained.</li> <li>
 111  
  * sql.retention.time.in.millis - Optional - default 6 hrs. Maximum time SQL
 112  
  * statements are retained since last executed.</li> <li>
 113  
  * usage.sleep.interval.millis -- Optional. Default 30000 (30 sec). Amount of
 114  
  * time in millis monitor will sleep between checks.</li> <li>usage.alert.levels
 115  
  * -- Optional. Default 100. Comma-delimited list of threshold levels for which
 116  
  * notices will be sent. Example: 10,50,100.</li> <li>
 117  
  * request.history.nbr.retained -- Optional. Default 5. The number of requests
 118  
  * in the request history section for error logs and emails.</li>
 119  
  *
 120  
  * <p>
 121  
  * Note: Properties can have variable references with syntax ${variable-name}.
 122  
  * Properties are resolved with rules documented with PropertyUtils
 123  
  * </p>
 124  
  *
 125  
  * @author D. Ashmore
 126  
  * @since 1.0
 127  
  * @see net.admin4j.util.PropertyUtils#resolveVariableReferences(Properties)
 128  
  */
 129  
 class PropertyConfigurator {
 130  
 
 131  99
         private static Logger logger = LoggerFactory.getLogger(PropertyConfigurator.class);
 132  
         private static PropertyConfigurator configurator;
 133  
 
 134  
         public synchronized static void configure() {
 135  105
                 InputStream inStream = null;
 136  105
                 boolean configurationFound = false;
 137  
 
 138  105
                 if (configurator == null) {
 139  102
                         configurator = new PropertyConfigurator();
 140  
                 }
 141  
                 else {
 142  3
                         return;
 143  
                 }
 144  
 
 145  
                 // Attempt to load from property setting.
 146  102
                 String propsFileName = System.getProperty("admin4j.configuration.file");
 147  0
                 if (!StringUtils.isEmpty(propsFileName)) {
 148  
                         try {
 149  3
                                 inStream = new FileInputStream(propsFileName);
 150  0
                                 logger.info("Admin4J properties loaded from file "
 151  
                                                 + propsFileName);
 152  0
                                 configurator.assignProps(inStream);
 153  0
                                 configurationFound = true;
 154  0
                                 return; // don't override with any configuration in the
 155  
                                 // classpath.
 156  
 
 157  3
                         } catch (FileNotFoundException e) {
 158  3
                                 logger.error("Error reading configuration file",
 159  
                                                 new Admin4jRuntimeException(e).addContextValue(
 160  
                                                                 "admin4j.configuration.file", propsFileName));
 161  0
                         } catch (IOException e) {
 162  0
                                 logger.error("Error reading configuration file",
 163  
                                                 new Admin4jRuntimeException(e).addContextValue(
 164  
                                                                 "admin4j.configuration.file", propsFileName));
 165  3
                         }
 166  
                 }
 167  
 
 168  
                 // Attempt to load from classpath.
 169  102
                 inStream = Admin4JConfiguration.class.getClassLoader()
 170  
                                 .getResourceAsStream("admin4j.properties");
 171  102
                 if (inStream != null) {
 172  
                         try {
 173  0
                                 configurator.assignProps(inStream);
 174  0
                                 logger.info("Admin4J properties loaded from file admin4j.properties in the classpath");
 175  0
                                 configurationFound = true;
 176  0
                         } catch (IOException e) {
 177  0
                                 logger.error("Error reading admin4j.properties",
 178  
                                                 new Admin4jRuntimeException(e));
 179  0
                         }
 180  
                 }
 181  
 
 182  102
                 if (!configurationFound) {
 183  102
                         logger.warn("Admin4J not configured properly.");
 184  
                 }
 185  102
         }
 186  
 
 187  
         /**
 188  
          * Here for unit testing purposes only -- shouldn't be used otherwise.
 189  
          *
 190  
          * @param configurator
 191  
          */
 192  
         protected static void setConfigurator(PropertyConfigurator configurator) {
 193  3
                 PropertyConfigurator.configurator = configurator;
 194  3
         }
 195  
 
 196  
         private static Boolean toBoolean(String value, String propName) {
 197  9
                 Boolean tempBool = null;
 198  
                 try {
 199  9
                         tempBool = Boolean.parseBoolean(value);
 200  0
                 } catch (Exception e) {
 201  
                         logger.error(
 202  
                                         "Illegal property value in admin4j properties file",
 203  
                                         new Admin4jRuntimeException(e).addContextValue("propName",
 204  
                                                         propName)
 205  
                                                         .addContextValue("value", value));
 206  9
                 }
 207  
 
 208  9
                 return tempBool;
 209  
         }
 210  
 
 211  
         private static Integer toInteger(String value, String propName) {
 212  30
                 Integer tempInt = null;
 213  
                 try {
 214  30
                         tempInt = Integer.parseInt(value);
 215  0
                 } catch (NumberFormatException e) {
 216  
                         logger.error(
 217  
                                         "Illegal property value in admin4j properties file",
 218  
                                         new Admin4jRuntimeException(e).addContextValue("propName",
 219  
                                                         propName)
 220  
                                                         .addContextValue("value", value));
 221  30
                 }
 222  
 
 223  30
                 return tempInt;
 224  
         }
 225  
 
 226  
         private static Long toLong(String value, String propName) {
 227  15
                 Long tempLong = null;
 228  
                 try {
 229  15
                         tempLong = Long.parseLong(value);
 230  0
                 } catch (NumberFormatException e) {
 231  
                         logger.error(
 232  
                                         "Illegal property value in admin4j properties file",
 233  
                                         new Admin4jRuntimeException(e).addContextValue("propName",
 234  
                                                         propName)
 235  
                                                         .addContextValue("value", value));
 236  15
                 }
 237  
 
 238  15
                 return tempLong;
 239  
         }
 240  
 
 241  105
         protected PropertyConfigurator() {
 242  105
         }
 243  
 
 244  
         /**
 245  
          * Note: protected to support unit test.
 246  
          *
 247  
          * @param inStream
 248  
          * @throws IOException
 249  
          */
 250  
         protected void assignProps(InputStream inStream) throws IOException {
 251  3
                 Properties admin4JProps = new Properties();
 252  3
                 admin4JProps.load(inStream);
 253  3
                 Set<String> unresolvedVariableSet = PropertyUtils.resolveVariableReferences(admin4JProps);
 254  3
                 for (String unresolvedVar : unresolvedVariableSet) {
 255  3
                         logger.warn("Properties file with unresolved variable {}",
 256  
                                         unresolvedVar);
 257  
                 }
 258  3
                 this.assignProps(admin4JProps);
 259  3
         }
 260  
 
 261  
         private void assignProps(Properties admin4JProps) {
 262  
                 String value;
 263  
 
 264  3
                 value = admin4JProps.getProperty("exception.info.storage.format");
 265  0
                 if (!StringUtils.isEmpty(value)) {
 266  3
                         if ("xml".equalsIgnoreCase(value)) {
 267  3
                                 logger.info("Exception Info storage set to XML format.");
 268  3
                                 Admin4JConfiguration.setExceptionInformationStorageFormat(Admin4JConfiguration.StorageFormat.XML);
 269  
                         }
 270  
                         // else if ("database".equalsIgnoreCase(value)) {
 271  
                         // logger.info("Exception Info storage set to database format.");
 272  
                         // Admin4JConfiguration.setExceptionInformationStorageFormat(Admin4JConfiguration.StorageFormat.DATABASE);
 273  
                         // }
 274  
                         else {
 275  0
                                 throw new Admin4jRuntimeException(
 276  
                                                 "Invalid exception.info.storage.format").addContextValue(
 277  
                                                                 "exception.info.storage.format", value);
 278  
                         }
 279  
                 }
 280  
 
 281  3
                 value = admin4JProps.getProperty("exception.info.xml.file");
 282  0
                 if (!StringUtils.isEmpty(value)) {
 283  3
                         logger.info("Exception Info storage set to file: " + value);
 284  3
                         Admin4JConfiguration.setExceptionInformationXmlFileName(value);
 285  
                 }
 286  
 
 287  3
                 value = admin4JProps.getProperty("performance.info.storage.format");
 288  0
                 if (!StringUtils.isEmpty(value)) {
 289  3
                         if ("xml".equalsIgnoreCase(value)) {
 290  3
                                 logger.info("Performance Info storage set to XML format.");
 291  3
                                 Admin4JConfiguration.setPerformanceInformationStorageFormat(Admin4JConfiguration.StorageFormat.XML);
 292  
                         }
 293  
                         // else if ("database".equalsIgnoreCase(value)) {
 294  
                         // logger.info("Performance Info storage set to database format.");
 295  
                         // Admin4JConfiguration.setPerformanceInformationStorageFormat(Admin4JConfiguration.StorageFormat.DATABASE);
 296  
                         // }
 297  
                         else {
 298  0
                                 throw new Admin4jRuntimeException(
 299  
                                                 "Invalid performance.info.storage.format").addContextValue(
 300  
                                                                 "performance.info.storage.format", value);
 301  
                         }
 302  
                 }
 303  
 
 304  3
                 value = admin4JProps.getProperty("performance.info.xml.file");
 305  0
                 if (!StringUtils.isEmpty(value)) {
 306  3
                         logger.info("Performance Info storage set to file: " + value);
 307  3
                         Admin4JConfiguration.setPerformanceInformationXmlFileName(value);
 308  
                 }
 309  
 
 310  
                 try {
 311  3
                         Admin4JConfiguration.setDefaultNotifier(NotifierUtils.configure(
 312  
                                         "default.notifier", admin4JProps));
 313  0
                 } catch (Exception e) {
 314  0
                         throw new Admin4jRuntimeException("Invalid default.notifier.class",
 315  
                                         e).addContextValue("default.notifier.class", value);
 316  3
                 }
 317  3
                 if (Admin4JConfiguration.getDefaultNotifier() == null) {
 318  3
                         logger.info("Default Notifier not set");
 319  
                 }
 320  
                 else {
 321  0
                         logger.info("Default Notifier set to class: "
 322  
                                         + Admin4JConfiguration.getDefaultNotifier()
 323  
                                         .getClass()
 324  
                                         .getName());
 325  
                 }
 326  
 
 327  3
                 value = admin4JProps.getProperty("additional.log.manager.classes");
 328  0
                 if (!StringUtils.isEmpty(value)) {
 329  3
                         StringTokenizer logManagerTok = new StringTokenizer(value, ",");
 330  
                         String logManagerClassName;
 331  6
                         while (logManagerTok.hasMoreTokens()) {
 332  3
                                 logManagerClassName = logManagerTok.nextToken();
 333  0
                                 if (!StringUtils.isEmpty(logManagerClassName)) {
 334  3
                                         Admin4JConfiguration.getAdditionalLogManagerClassNames()
 335  
                                         .add(logManagerClassName.trim());
 336  3
                                         logger.info("Log Manager class {} added to configuration",
 337  
                                                         logManagerClassName);
 338  
                                 }
 339  
                         }
 340  
                 }
 341  
 
 342  3
                 value = admin4JProps.getProperty("base.freemarker.template.dir");
 343  0
                 if (!StringUtils.isEmpty(value)) {
 344  3
                         File templateDir = new File(value);
 345  3
                         if (!templateDir.canRead()) {
 346  0
                                 throw new Admin4jRuntimeException(
 347  
                                                 "base.freemarker.template.dir not readable").addContextValue(
 348  
                                                                 "base.freemarker.template.dir", value);
 349  
                         }
 350  3
                         if (!templateDir.isDirectory()) {
 351  0
                                 throw new Admin4jRuntimeException(
 352  
                                                 "base.freemarker.template.dir not a directory").addContextValue(
 353  
                                                                 "base.freemarker.template.dir", value);
 354  
                         }
 355  3
                         Admin4JConfiguration.setBaseFreemarkerTemplateDirectory(templateDir);
 356  3
                         logger.info("Freemarker Template Directory set to {}", value);
 357  
                 }
 358  
 
 359  3
                 value = admin4JProps.getProperty("exception.time.tracking.in.days");
 360  0
                 if (!StringUtils.isEmpty(value)) {
 361  3
                         Admin4JConfiguration.setExceptionTimeTrackingInDays(toInteger(
 362  
                                         value, "exception.time.tracking.in.days"));
 363  
                 }
 364  
 
 365  3
                 value = admin4JProps.getProperty("exception.exempted.exception.types");
 366  0
                 if (!StringUtils.isEmpty(value)) {
 367  3
                         Admin4JConfiguration.setExceptionExemptedExceptionTypes(value);
 368  
                 }
 369  
 
 370  3
                 value = admin4JProps.getProperty("file.explorer.restrict.to.base.dir");
 371  0
                 if (!StringUtils.isEmpty(value)) {
 372  3
                         Admin4JConfiguration.setFileExplorerRestrictToBaseDir(toBoolean(
 373  
                                         value, "file.explorer.restrict.to.base.dir"));
 374  
                 }
 375  3
                 value = admin4JProps.getProperty("file.explorer.restrict.from.exec");
 376  0
                 if (!StringUtils.isEmpty(value)) {
 377  3
                         Admin4JConfiguration.setFileExplorerRestrictFromExec(toBoolean(
 378  
                                         value, "file.explorer.restrict.from.exec"));
 379  
                 }
 380  3
                 value = admin4JProps.getProperty("file.explorer.restrict.from.write");
 381  0
                 if (!StringUtils.isEmpty(value)) {
 382  3
                         Admin4JConfiguration.setFileExplorerRestrictFromWrite(toBoolean(
 383  
                                         value, "file.explorer.restrict.from.write"));
 384  
                 }
 385  3
                 value = admin4JProps.getProperty("file.explorer.base.dir.name");
 386  0
                 if (!StringUtils.isEmpty(value)) {
 387  3
                         Admin4JConfiguration.setFileExplorerBaseDirName(value);
 388  
                 }
 389  
 
 390  3
                 value = admin4JProps.getProperty("hotspot.sleep.interval.millis");
 391  0
                 if (!StringUtils.isEmpty(value)) {
 392  3
                         Admin4JConfiguration.setHotSpotSleepIntervalMillis(toInteger(value,
 393  
                                         "hotspot.sleep.interval.millis"));
 394  
                 }
 395  
 
 396  3
                 value = admin4JProps.getProperty("memory.sleep.interval.millis");
 397  0
                 if (!StringUtils.isEmpty(value)) {
 398  3
                         Admin4JConfiguration.setMemorySleepIntervalMillis(toLong(value,
 399  
                                         "memory.sleep.interval.millis"));
 400  
                 }
 401  3
                 value = admin4JProps.getProperty("memory.threshold.pct");
 402  0
                 if (!StringUtils.isEmpty(value)) {
 403  3
                         Admin4JConfiguration.setMemoryThresholdPct(toInteger(value,
 404  
                                         "memory.threshold.pct"));
 405  
                 }
 406  3
                 value = admin4JProps.getProperty("memory.nbr.intervals.between.warnings");
 407  0
                 if (!StringUtils.isEmpty(value)) {
 408  3
                         Admin4JConfiguration.setMemoryNbrIntervalsBetweenWarnings(toInteger(
 409  
                                         value, "memory.nbr.intervals.between.warnings"));
 410  
                 }
 411  3
                 value = admin4JProps.getProperty("memory.nbr.low.watermark.intervals");
 412  0
                 if (!StringUtils.isEmpty(value)) {
 413  3
                         Admin4JConfiguration.setMemoryNbrLowWatermarkIntervals(toInteger(
 414  
                                         value, "memory.nbr.low.watermark.intervals"));
 415  
                 }
 416  3
                 value = admin4JProps.getProperty("memory.low.watermark.monitor.interval.millis");
 417  0
                 if (!StringUtils.isEmpty(value)) {
 418  3
                         Admin4JConfiguration.setMemoryLowWatermarkMonitorIntervalInMillis(toLong(
 419  
                                         value, "memory.low.watermark.monitor.interval.millis"));
 420  
                 }
 421  
 
 422  3
                 value = admin4JProps.getProperty("thread.sleep.interval.millis");
 423  0
                 if (!StringUtils.isEmpty(value)) {
 424  3
                         Admin4JConfiguration.setThreadSleepIntervalMillis(toInteger(value,
 425  
                                         "thread.sleep.interval.millis"));
 426  
                 }
 427  3
                 value = admin4JProps.getProperty("thread.max.blocked.threads");
 428  0
                 if (!StringUtils.isEmpty(value)) {
 429  3
                         Admin4JConfiguration.setThreadMaxBlockedThreads(toInteger(value,
 430  
                                         "thread.max.blocked.threads"));
 431  
                 }
 432  
 
 433  3
                 value = admin4JProps.getProperty("web.transaction.error.logger.name");
 434  0
                 if (!StringUtils.isEmpty(value)) {
 435  3
                         Admin4JConfiguration.setWebTransactionErrorLoggerName(value);
 436  
                 }
 437  
 
 438  3
                 value = admin4JProps.getProperty("error.notification.time.interval.millis");
 439  0
                 if (!StringUtils.isEmpty(value)) {
 440  3
                         Admin4JConfiguration.setErrorNotificationTimeIntervalMillis(toLong(
 441  
                                         value, "error.notification.time.interval.millis"));
 442  
                 }
 443  
 
 444  3
                 value = admin4JProps.getProperty("error.exempted.exception.types");
 445  0
                 if (!StringUtils.isEmpty(value)) {
 446  3
                         Admin4JConfiguration.setErrorExemptedExceptionTypes(value);
 447  
                 }
 448  
 
 449  3
                 value = admin4JProps.getProperty("web.transaction.performance.notification.threshold.in.millis");
 450  0
                 if (!StringUtils.isEmpty(value)) {
 451  3
                         Admin4JConfiguration.setWebTransactionPerformanceNotificationThresholdInMillis(toLong(
 452  
                                         value,
 453  
                                         "web.transaction.performance.notification.threshold.in.millis"));
 454  
                 }
 455  
 
 456  3
                 value = admin4JProps.getProperty("sql.nbr.retained.sql.statements");
 457  0
                 if (!StringUtils.isEmpty(value)) {
 458  3
                         Admin4JConfiguration.setSqlNbrRetainedSqlStatements(toInteger(
 459  
                                         value, "sql.nbr.retained.sql.statements"));
 460  
                 }
 461  
 
 462  3
                 value = admin4JProps.getProperty("sql.retention.time.in.millis");
 463  0
                 if (!StringUtils.isEmpty(value)) {
 464  3
                         Admin4JConfiguration.setSqlRetentionTimeInMillis(toLong(value,
 465  
                                         "sql.retention.time.in.millis"));
 466  
                 }
 467  
 
 468  3
                 value = admin4JProps.getProperty("usage.sleep.interval.millis");
 469  0
                 if (!StringUtils.isEmpty(value)) {
 470  3
                         Admin4JConfiguration.setConcurrentUsageSleepIntervalMillis(toInteger(
 471  
                                         value, "usage.sleep.interval.millis"));
 472  
                 }
 473  
 
 474  3
                 value = admin4JProps.getProperty("usage.alert.levels");
 475  0
                 if (!StringUtils.isEmpty(value)) {
 476  
                         try {
 477  
                                 String[] levelStr = StringUtils.split(value, ",");
 478  3
                                 Integer[] alertLevels = new Integer[levelStr.length];
 479  12
                                 for (int i = 0; i < levelStr.length; i++) {
 480  9
                                         alertLevels[i] = Integer.valueOf(levelStr[i].trim());
 481  
                                 }
 482  3
                                 Admin4JConfiguration.setConcurrentUsageAlertLevels(alertLevels);
 483  0
                         } catch (Exception e) {
 484  
                                 logger.error(
 485  
                                                 "Illegal property value in admin4j properties file",
 486  
                                                 new Admin4jRuntimeException(e).addContextValue(
 487  
                                                                 "propName", "usage.alert.levels")
 488  
                                                                 .addContextValue("value", value));
 489  3
                         }
 490  
                 }
 491  
 
 492  3
                 value = admin4JProps.getProperty("request.history.nbr.retained");
 493  0
                 if (!StringUtils.isEmpty(value)) {
 494  3
                         Admin4JConfiguration.setRequestHistoryNbrRetained(toInteger(value,
 495  
                                         "request.history.nbr.retained"));
 496  
                 }
 497  
 
 498  3
                 value = admin4JProps.getProperty("performance.uri.consolidator");
 499  0
                 if (!StringUtils.isEmpty(value)) {
 500  
                         try {
 501  0
                                 Admin4JConfiguration.setPerformanceRestUriConsolidator((HttpRequestConsolidator) Class.forName(
 502  
                                                 value)
 503  
                                                 .newInstance());
 504  0
                         } catch (Exception e) {
 505  0
                                 throw new Admin4jRuntimeException(
 506  
                                                 "performance.uri.consolidator cannot be instantiated",
 507  
                                                 e).addContextValue("performance.uri.consolidator",
 508  
                                                                 value);
 509  0
                         }
 510  0
                         Admin4JConfiguration.getPerformanceRestUriConsolidator()
 511  
                                         .configure(null, admin4JProps);
 512  
                 }
 513  
 
 514  3
         }
 515  
 }