summaryrefslogtreecommitdiffstats
path: root/infra/translate-impl/src/main/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-01-09 08:23:45 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-01-10 07:41:32 +0000
commit98666a011d7538ac9742a8351856f76fbe7d8e69 (patch)
tree1b955cd53a0a78eefb9e1c04413fd3f7dd0b6b9a /infra/translate-impl/src/main/java/io/fd
parent75f0efb8b1aff9e9be8d222fd90d1df7ce542bbc (diff)
HONEYCOMB-331: unify initialization handling
Due to incorrect instance of check, InitSubtreeReader was never created in CompositeReaderRegistryBuilder.getSubtreeHandler(). As a consequence, initializers registered by subtreeAdd*, were not invoked. The patch: - fixes mentioned check, - makes readers implement InitReader instead of directly implementing Initializer - includes missing unit tests for GenericReaders. Change-Id: I93be59fafddb60dce00191958b5c8c62e7c2d289 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/translate-impl/src/main/java/io/fd')
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java4
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReader.java3
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java5
-rw-r--r--infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/InitSubtreeReader.java7
4 files changed, 10 insertions, 9 deletions
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
index 024e0a815..e55bc8ab6 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericInitReader.java
@@ -20,7 +20,7 @@ import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastor
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.InitFailedException;
-import io.fd.honeycomb.translate.read.Initializer;
+import io.fd.honeycomb.translate.read.InitReader;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
public final class GenericInitReader<O extends DataObject, B extends Builder<O>>
extends GenericReader<O, B>
- implements Initializer<O> {
+ implements InitReader<O, B> {
private static final Logger LOG = LoggerFactory.getLogger(GenericInitReader.class);
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReader.java
index ec82b3f7f..2eca8954c 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReader.java
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import io.fd.honeycomb.translate.read.InitFailedException;
import io.fd.honeycomb.translate.read.InitListReader;
+import io.fd.honeycomb.translate.read.InitReader;
import io.fd.honeycomb.translate.read.Initializer;
import io.fd.honeycomb.translate.read.ListReader;
import io.fd.honeycomb.translate.read.ReadContext;
@@ -47,7 +48,7 @@ import org.slf4j.LoggerFactory;
class CompositeReader<D extends DataObject, B extends Builder<D>>
extends AbstractGenericReader<D, B>
- implements Initializer<D>, DelegatingReader<D, B> {
+ implements InitReader<D, B>, DelegatingReader<D, B> {
private static final Logger LOG = LoggerFactory.getLogger(CompositeReader.class);
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
index 290c5d4aa..36ab90995 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java
@@ -19,6 +19,7 @@ package io.fd.honeycomb.translate.impl.read.registry;
import com.google.common.collect.ImmutableMap;
import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.InitReader;
+import io.fd.honeycomb.translate.read.Initializer;
import io.fd.honeycomb.translate.read.Reader;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
@@ -46,8 +47,8 @@ public final class CompositeReaderRegistryBuilder
@Override
protected Reader<? extends DataObject, ? extends Builder<?>> getSubtreeHandler(@Nonnull final Set<InstanceIdentifier<?>> handledChildren,
@Nonnull final Reader<? extends DataObject, ? extends Builder<?>> reader) {
- return reader instanceof InitReader
- ? InitSubtreeReader.createForReader(handledChildren, reader)
+ return reader instanceof Initializer
+ ? InitSubtreeReader.createForReader(handledChildren, (InitReader<?, ?>)reader)
: SubtreeReader.createForReader(handledChildren, reader);
}
diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/InitSubtreeReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/InitSubtreeReader.java
index 809cdb214..e7cef8107 100644
--- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/InitSubtreeReader.java
+++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/InitSubtreeReader.java
@@ -21,7 +21,6 @@ import io.fd.honeycomb.translate.read.InitListReader;
import io.fd.honeycomb.translate.read.InitReader;
import io.fd.honeycomb.translate.read.ListReader;
import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.read.Reader;
import java.util.Set;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -48,11 +47,11 @@ class InitSubtreeReader<O extends DataObject, B extends Builder<O>>
/**
* Wrap a Reader as an initializing subtree Reader.
*/
- static <D extends DataObject, B extends Builder<D>> Reader<D, B> createForReader(@Nonnull final Set<InstanceIdentifier<?>> handledChildren,
- @Nonnull final Reader<D, B> reader) {
+ static <D extends DataObject, B extends Builder<D>> InitReader<D, B> createForReader(@Nonnull final Set<InstanceIdentifier<?>> handledChildren,
+ @Nonnull final InitReader<D, B> reader) {
return (reader instanceof ListReader)
? new InitSubtreeListReader<>((InitListReader) reader, handledChildren)
- : new InitSubtreeReader<>(((InitReader<D, B>) reader), handledChildren);
+ : new InitSubtreeReader<>(reader, handledChildren);
}
private static class InitSubtreeListReader<D extends DataObject & Identifiable<K>, B extends Builder<D>, K extends Identifier<D>>