private final Persister storage;
private final boolean readOnly;
- public PersisterWithConfiguration(Persister storage, boolean readOnly) {
+ public PersisterWithConfiguration(final Persister storage, final boolean readOnly) {
this.storage = storage;
this.readOnly = readOnly;
}
}
}
+ /**
+ * Persisters ordered by 'netconf.config.persister' property.
+ */
+ private final List<PersisterWithConfiguration> persisterWithConfigurations;
+
+ public PersisterAggregator(final List<PersisterWithConfiguration> persisterWithConfigurations) {
+ this.persisterWithConfigurations = persisterWithConfigurations;
+ }
+
private static PersisterWithConfiguration loadConfiguration(final String index, final PropertiesProvider propertiesProvider) {
String classKey = index + "." + ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX;
String storageAdapterClass = propertiesProvider.getProperty(classKey);
StorageAdapter storageAdapter;
- if (storageAdapterClass == null || storageAdapterClass.equals("")) {
+ if (storageAdapterClass == null || storageAdapterClass.isEmpty()) {
throw new IllegalStateException("No persister is defined in " +
propertiesProvider.getFullKeyForReporting(classKey)
+ " property. Persister is not operational");
}
storageAdapter = StorageAdapter.class.cast(clazz.newInstance());
- boolean readOnly = false;
String readOnlyProperty = propertiesProvider.getProperty(index + "." + "readonly");
- if (readOnlyProperty != null && readOnlyProperty.equals("true")) {
- readOnly = true;
- }
+ boolean readOnly = Boolean.parseBoolean(readOnlyProperty);
PropertiesProviderAdapterImpl innerProvider = new PropertiesProviderAdapterImpl(propertiesProvider, index);
Persister storage = storageAdapter.instantiate(innerProvider);
}
}
- /**
- * Persisters ordered by 'netconf.config.persister' property.
- */
- private final List<PersisterWithConfiguration> persisterWithConfigurations;
-
- public PersisterAggregator(List<PersisterWithConfiguration> persisterWithConfigurations) {
- this.persisterWithConfigurations = persisterWithConfigurations;
-
- }
-
- public static PersisterAggregator createFromProperties(PropertiesProvider propertiesProvider) {
+ public static PersisterAggregator createFromProperties(final PropertiesProvider propertiesProvider) {
List<PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
String prefixes = propertiesProvider.getProperty("active");
if (prefixes!=null && !prefixes.isEmpty()) {
}
@Override
- public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+ public void persistConfig(final ConfigSnapshotHolder holder) throws IOException {
for (PersisterWithConfiguration persisterWithConfiguration: persisterWithConfigurations){
if (!persisterWithConfiguration.readOnly){
LOG.debug("Calling {}.persistConfig", persisterWithConfiguration.getStorage());
List<ConfigSnapshotHolder> configs = null;
try {
configs = persisterWithConfiguration.storage.loadLastConfigs();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException("Error while calling loadLastConfig on " + persisterWithConfiguration, e);
}
if (!configs.isEmpty()) {
for (PersisterWithConfiguration persisterWithConfiguration: persisterWithConfigurations){
try{
persisterWithConfiguration.storage.close();
- }catch(RuntimeException e) {
+ }catch(final RuntimeException e) {
LOG.error("Error while closing {}", persisterWithConfiguration.storage, e);
if (lastException == null){
lastException = e;