Scripting support
[lgpl/argeo-commons.git] / org.argeo.osgi.boot / src / org / argeo / osgi / boot / OsgiBootUtils.java
index 54efffc8056504f7e15234c4791b742a7a406366..455c96198b3d76f1e8c344608db3b1f08a0a6d54 100644 (file)
@@ -29,12 +29,16 @@ public class OsgiBootUtils {
        /** ISO8601 (as per log4j) and difference to UTC */\r
        private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS Z");\r
 \r
+       static boolean debug = System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_DEBUG) == null ? false\r
+                       : !System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BOOT_DEBUG).trim().equals("false");\r
+\r
        public static void info(Object obj) {\r
                System.out.println("# OSGiBOOT      # " + dateFormat.format(new Date()) + " # " + obj);\r
        }\r
 \r
        public static void debug(Object obj) {\r
-               System.out.println("# OSGiBOOT DBG  # " + dateFormat.format(new Date()) + " # " + obj);\r
+               if (debug)\r
+                       System.out.println("# OSGiBOOT DBG  # " + dateFormat.format(new Date()) + " # " + obj);\r
        }\r
 \r
        public static void warn(Object obj) {\r
@@ -47,26 +51,8 @@ public class OsgiBootUtils {
                        e.printStackTrace();\r
        }\r
 \r
-       /**\r
-        * Gets a property value\r
-        * \r
-        * @return null when defaultValue is ""\r
-        */\r
-       public static String getProperty(String name, String defaultValue) {\r
-               final String value;\r
-               if (defaultValue != null)\r
-                       value = System.getProperty(name, defaultValue);\r
-               else\r
-                       value = System.getProperty(name);\r
-\r
-               if (value == null || value.equals(""))\r
-                       return null;\r
-               else\r
-                       return value;\r
-       }\r
-\r
-       public static String getProperty(String name) {\r
-               return getProperty(name, null);\r
+       public static boolean isDebug() {\r
+               return debug;\r
        }\r
 \r
        public static String stateAsString(int state) {\r
@@ -89,7 +75,7 @@ public class OsgiBootUtils {
        }\r
 \r
        /**\r
-        * @return ==0: versions are identical, <0: tested version is newer, >0:\r
+        * @return ==0: versions are identical, &lt;0: tested version is newer, &gt;0:\r
         *         currentVersion is newer.\r
         */\r
        public static int compareVersions(String currentVersion, String testedVersion) {\r