|
|
|
|
@ -16,6 +16,9 @@ public final class ConfigurationManager {
|
|
|
|
|
Logger logger = LogManager.getLogger(); |
|
|
|
|
Properties prop = new Properties(); |
|
|
|
|
|
|
|
|
|
private boolean hasCachedEthAddress = false; |
|
|
|
|
private String cachedEthAddress = null; |
|
|
|
|
|
|
|
|
|
private DatabaseManager databaseManager; |
|
|
|
|
|
|
|
|
|
public DatabaseManager getDatabaseManager() { |
|
|
|
|
@ -124,4 +127,33 @@ public final class ConfigurationManager {
|
|
|
|
|
public void forEach(BiConsumer<? super Object, ? super Object> action) { |
|
|
|
|
prop.forEach(action); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Special handling for getting the ethernet address
|
|
|
|
|
public String getEthAddress(){ |
|
|
|
|
if(hasCachedEthAddress){ |
|
|
|
|
return cachedEthAddress; |
|
|
|
|
} |
|
|
|
|
String addr = prop.getProperty("uuid.ethAddr"); |
|
|
|
|
if (addr == null){ |
|
|
|
|
//There are no ethernet address available. Return null
|
|
|
|
|
hasCachedEthAddress = true; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
for(char ch:addr.toCharArray()){ |
|
|
|
|
if(ch>='0'&&ch<='9'){ |
|
|
|
|
sb.append(ch); |
|
|
|
|
}else if ((ch >= 'a' && ch <= 'f') ||(ch>='A'&&ch<='F')) { |
|
|
|
|
sb.append(Character.toLowerCase(ch)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(sb.length()==12){ |
|
|
|
|
cachedEthAddress = sb.toString(); |
|
|
|
|
hasCachedEthAddress = true; |
|
|
|
|
return cachedEthAddress; |
|
|
|
|
}else{ |
|
|
|
|
hasCachedEthAddress=true; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|