[Minor] Added AbstractionConfiguration.getAsProperties()

This commit is contained in:
Robert von Burg 2016-09-08 11:20:06 +02:00
parent 9602313410
commit 3f2c749659
2 changed files with 17 additions and 3 deletions

View File

@ -104,7 +104,7 @@ public abstract class InternalStrolchRealm implements StrolchRealm {
String propTryLockTimeUnit = StrolchConstants.makeRealmKey(this.realm, PROP_TRY_LOCK_TIME_UNIT);
String propTryLockTime = StrolchConstants.makeRealmKey(this.realm, PROP_TRY_LOCK_TIME);
TimeUnit timeUnit = TimeUnit.valueOf(configuration.getString(propTryLockTimeUnit, TimeUnit.SECONDS.name()));
long time = configuration.getLong(propTryLockTime, 10);
long time = configuration.getLong(propTryLockTime, 10L);
this.lockHandler = new DefaultLockHandler(this.realm, timeUnit, time);
// versioning

View File

@ -17,8 +17,10 @@ package li.strolch.runtime.configuration;
import java.io.File;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.slf4j.Logger;
@ -42,6 +44,18 @@ public abstract class AbstractionConfiguration {
return this.name;
}
public Properties getAsProperties() {
Properties props = new Properties();
for (String key : configurationValues.keySet()) {
props.setProperty(key, configurationValues.get(key));
}
return props;
}
public Map<String, String> getAsMap() {
return new HashMap<>(this.configurationValues);
}
public boolean hasProperty(String key) {
return this.configurationValues.containsKey(key);
}
@ -82,7 +96,7 @@ public abstract class AbstractionConfiguration {
return defValue;
}
public int getInt(String key, int defValue) {
public int getInt(String key, Integer defValue) {
String value = this.configurationValues.get(key);
if (StringHelper.isNotEmpty(value)) {
@ -100,7 +114,7 @@ public abstract class AbstractionConfiguration {
return defValue;
}
public long getLong(String key, long defValue) {
public long getLong(String key, Long defValue) {
String value = this.configurationValues.get(key);
if (StringHelper.isNotEmpty(value)) {