/*
 * Copyright (c) 2012 Mateusz Parzonka, Eric Bodden
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Mateusz Parzonka - initial API and implementation
 */
package prm4j;

public class Globals {

    public final static boolean DEBUG = isSystemProperty("prm4j.debug", "true");

    public static final int MONITOR_CLEANING_INTERVAL = Integer.parseInt(getSystemProperty(
	    "prm4j.monitorCleaningInterval", "2000"));

    /**
     * Specifies the number of retrieve-operations after which the store will try to clean expired bindings. It will
     * poll the a reference queue and remove the bindings from the store, triggering their resource removal.
     */
    public final static int BINDING_CLEANING_INTERVAL = Integer.parseInt(getSystemProperty(
	    "prm4j.bindingCleaningInterval", "10000"));

    /**
     * Compare the value of a system property.
     * 
     * @param key
     * @param expectedValue
     * @return <code>true</code> if property value is expected value
     */
    static boolean isSystemProperty(String key, String expectedValue) {
	final String value = System.getProperty(key);
	if (value == null) {
	    return false;
	}
	return value.equals(expectedValue);
    }

    static String getSystemProperty(String key, String defaultValue) {
	final String value = System.getProperty(key);
	String result = value != null ? value : defaultValue;
	System.out.println("[prm4j] " + key + "=" + result);
	return result;
    }

}

@@ -391,30 +391,234 @@
 j;%0A%0A
-public class Globals %7B
+/**%0A * Encapsulates configuration via Java System Properties.%0A */%0Apublic class Globals %7B%0A%0A    /**%0A     * Controls configuration printing on application start.%0A     */%0A    public static final boolean PRINT_CONFIGURATION = true;
 %0A%0A  
@@ -1214,32 +1214,185 @@
 l%22, %2210000%22));%0A%0A
+    public final static boolean CHECK_MONITOR_VALIDITY_ON_EACH_UPDATE = getBooleanSystemProperty(%0A%09    %22prm4j.checkMonitorValidityOnEachUpdate%22, true);%0A%0A
     /**%0A     * C
@@ -1685,94 +1685,392 @@
 );%0A%09
-if (
+final boolean result = 
 value 
-=
+!
 = null
-) %7B%0A%09    return false;%0A%09%7D%0A%09return value.equals(expected
+ ? expectedValue.equals(value) : false;%0A%09if (PRINT_CONFIGURATION) %7B%0A%09    System.out.println(%22%5Bprm4j%5D %22 + key + %22=%22 + result);%0A%09%7D%0A%09return result;%0A    %7D%0A%0A    /**%0A     * Return the value of a system property or a default value if undefined.%0A     * %0A     * @param key%0A     * @param default
 Value
-);
 %0A
+ 
     
-%7D%0A
+* @return defined system property or default%0A     */
 %0A   
@@ -2185,16 +2185,22 @@
 (key);%0A%09
+final 
 String r
@@ -2246,16 +2246,48 @@
 Value;%0A%09
+if (PRINT_CONFIGURATION) %7B%0A%09    
 System.o
@@ -2331,16 +2331,542 @@
 esult);%0A
+%09%7D%0A%09return result;%0A    %7D%0A%0A    /**%0A     * Return the value of a system property or a default value if undefined.%0A     * %0A     * @param key%0A     * @param defaultValue%0A     * @return defined system property or default%0A     */%0A    static boolean getBooleanSystemProperty(String key, boolean expectedValue) %7B%0A%09final Boolean value = Boolean.parseBoolean(System.getProperty(key));%0A%09final boolean result = value != null ? value : expectedValue;%0A%09if (PRINT_CONFIGURATION) %7B%0A%09    System.out.println(%22%5Bprm4j%5D %22 + key + %22=%22 + result);%0A%09%7D%0A
 %09return 

Add System property 'checkMonitorValidityOnEachUpdate'