From 3edb738db9c756d42ee5c0b6fa172b6f2caa808a Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 11 Apr 2016 21:23:57 +0200 Subject: HONEYCOMB-34: Config tree initialization using binding data broker Change-Id: I070aca2cc35dd10ea5bde19c8cbf4cad1c50f468 Signed-off-by: Marek Gradzki --- .../data/impl/rev160411/ConfigDataTreeModule.java | 17 +---- .../rev160411/InMemoryConfigDataTreeModule.java | 81 ++++++++++++++++++++++ .../InMemoryConfigDataTreeModuleFactory.java | 13 ++++ .../impl/rev160411/OperationalDataTreeModule.java | 4 +- 4 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java create mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java (limited to 'v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml') diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java index 19267b1bd..86a3f9db4 100644 --- a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/ConfigDataTreeModule.java @@ -4,11 +4,8 @@ import io.fd.honeycomb.v3po.data.DataTreeSnapshot; import io.fd.honeycomb.v3po.data.ModifiableDataTree; import io.fd.honeycomb.v3po.data.impl.ConfigDataTree; import io.fd.honeycomb.v3po.translate.TranslationException; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; -import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; -import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,11 +33,9 @@ public class ConfigDataTreeModule extends @Override public java.lang.AutoCloseable createInstance() { - LOG.info("ConfigDataTreeModule.createInstance()"); - final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); - dataTree.setSchemaContext(getSchemaServiceDependency().getGlobalContext()); + LOG.debug("ConfigDataTreeModule.createInstance()"); return new CloseableConfigDataTree( - new ConfigDataTree(getSerializerDependency(), dataTree, getWriterRegistryDependency())); + new ConfigDataTree(getSerializerDependency(), getDataTreeDependency(), getWriterRegistryDependency())); } private static final class CloseableConfigDataTree implements ModifiableDataTree, AutoCloseable { @@ -53,7 +48,7 @@ public class ConfigDataTreeModule extends @Override public void close() throws Exception { - LOG.info("CloseableConfigDataTree.close()"); + LOG.debug("CloseableConfigDataTree.close()"); // NOP } @@ -64,12 +59,6 @@ public class ConfigDataTreeModule extends delegate.modify(modification); } - @Override - public void initialize(final DataTreeModification modification) throws DataValidationFailedException { - LOG.trace("CloseableConfigDataTree.initialize modification={}", modification); - delegate.initialize(modification); - } - @Override public DataTreeSnapshot takeSnapshot() { LOG.trace("CloseableConfigDataTree.takeSnapshot"); diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java new file mode 100644 index 000000000..9ae8a01f5 --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java @@ -0,0 +1,81 @@ +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411; + +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; +import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; +import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class InMemoryConfigDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModule { + + private static final Logger LOG = LoggerFactory.getLogger(InMemoryConfigDataTreeModule.class); + + public InMemoryConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public InMemoryConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.InMemoryConfigDataTreeModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + LOG.debug("InMemoryConfigDataTreeModule.createInstance()"); + return new CloseableConfigDataTree(getSchemaServiceDependency().getGlobalContext()); + } + + private static class CloseableConfigDataTree implements AutoCloseable, DataTree { + private final DataTree dataTree; + + public CloseableConfigDataTree(final SchemaContext schemaContext) { + this.dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION); + dataTree.setSchemaContext(schemaContext); + } + + @Override + public void close() throws Exception { + // NOP + } + + @Override + public DataTreeSnapshot takeSnapshot() { + return dataTree.takeSnapshot(); + } + + @Override + public void setSchemaContext(final SchemaContext newSchemaContext) { + dataTree.setSchemaContext(newSchemaContext); + } + + @Override + public void commit(final DataTreeCandidate candidate) { + dataTree.commit(candidate); + } + + @Override + public YangInstanceIdentifier getRootPath() { + return dataTree.getRootPath(); + } + + @Override + public void validate(final DataTreeModification modification) throws DataValidationFailedException { + dataTree.validate(modification); + } + + @Override + public DataTreeCandidate prepare(final DataTreeModification modification) { + return dataTree.prepare(modification); + } + } +} diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java new file mode 100644 index 000000000..504e007c0 --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: data-impl yang module local name: inmemory-config-data-tree +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Tue Apr 12 07:26:54 CEST 2016 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411; +public class InMemoryConfigDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryConfigDataTreeModuleFactory { + +} diff --git a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java index 0034b12c5..24a1ca519 100644 --- a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/OperationalDataTreeModule.java @@ -35,7 +35,7 @@ public class OperationalDataTreeModule extends @Override public java.lang.AutoCloseable createInstance() { - LOG.info("OperationalDataTreeModule.createInstance()"); + LOG.debug("OperationalDataTreeModule.createInstance()"); return new CloseableOperationalDataTree( new OperationalDataTree(getSerializerDependency(), getSchemaServiceDependency().getGlobalContext(), getReaderRegistryDependency())); @@ -51,7 +51,7 @@ public class OperationalDataTreeModule extends @Override public void close() throws Exception { - LOG.info("CloseableOperationalDataTree.close()"); + LOG.debug("CloseableOperationalDataTree.close()"); // NOP } -- cgit 1.2.3-korg