diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-07-13 11:52:51 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-07-21 14:18:59 +0200 |
commit | 4e6b846c342b2c9e9443e3d3472685e5acb32fa3 (patch) | |
tree | df8990c71077f8561b94c6055dfe3e2b59fa32e3 /v3po/impl/src | |
parent | 758f3cc154d28df97b3995344e0c67190c50a035 (diff) |
HONEYCOMB-122 Update reader registry to share similar APIs as writer
+ Extract common registry builder base code
(Reader registry is not flat, so there is not full control over ordering as with writers
but it is sufficient)
+ Split CompositeReader into CompositeReader, SubtreeReader and GenericReader
+ No need to build composite structure in ReaderFactories (registry does that internally)
+ Keep only ReaderCustomizer + ListReaderCustomizer, no root reader (same for writers)
Change-Id: Ic4e5bc96ad47a6cbcada4efcc2209db5c16d2a6c
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl/src')
6 files changed, 63 insertions, 18 deletions
diff --git a/v3po/impl/src/main/config/context-datatree-config.xml b/v3po/impl/src/main/config/context-datatree-config.xml index 02d2f61d4..2c17de15e 100644 --- a/v3po/impl/src/main/config/context-datatree-config.xml +++ b/v3po/impl/src/main/config/context-datatree-config.xml @@ -102,10 +102,10 @@ <module> <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:delegating-reader-registry</type> <name>read-registry</name> - <root-readers> - <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader</type> + <reader-factory> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-factory</type> <name>context-reader</name> - </root-readers> + </reader-factory> </module> <!-- END: Special reader for Context --> @@ -122,7 +122,7 @@ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> <service> - <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader</type> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-factory</type> <instance> <name>context-reader</name> <provider>/modules/module[type='context-reader'][name='context-reader']</provider> diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index cc6c7c6e2..63f40c624 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -105,10 +105,10 @@ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type> <name>runtime-mapping-singleton</name> </serializer> - <reader-registry> + <reader-registry-builder> <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-registry</type> <name>read-registry</name> - </reader-registry> + </reader-registry-builder> <context-binding-broker> <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> <name>honeycomb-context-binding-data-broker</name> diff --git a/v3po/impl/src/main/config/netconf-north-config.xml b/v3po/impl/src/main/config/netconf-north-config.xml index ef500c68c..35bd5ff04 100644 --- a/v3po/impl/src/main/config/netconf-north-config.xml +++ b/v3po/impl/src/main/config/netconf-north-config.xml @@ -331,10 +331,10 @@ <module> <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:utils">prefix:delegating-reader-registry</type> <name>read-registry</name> - <root-readers> - <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader</type> + <reader-factory> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-factory</type> <name>netconf-monitoring-reader</name> - </root-readers> + </reader-factory> </module> <!-- END: Special reader for Netconf monitoring. --> @@ -364,7 +364,7 @@ </service> <service> - <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader</type> + <type xmlns:prefix="urn:honeycomb:params:xml:ns:yang:translate:api">prefix:honeycomb-reader-factory</type> <instance> <name>netconf-monitoring-reader</name> <provider>/modules/module[type='netconf-monitoring-reader'][name='netconf-monitoring-reader']</provider> diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/ContextReaderModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/ContextReaderModule.java index df22a2bea..c15fe525c 100644 --- a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/ContextReaderModule.java +++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/ContextReaderModule.java @@ -1,9 +1,12 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210; +import io.fd.honeycomb.v3po.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.honeycomb.v3po.translate.util.read.BindingBrokerReader; -import io.fd.honeycomb.v3po.translate.util.read.CloseableReader; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.Contexts; +import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.ContextsBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * A reader to provide mapping context related data @@ -24,8 +27,27 @@ public class ContextReaderModule extends org.opendaylight.yang.gen.v1.urn.openda @Override public java.lang.AutoCloseable createInstance() { - return new CloseableReader<>(new BindingBrokerReader<>(Contexts.class, getContextBindingBrokerDependency(), - LogicalDatastoreType.OPERATIONAL)); + return new ReaderFactory(getContextBindingBrokerDependency()); } + private static final class ReaderFactory implements AutoCloseable, io.fd.honeycomb.v3po.translate.read.ReaderFactory { + + private final DataBroker contextBindingBrokerDependency; + + public ReaderFactory(final DataBroker contextBindingBrokerDependency) { + this.contextBindingBrokerDependency = contextBindingBrokerDependency; + } + + @Override + public void init(final ModifiableReaderRegistryBuilder registry) { + registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(Contexts.class), + contextBindingBrokerDependency, + LogicalDatastoreType.OPERATIONAL, ContextsBuilder.class)); + } + + @Override + public void close() throws Exception { + // TODO no unregister + } + } } diff --git a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfMonitoringReaderModule.java b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfMonitoringReaderModule.java index feb7768a2..455751858 100644 --- a/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfMonitoringReaderModule.java +++ b/v3po/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/v3po/impl/rev141210/NetconfMonitoringReaderModule.java @@ -1,9 +1,12 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210; +import io.fd.honeycomb.v3po.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.honeycomb.v3po.translate.util.read.BindingBrokerReader; -import io.fd.honeycomb.v3po.translate.util.read.CloseableReader; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfStateBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class NetconfMonitoringReaderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfMonitoringReaderModule { public NetconfMonitoringReaderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { @@ -21,8 +24,28 @@ public class NetconfMonitoringReaderModule extends org.opendaylight.yang.gen.v1. @Override public java.lang.AutoCloseable createInstance() { - return new CloseableReader<>(new BindingBrokerReader<>(NetconfState.class, getNetconfMonitoringBindingBrokerDependency(), - LogicalDatastoreType.OPERATIONAL)); + return new ReaderFactory(getNetconfMonitoringBindingBrokerDependency()); } + + private static final class ReaderFactory implements AutoCloseable, io.fd.honeycomb.v3po.translate.read.ReaderFactory { + + private final DataBroker netconfMonitoringBindingBrokerDependency; + + public ReaderFactory(final DataBroker netconfMonitoringBindingBrokerDependency) { + this.netconfMonitoringBindingBrokerDependency = netconfMonitoringBindingBrokerDependency; + } + + @Override + public void init(final ModifiableReaderRegistryBuilder registry) { + registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(NetconfState.class), + netconfMonitoringBindingBrokerDependency, + LogicalDatastoreType.OPERATIONAL, NetconfStateBuilder.class)); + } + + @Override + public void close() throws Exception { + // TODO no unregister + } + } } diff --git a/v3po/impl/src/main/yang/v3po-impl.yang b/v3po/impl/src/main/yang/v3po-impl.yang index 40b00ec96..065e99fbb 100644 --- a/v3po/impl/src/main/yang/v3po-impl.yang +++ b/v3po/impl/src/main/yang/v3po-impl.yang @@ -135,7 +135,7 @@ module v3po-impl { identity netconf-monitoring-reader { base config:module-type; - config:provided-service tapi:honeycomb-reader; + config:provided-service tapi:honeycomb-reader-factory; } augment "/config:modules/config:module/config:configuration" { @@ -156,7 +156,7 @@ module v3po-impl { identity context-reader { base config:module-type; - config:provided-service tapi:honeycomb-reader; + config:provided-service tapi:honeycomb-reader-factory; description "A reader to provide mapping context related data"; } |