[Minor] Extract Realm instantiation into method

This commit is contained in:
Robert von Burg 2020-01-08 09:11:00 +01:00
parent c96ca434be
commit d6a8c99b3a
1 changed files with 6 additions and 5 deletions

View File

@ -74,21 +74,22 @@ public class DefaultRealmHandler extends StrolchComponent implements RealmHandle
@Override
public void setup(ComponentConfiguration configuration) {
this.realms = new HashMap<>(1);
String[] realms = configuration.getStringArray(PROP_REALMS, StrolchConstants.DEFAULT_REALM);
for (String realmName : realms) {
String dataStoreModeKey = StrolchConstants.makeRealmKey(realmName, PREFIX_DATA_STORE_MODE);
String realmMode = configuration.getString(dataStoreModeKey, null);
DataStoreMode dataStoreMode = DataStoreMode.parseDataStoreMode(realmMode);
InternalStrolchRealm realm = dataStoreMode.createRealm(realmName);
InternalStrolchRealm realm = buildRealm(realmName, realmMode);
this.realms.put(realmName, realm);
}
super.setup(configuration);
}
protected InternalStrolchRealm buildRealm(String realmName, String realmMode) {
DataStoreMode dataStoreMode = DataStoreMode.parseDataStoreMode(realmMode);
return dataStoreMode.createRealm(realmName);
}
@Override
public void initialize(ComponentConfiguration configuration) throws Exception {