Making number of components configurable using the central component configuration subsystem.
Change-Id: Ia32c51480913689339a766d9849e792d62f7d133
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index e3a3a41..b788038 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -35,6 +35,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Dictionary;
import java.util.List;
import java.util.concurrent.ThreadFactory;
@@ -142,6 +143,20 @@
}
/**
+ * Get property as a string value.
+ *
+ * @param properties properties to be looked up
+ * @param propertyName the name of the property to look up
+ * @return value when the propertyName is defined or return null
+ */
+ public static String get(Dictionary<?, ?> properties, String propertyName) {
+ Object v = properties.get(propertyName);
+ String s = (v instanceof String) ? (String) v :
+ v != null ? v.toString() : null;
+ return Strings.isNullOrEmpty(s) ? null : s.trim();
+ }
+
+ /**
* Suspends the current thread for a specified number of millis.
*
* @param ms number of millis