From 5f10c13fc3bff497f6556f0538b08060e4f28105 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Fri, 13 May 2016 11:24:15 +0200 Subject: HONEYCOMB-61: Make InmemoryDataTree module type configurable Change-Id: Ie73eac8960a76ebcc578d3b44c50492f29908e24 Signed-off-by: Maros Marsalek --- .../rev160411/InMemoryConfigDataTreeModule.java | 81 ---------------------- .../InMemoryConfigDataTreeModuleFactory.java | 13 ---- .../impl/rev160411/InMemoryDataTreeModule.java | 79 +++++++++++++++++++++ .../rev160411/InMemoryDataTreeModuleFactory.java | 13 ++++ v3po/data-impl/src/main/yang/data-impl.yang | 19 +++-- v3po/impl/src/main/config/default-config.xml | 5 +- 6 files changed, 110 insertions(+), 100 deletions(-) delete mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java delete mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java create mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModule.java create mode 100644 v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModuleFactory.java (limited to 'v3po') 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 deleted file mode 100644 index 9ae8a01f5..000000000 --- a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModule.java +++ /dev/null @@ -1,81 +0,0 @@ -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 deleted file mode 100644 index 504e007c0..000000000 --- a/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryConfigDataTreeModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* 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/InMemoryDataTreeModule.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModule.java new file mode 100644 index 000000000..54c830ec0 --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModule.java @@ -0,0 +1,79 @@ +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.*; +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 InMemoryDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryDataTreeModule { + + private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModule.class); + + public InMemoryDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public InMemoryDataTreeModule(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.InMemoryDataTreeModule 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(), getType()); + } + + private static class CloseableConfigDataTree implements AutoCloseable, + org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree { + private final org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree dataTree; + + public CloseableConfigDataTree(final SchemaContext schemaContext, final DatatreeType type) { + this.dataTree = InMemoryDataTreeFactory.getInstance().create( + type == DatatreeType.Config ? TreeType.CONFIGURATION : TreeType.OPERATIONAL + ); + 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/InMemoryDataTreeModuleFactory.java b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModuleFactory.java new file mode 100644 index 000000000..34a543949 --- /dev/null +++ b/v3po/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: data-impl yang module local name: inmemory-data-tree +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri May 13 11:10:56 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 InMemoryDataTreeModuleFactory extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryDataTreeModuleFactory { + +} diff --git a/v3po/data-impl/src/main/yang/data-impl.yang b/v3po/data-impl/src/main/yang/data-impl.yang index fa6c6f06d..da1c02316 100644 --- a/v3po/data-impl/src/main/yang/data-impl.yang +++ b/v3po/data-impl/src/main/yang/data-impl.yang @@ -23,15 +23,22 @@ module data-impl { config:java-class org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; } - identity inmemory-config-data-tree { + identity inmemory-data-tree { base config:module-type; config:provided-service data-tree; - config:java-name-prefix InMemoryConfigDataTree; + config:java-name-prefix InMemoryDataTree; + } + + typedef datatree-type { + type enumeration { + enum config; + enum oper; + } } augment "/config:modules/config:module/config:configuration" { - case inmemory-config-data-tree { - when "/config:modules/config:module/config:type = 'inmemory-config-data-tree'"; + case inmemory-data-tree { + when "/config:modules/config:module/config:type = 'inmemory-data-tree'"; container schema-service { uses config:service-ref { @@ -41,6 +48,10 @@ module data-impl { } } } + + leaf type { + type datatree-type; + } } } diff --git a/v3po/impl/src/main/config/default-config.xml b/v3po/impl/src/main/config/default-config.xml index ca09d6e0b..61fe1c68d 100644 --- a/v3po/impl/src/main/config/default-config.xml +++ b/v3po/impl/src/main/config/default-config.xml @@ -39,12 +39,13 @@ - prefix:inmemory-config-data-tree + prefix:inmemory-data-tree inmemory-config-data-tree dom:schema-service yang-schema-service + config @@ -338,7 +339,7 @@ prefix:data-tree inmemory-config-data-tree - /modules/module[type='inmemory-config-data-tree'][name='inmemory-config-data-tree'] + /modules/module[type='inmemory-data-tree'][name='inmemory-config-data-tree'] -- cgit 1.2.3-korg