From 8764f31fa74942d963dc85dd53227e980ceadf44 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Sun, 10 Apr 2016 23:45:43 +0200 Subject: HONEYCOMB-34: Configurable ConfigDataTree dependency Change-Id: I17a93835541e66835398391e2a127b25767b774a Signed-off-by: Marek Gradzki --- .../fd/honeycomb/v3po/data/impl/ConfigDataTree.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'v3po/data-impl/src/main/java/io/fd/honeycomb') diff --git a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java index f636e6708..59a555fda 100644 --- a/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java +++ b/v3po/data-impl/src/main/java/io/fd/honeycomb/v3po/data/impl/ConfigDataTree.java @@ -57,7 +57,7 @@ public final class ConfigDataTree implements ModifiableDataTree { private final BindingNormalizedNodeSerializer serializer; private final DataTree dataTree; - private final WriterRegistry writer; + private final WriterRegistry writerRegistry; public static final ReadableDataTree EMPTY_OPERATIONAL = new ReadableDataTree() { @Override public CheckedFuture>, ReadFailedException> read( @@ -69,16 +69,17 @@ public final class ConfigDataTree implements ModifiableDataTree { /** * Creates configuration data tree instance. * - * @param serializer service for serialization between Java Binding Data representation and NormalizedNode - * representation. - * @param dataTree data tree for configuration data representation - * @param writer service for translation between Java Binding Data and data provider. + * @param serializer service for serialization between Java Binding Data representation and NormalizedNode + * representation. + * @param dataTree data tree for configuration data representation + * @param writerRegistry service for translation between Java Binding Data and data provider, capable of performing + * bulk updates. */ public ConfigDataTree(@Nonnull final BindingNormalizedNodeSerializer serializer, - @Nonnull final DataTree dataTree, @Nonnull final WriterRegistry writer) { + @Nonnull final DataTree dataTree, @Nonnull final WriterRegistry writerRegistry) { this.serializer = checkNotNull(serializer, "serializer should not be null"); this.dataTree = checkNotNull(dataTree, "dataTree should not be null"); - this.writer = checkNotNull(writer, "writer should not be null"); + this.writerRegistry = checkNotNull(writerRegistry, "writerRegistry should not be null"); } @Override @@ -110,8 +111,8 @@ public final class ConfigDataTree implements ModifiableDataTree { final DOMDataReadOnlyTransaction beforeTx = new ReadOnlyTransaction(EMPTY_OPERATIONAL, takeSnapshot()); final ConfigSnapshot modificationSnapshot = new ConfigSnapshot(modification); final DOMDataReadOnlyTransaction afterTx = new ReadOnlyTransaction(EMPTY_OPERATIONAL, modificationSnapshot); - try(final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) { - writer.update(nodesBefore, nodesAfter, ctx); + try (final WriteContext ctx = new TransactionWriteContext(serializer, beforeTx, afterTx)) { + writerRegistry.update(nodesBefore, nodesAfter, ctx); } catch (io.fd.honeycomb.v3po.translate.write.WriterRegistry.BulkUpdateException e) { LOG.warn("Failed to apply all changes", e); LOG.info("Trying to revert successful changes for current transaction"); -- cgit 1.2.3-korg