Merge changes Ia268965a,Iefa79f99
authorEd Warnicke <eaw@cisco.com>
Fri, 29 Nov 2013 11:17:38 +0000 (11:17 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 29 Nov 2013 11:17:38 +0000 (11:17 +0000)
* changes:
  Add running configuration data to get netconf operation response
  Add support for configuration attributes based on yang leaves with custom types (typedef) to netconf.

37 files changed:
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/TypeProviderWrapper.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/DependencyAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/SimpleTypeResolver.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java
opendaylight/config/yang-test/pom.xml
opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModule.java
opendaylight/config/yang-test/src/main/yang/config-test-impl.yang
opendaylight/config/yang-test/src/main/yang/types/test-types.yang [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/AttributeIfcSwitchStatement.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/AbstractAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ArrayAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/AttributeConfigElement.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/CompositeAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectXmlReader.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/SimpleAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/SimpleCompositeAttributeReadingStrategy.java [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/mapping/ObjectMapper.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/ObjectResolver.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/ObjectXmlWriter.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleCompositeAttributeWritingStrategy.java [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Config.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/ModuleRuntime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/Runtime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/editConfig.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/rpc.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/rpcInner.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/rpcInnerInner.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/rpcInnerInner_complex_output.xml

index 7490ad6..a2238d1 100644 (file)
@@ -11,6 +11,8 @@ import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 public class TypeProviderWrapper {
     private final TypeProvider typeProvider;
@@ -20,10 +22,15 @@ public class TypeProviderWrapper {
     }
 
     public Type getType(LeafSchemaNode leaf) {
+        TypeDefinition<?> type = leaf.getType();
+        return getType(leaf, type);
+    }
+
+    public Type getType(SchemaNode leaf, TypeDefinition<?> type) {
         Type javaType;
         try {
             javaType = typeProvider.javaTypeForSchemaDefinitionType(
-                    leaf.getType(), leaf);
+                    type, leaf);
             if (javaType == null)
                 throw new IllegalArgumentException("Unknown type received for "
                         + leaf.toString());
@@ -50,4 +57,7 @@ public class TypeProviderWrapper {
         return javaType;
     }
 
+    public String getJMXParamForBaseType(TypeDefinition<?> baseType) {
+        return typeProvider.getConstructorPropertyName(baseType);
+    }
 }
index 5ffc192..ba2edc4 100644 (file)
@@ -13,7 +13,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 public abstract class AbstractAttribute implements AttributeIfc {
     private final String attributeYangName, upperCaseCammelCase,
             lowerCaseCammelCase;
-    private final DataSchemaNode node;
+    protected final DataSchemaNode node;
 
     private static String getLocalName(DataSchemaNode attrNode) {
         return attrNode.getQName().getLocalName();
index b6d60e4..1912b75 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.attribute;
 
-import javax.management.ObjectName;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
 import org.opendaylight.yangtools.binding.generator.util.Types;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
+import javax.management.ObjectName;
+import javax.management.openmbean.SimpleType;
+
 public class DependencyAttribute extends AbstractAttribute implements
         TypedAttribute {
 
@@ -95,7 +94,7 @@ public class DependencyAttribute extends AbstractAttribute implements
     }
 
     @Override
-    public OpenType<?> getOpenType() {
+    public SimpleType<?> getOpenType() {
         return SimpleType.OBJECTNAME;
     }
 
index 59ab0ff..73c7e22 100644 (file)
@@ -11,8 +11,10 @@ import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
 import javax.management.openmbean.SimpleType;
@@ -21,11 +23,15 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
 
     private final Type type;
     private final String nullableDescription, nullableDefault;
+    private final TypeProviderWrapper typeProviderWrapper;
+    private final TypeDefinition<?> typeDefinition;
 
     public JavaAttribute(LeafSchemaNode leaf,
             TypeProviderWrapper typeProviderWrapper) {
         super(leaf);
         this.type = typeProviderWrapper.getType(leaf);
+        this.typeDefinition = leaf.getType();
+        this.typeProviderWrapper = typeProviderWrapper;
         this.nullableDefault = leaf.getDefault();
         this.nullableDescription = leaf.getDescription();
     }
@@ -34,10 +40,22 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
             TypeProviderWrapper typeProviderWrapper) {
         super(leaf);
         this.type = typeProviderWrapper.getType(leaf);
+        this.typeDefinition = leaf.getType();
+        this.typeProviderWrapper = typeProviderWrapper;
         this.nullableDefault = null;
         this.nullableDescription = leaf.getDescription();
     }
 
+    /**
+     * Returns the most base type
+     */
+    private TypeDefinition<?> getBaseType(TypeProviderWrapper typeProviderWrapper, TypeDefinition<?> baseType) {
+        while(baseType.getBaseType()!=null) {
+            baseType = baseType.getBaseType();
+        }
+        return baseType;
+    }
+
     @Override
     public Type getType() {
         return type;
@@ -98,27 +116,54 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
 
     @Override
     public OpenType<?> getOpenType() {
-        // If is array => arrayType
-        if (isArray(getType())) {
-            String innerTypeFullyQName = getInnerType(getType());
-            SimpleType<?> innerSimpleType = SimpleTypeResolver
-                    .getSimpleType(innerTypeFullyQName);
-            try {
-                ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(
-                        innerSimpleType, true) : new ArrayType<>(1,
-                        innerSimpleType);
-                return arrayType;
-            } catch (OpenDataException e) {
-                throw new RuntimeException("Unable to create "
-                        + ArrayType.class + " with inner element of type "
-                        + innerSimpleType, e);
-            }
+        TypeDefinition<?> baseTypeDefinition = getBaseType(typeProviderWrapper, typeDefinition);
+        Type baseType = typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition);
+
+        if (isArray()) {
+            return getArrayType();
+        } else if (isDerivedType(baseType)) {
+            return getCompositeType(baseType, baseTypeDefinition);
         }
-        // else simple type
+
+        return getSimpleType();
+    }
+
+    private OpenType<?> getSimpleType() {
         SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(getType());
         return simpleType;
     }
 
+     private OpenType<?> getCompositeType(Type baseType, TypeDefinition<?> baseTypeDefinition) {
+
+        SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
+        String innerItemName = typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
+
+        String[] itemNames = new String[]{innerItemName};
+        String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+
+        OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
+        try {
+            return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
+        } catch (OpenDataException e) {
+            throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
+                    + itemTypes, e);
+        }
+
+    }
+
+    private OpenType<?> getArrayType() {
+        String innerTypeFullyQName = getInnerType(getType());
+        SimpleType<?> innerSimpleType = SimpleTypeResolver.getSimpleType(innerTypeFullyQName);
+        try {
+            ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(innerSimpleType, true)
+                    : new ArrayType<>(1, innerSimpleType);
+            return arrayType;
+        } catch (OpenDataException e) {
+            throw new RuntimeException("Unable to create " + ArrayType.class + " with inner element of type "
+                    + innerSimpleType, e);
+        }
+    }
+
     // TODO verify
     private boolean isPrimitive(String innerTypeFullyQName) {
         if (innerTypeFullyQName.contains("."))
@@ -127,13 +172,17 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
         return true;
     }
 
+    private boolean isArray() {
+        return type.getName().endsWith("[]");
+    }
+
+    private boolean isDerivedType(Type baseType) {
+        return  baseType.equals(getType()) == false;
+    }
+
     private static String getInnerType(Type type) {
         String fullyQualifiedName = type.getFullyQualifiedName();
         return fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2);
     }
 
-    private static boolean isArray(Type type) {
-        return type.getName().endsWith("[]");
-    }
-
 }
index 349459a..61ad74d 100644 (file)
@@ -7,18 +7,16 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.attribute;
 
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import org.opendaylight.yangtools.sal.binding.model.api.Type;
+
+import javax.management.openmbean.SimpleType;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Date;
 import java.util.Map;
 
-import javax.management.openmbean.SimpleType;
-
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-
 public class SimpleTypeResolver {
 
     public static SimpleType<?> getSimpleType(Type type) {
@@ -29,6 +27,10 @@ public class SimpleTypeResolver {
         return expectedSimpleType;
     }
 
+    public static boolean canResolve(Type type) {
+        return JAVA_TYPE_TO_SIMPLE_TYPE.containsKey(type.getFullyQualifiedName());
+    }
+
     public static SimpleType<?> getSimpleType(String fullyQualifiedName) {
         SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE
                 .get(fullyQualifiedName);
index 20029d0..9665633 100644 (file)
@@ -7,15 +7,10 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator.attribute;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
@@ -26,10 +21,13 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
 
 public class TOAttribute extends AbstractAttribute {
 
@@ -59,7 +57,7 @@ public class TOAttribute extends AbstractAttribute {
                         createInnerAttribute(dataSchemaNode,
                                 typeProviderWrapper));
             } catch (IllegalArgumentException e) {
-                throw new IllegalStateException("Unable to create TO");
+                throw new IllegalStateException("Unable to create TO", e);
             }
         }
         return new TOAttribute(containerSchemaNode, map, attributeNameMap,
@@ -200,7 +198,7 @@ public class TOAttribute extends AbstractAttribute {
     }
 
     @Override
-    public OpenType<?> getOpenType() {
+    public CompositeType getOpenType() {
         String description = getNullableDescription() == null ? getAttributeYangName()
                 : getNullableDescription();
         final String[] itemNames = new String[yangNameToAttributeMap.keySet()
index b7540c8..f8d86b2 100644 (file)
         </dependency>
     </dependencies>
 
-
-
     <build>
         <plugins>
             <plugin>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
+                <version>${opendaylight.yang.version}</version>
+                <executions>
+                    <execution>
+                        <id>config</id>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>
+                                            urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+                                        </namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>types</id>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <yangFilesRootDir>src/main/yang/types</yangFilesRootDir>
+                            <codeGenerators>
+                              <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>
+                                        target/generated-sources/sal
+                                    </outputBaseDir>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>${config.version}</version>
+                    </dependency>
+
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>maven-sal-api-gen-plugin</artifactId>
+                        <version>${yangtools.binding.version}</version>
+                    </dependency>
+                </dependencies>
             </plugin>
         </plugins>
     </build>
index 43f6200..ae86d42 100644 (file)
 package org.opendaylight.controller.config.yang.test.impl;
 
 
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
 /**
 *
 */
@@ -38,11 +42,118 @@ public final class NetconfTestImplModule
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return new AutoCloseable() {
+        return registerRuntimeBeans();
+    }
+
+    private NetconfTestImplRuntimeRegistration registerRuntimeBeans() {
+        NetconfTestImplRuntimeRegistration reg = getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
+
+            @Override
+            public Long getCreatedSessions() {
+                return getSimpleLong();
+            }
+
             @Override
-            public void close() throws Exception {
+            public Asdf getAsdf() {
+                final Asdf asdf = new Asdf();
+                asdf.setSimpleString("asdf");
+                return asdf;
             }
-        };
+
+            @Override
+            public String noArg(final String arg1) {
+                return arg1.toUpperCase();
+            }
+
+        });
+
+        for (int i = 0; i < getSimpleShort(); i++) {
+            final int finalI = i;
+
+            reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
+                @Override
+                public Integer getSimpleInt3() {
+                    return getSimpleTest();
+                }
+
+                @Override
+                public Deep4 getDeep4() {
+                    final Deep4 d = new Deep4();
+                    d.setBoool(false);
+                    return d;
+                }
+
+                @Override
+                public String getSimpleString() {
+                    return Integer.toString(finalI);
+                }
+
+                @Override
+                public void noArgInner() {
+                }
+            });
+
+            InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
+                @Override
+                public Integer getSimpleInt3() {
+                    return finalI;
+                }
+
+                @Override
+                public Deep2 getDeep2() {
+                    return new Deep2();
+                }
+            });
+
+            for (int j = 0; j < getSimpleShort(); j++) {
+                final int finalJ = j;
+                innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
+                    @Override
+                    public List<NotStateBean> getNotStateBean() {
+                        NotStateBean b1 = new NotStateBean();
+                        b1.setElement("not state");
+                        return Lists.newArrayList(b1);
+                    }
+
+                    @Override
+                    public Integer getSimpleInt3() {
+                        return finalJ;
+                    }
+
+                    @Override
+                    public Deep3 getDeep3() {
+                        return new Deep3();
+                    }
+
+                    @Override
+                    public List<String> getListOfStrings() {
+                        return Lists.newArrayList("l1", "l2");
+                    }
+
+                    @Override
+                    public List<RetValList> listOutput() {
+                        return Lists.newArrayList(new RetValList());
+                    }
+
+                    @Override
+                    public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
+                        return aBoolean;
+                    }
+
+                    @Override
+                    public RetValContainer containerOutput() {
+                        return new RetValContainer();
+                    }
+
+                    @Override
+                    public List<String> leafListOutput() {
+                        return Lists.newArrayList("1", "2");
+                    }
+                });
+            }
+        }
+
+        return reg;
     }
 
 }
index 291e3eb..977aa6a 100644 (file)
@@ -7,7 +7,7 @@ module config-test-impl {
     import config { prefix config; revision-date 2013-04-05; }
     import ietf-inet-types { prefix inet; revision-date 2010-09-24;}
     import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
+    import test-types { prefix tt; revision-date 2013-11-27; }
 
     description
         "Testing IMPL";
@@ -107,6 +107,20 @@ module config-test-impl {
                 type string;
             }
 
+            leaf extended {
+                type tt:extend-once;
+            }
+
+            leaf extended-twice {
+                type tt:extend-twice;
+            }
+
+/* TODO Add support for enums
+
+            leaf extended-enum {
+                type tt:extend-enum;
+            }
+*/
            container dto-c {
                 leaf simple-arg {
                     type uint32;
diff --git a/opendaylight/config/yang-test/src/main/yang/types/test-types.yang b/opendaylight/config/yang-test/src/main/yang/types/test-types.yang
new file mode 100644 (file)
index 0000000..84fbcb0
--- /dev/null
@@ -0,0 +1,26 @@
+module test-types {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:test:types";
+    prefix "tt";
+
+    description
+        "Types generated for testing";
+
+    revision "2013-11-27";
+
+    typedef extend-once {
+        type uint16;
+    }
+
+    typedef extend-twice {
+        type extend-once;
+    }
+
+    typedef extend-enum {
+        type enumeration {
+            enum "ONE";
+            enum "TWO";
+        }
+    }
+
+}
index 1ef2ae3..4b6dcfd 100644 (file)
@@ -14,28 +14,70 @@ import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribu
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
 public abstract class AttributeIfcSwitchStatement<T> {
 
+    protected AttributeIfc lastAttribute;
+
     public T switchAttribute(AttributeIfc attributeIfc) {
 
+        this.lastAttribute = attributeIfc;
+
         if (attributeIfc instanceof JavaAttribute) {
-            return caseJavaAttribute((JavaAttribute) attributeIfc);
+            try {
+                return caseJavaAttribute(attributeIfc.getOpenType());
+            } catch (UnknownOpenTypeException e) {
+                throw getIllegalArgumentException(attributeIfc);
+            }
+
         } else if (attributeIfc instanceof DependencyAttribute) {
-            return caseDependencyAttribute((DependencyAttribute) attributeIfc);
+            return caseDependencyAttribute(((DependencyAttribute) attributeIfc).getOpenType());
         } else if (attributeIfc instanceof ListAttribute) {
-            return caseListAttribute((ListAttribute) attributeIfc);
+            return caseListAttribute(((ListAttribute) attributeIfc).getOpenType());
         } else if (attributeIfc instanceof TOAttribute) {
-            return caseTOAttribute((TOAttribute) attributeIfc);
+            return caseTOAttribute(((TOAttribute) attributeIfc).getOpenType());
+        }
+
+        throw getIllegalArgumentException(attributeIfc);
+    }
+
+    private IllegalArgumentException getIllegalArgumentException(AttributeIfc attributeIfc) {
+        return new IllegalArgumentException("Unknown attribute type " + attributeIfc.getClass() + ", " + attributeIfc
+                + " with open type:" + attributeIfc.getOpenType());
+    }
+
+    public final T caseJavaAttribute(OpenType<?> openType) {
+        if (openType instanceof SimpleType<?>) {
+            return caseJavaSimpleAttribute((SimpleType<?>) openType);
+        } else if (openType instanceof ArrayType<?>) {
+            return caseJavaArrayAttribute((ArrayType<?>) openType);
+        } else if (openType instanceof CompositeType) {
+            return caseJavaCompositeAttribute((CompositeType) openType);
         }
 
-        throw new IllegalArgumentException("Unknown attribute type " + attributeIfc.getClass() + ", " + attributeIfc);
+        throw new UnknownOpenTypeException("Unknown attribute open type " + openType);
     }
 
-    protected abstract T caseJavaAttribute(JavaAttribute attributeIfc);
+    protected abstract T caseJavaSimpleAttribute(SimpleType<?> openType);
+
+    protected abstract T caseJavaArrayAttribute(ArrayType<?> openType);
+
+    protected abstract T caseJavaCompositeAttribute(CompositeType openType);
 
-    protected abstract T caseDependencyAttribute(DependencyAttribute attributeIfc);
+    protected abstract T caseDependencyAttribute(SimpleType<?> attributeIfc);
 
-    protected abstract T caseTOAttribute(TOAttribute attributeIfc);
+    protected abstract T caseTOAttribute(CompositeType openType);
 
-    protected abstract T caseListAttribute(ListAttribute attributeIfc);
+    protected abstract T caseListAttribute(ArrayType<?> openType);
+
+
+    private static class UnknownOpenTypeException extends RuntimeException {
+        public UnknownOpenTypeException(String message) {
+            super(message);
+        }
+    }
 }
index 2ba1b61..867d94e 100644 (file)
@@ -8,27 +8,26 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
-import java.util.List;
-
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
-public abstract class AbstractAttributeReadingStrategy<A extends AttributeIfc> implements AttributeReadingStrategy {
+import java.util.List;
+
+public abstract class AbstractAttributeReadingStrategy implements AttributeReadingStrategy {
 
-    private final A attributeIfc;
+    private final String nullableDefault;
 
-    public AbstractAttributeReadingStrategy(A attributeIfc) {
-        this.attributeIfc = attributeIfc;
+    public AbstractAttributeReadingStrategy(String nullableDefault) {
+        this.nullableDefault = nullableDefault;
     }
 
-    public A getAttributeIfc() {
-        return attributeIfc;
+    public String getNullableDefault() {
+        return nullableDefault;
     }
 
     @Override
     public AttributeConfigElement readElement(List<XmlElement> configNodes) {
         if (configNodes.size() == 0)
-            return AttributeConfigElement.createNullValue(attributeIfc);
+            return AttributeConfigElement.createNullValue(nullableDefault);
 
         return readElementHook(configNodes);
     }
index f07e740..8f56961 100644 (file)
@@ -9,12 +9,11 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.collect.Lists;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
 import java.util.List;
 
-public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrategy<AttributeIfc> {
+public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
     private final AttributeReadingStrategy innerStrategy;
 
@@ -22,8 +21,8 @@ public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrat
      * @param attributeIfc
      * @param innerStrategy
      */
-    public ArrayAttributeReadingStrategy(AttributeIfc attributeIfc, AttributeReadingStrategy innerStrategy) {
-        super(attributeIfc);
+    public ArrayAttributeReadingStrategy(String nullableDefault, AttributeReadingStrategy innerStrategy) {
+        super(nullableDefault);
         this.innerStrategy = innerStrategy;
     }
 
@@ -33,7 +32,7 @@ public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrat
         for (int i = 0; i < configNodes.size(); i++) {
             innerList.add(innerStrategy.readElement(Lists.newArrayList(configNodes.get(i))).getValue());
         }
-        return AttributeConfigElement.create(getAttributeIfc(), innerList);
+        return AttributeConfigElement.create(getNullableDefault(), innerList);
     }
 
 }
index fa249da..598935a 100644 (file)
@@ -8,12 +8,11 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
-import javax.management.openmbean.OpenType;
-
+import com.google.common.base.Optional;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy;
 
-import com.google.common.base.Optional;
+import javax.management.openmbean.OpenType;
 
 /**
  * Parsed xml element containing configuration for one attribute of an instance
@@ -49,13 +48,23 @@ public class AttributeConfigElement {
     }
 
     public static AttributeConfigElement create(AttributeIfc attributeIfc, Object value) {
-        return new AttributeConfigElement(attributeIfc.getNullableDefault(), value);
+        String nullableDefault = attributeIfc.getNullableDefault();
+        return create(nullableDefault, value);
+    }
+
+    public static AttributeConfigElement create(String nullableDefault, Object value) {
+        return new AttributeConfigElement(nullableDefault, value);
     }
 
     public static AttributeConfigElement createNullValue(AttributeIfc attributeIfc) {
         return new AttributeConfigElement(attributeIfc.getNullableDefault(), null);
     }
 
+    public static AttributeConfigElement createNullValue(String nullableDefault) {
+        return new AttributeConfigElement(nullableDefault, null);
+    }
+
+
     public Object getValue() {
         return value;
     }
index 1cfb74d..fdbfb98 100644 (file)
@@ -11,21 +11,19 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attri
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingStrategy<TOAttribute> {
+public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
     private final Map<String, AttributeReadingStrategy> innerStrategies;
 
-    public CompositeAttributeReadingStrategy(TOAttribute attributeIfc,
+    public CompositeAttributeReadingStrategy(String nullableDefault,
             Map<String, AttributeReadingStrategy> innerStrategies) {
-        super(attributeIfc);
+        super(nullableDefault);
         this.innerStrategies = innerStrategies;
     }
 
@@ -38,21 +36,19 @@ public class CompositeAttributeReadingStrategy extends AbstractAttributeReadingS
 
         Map<String, Object> innerMap = Maps.newHashMap();
 
-        Map<String, AttributeIfc> inner = getAttributeIfc().getYangPropertiesToTypesMap();
-
         List<XmlElement> recognisedChildren = Lists.newArrayList();
-        for (Entry<String, AttributeIfc> innerAttrEntry : inner.entrySet()) {
+        for (Entry<String, AttributeReadingStrategy> innerAttrEntry : innerStrategies.entrySet()) {
             List<XmlElement> childItem = complexElement.getChildElementsWithSameNamespace(innerAttrEntry.getKey());
             recognisedChildren.addAll(childItem);
 
-            AttributeConfigElement resolvedInner = innerStrategies.get(innerAttrEntry.getKey()).readElement(childItem);
+            AttributeConfigElement resolvedInner = innerAttrEntry.getValue().readElement(childItem);
 
             innerMap.put(innerAttrEntry.getKey(), resolvedInner.getValue());
         }
 
         complexElement.checkUnrecognisedElements(recognisedChildren);
 
-        return AttributeConfigElement.create(getAttributeIfc(), innerMap);
+        return AttributeConfigElement.create(getNullableDefault(), innerMap);
     }
 
 }
index 59dc11f..7a4ba31 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
@@ -17,12 +15,12 @@ import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import java.util.List;
 import java.util.Map;
 
-public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReadingStrategy<AttributeIfc> {
+public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
     private static final Object PREFIX_SEPARATOR = ":";
 
-    public ObjectNameAttributeReadingStrategy(DependencyAttribute attributeIfc) {
-        super(attributeIfc);
+    public ObjectNameAttributeReadingStrategy(String nullableDefault) {
+        super(nullableDefault);
     }
 
     @Override
@@ -33,7 +31,7 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
                 + " but was " + configNodes.size());
 
         Preconditions.checkNotNull(firstChild, "Element %s should be present", firstChild);
-        return AttributeConfigElement.create(getAttributeIfc(), resolve(firstChild));
+        return AttributeConfigElement.create(getNullableDefault(), resolve(firstChild));
     }
 
     private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) {
index 80a2555..bc3c74a 100644 (file)
@@ -8,15 +8,15 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
 
 import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.SimpleType;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -41,26 +41,33 @@ public class ObjectXmlReader extends AttributeIfcSwitchStatement<AttributeReadin
     }
 
     @Override
-    protected AttributeReadingStrategy caseJavaAttribute(JavaAttribute attributeIfc) {
-        if (attributeIfc.getOpenType() instanceof SimpleType<?>)
-            return new SimpleAttributeReadingStrategy(attributeIfc);
-        else if (attributeIfc.getOpenType() instanceof ArrayType<?>) {
-            SimpleAttributeReadingStrategy innerStrategy = new SimpleAttributeReadingStrategy(
-                    ((ArrayType<?>) attributeIfc.getOpenType()).getElementOpenType());
-            return new ArrayAttributeReadingStrategy(attributeIfc, innerStrategy);
-        }
-        throw new IllegalStateException(JavaAttribute.class + " can only provide open type " + SimpleType.class
-                + " or " + ArrayType.class);
+    public AttributeReadingStrategy caseJavaSimpleAttribute(SimpleType<?> openType) {
+        return new SimpleAttributeReadingStrategy(lastAttribute.getNullableDefault());
+    }
+
+    @Override
+    public AttributeReadingStrategy caseJavaArrayAttribute(ArrayType<?> openType) {
+        SimpleAttributeReadingStrategy innerStrategy = new SimpleAttributeReadingStrategy(lastAttribute.getNullableDefault());
+        return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
     }
 
     @Override
-    protected AttributeReadingStrategy caseDependencyAttribute(DependencyAttribute attributeIfc) {
-        return new ObjectNameAttributeReadingStrategy(attributeIfc);
+    public AttributeReadingStrategy caseJavaCompositeAttribute(CompositeType openType) {
+        Preconditions.checkState(openType.keySet().size() == 1, "Unexpected number of elements for open type %s, should be 1", openType);
+        String mappingKey = openType.keySet().iterator().next();
+        return new SimpleCompositeAttributeReadingStrategy(lastAttribute.getNullableDefault(), mappingKey);
     }
 
     @Override
-    protected AttributeReadingStrategy caseTOAttribute(TOAttribute attributeIfc) {
-        Map<String, AttributeIfc> inner = attributeIfc.getYangPropertiesToTypesMap();
+    protected AttributeReadingStrategy caseDependencyAttribute(SimpleType<?> openType) {
+        return new ObjectNameAttributeReadingStrategy(lastAttribute.getNullableDefault());
+    }
+
+    @Override
+    protected AttributeReadingStrategy caseTOAttribute(CompositeType openType) {
+        Preconditions.checkState(lastAttribute instanceof TOAttribute);
+        Map<String, AttributeIfc> inner = ((TOAttribute)lastAttribute).getYangPropertiesToTypesMap();
+
         Map<String, AttributeReadingStrategy> innerStrategies = Maps.newHashMap();
 
         for (Entry<String, AttributeIfc> innerAttrEntry : inner.entrySet()) {
@@ -69,14 +76,14 @@ public class ObjectXmlReader extends AttributeIfcSwitchStatement<AttributeReadin
             innerStrategies.put(innerAttrEntry.getKey(), innerStrat);
         }
 
-        return new CompositeAttributeReadingStrategy(attributeIfc, innerStrategies);
+        return new CompositeAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategies);
     }
 
     @Override
-    protected AttributeReadingStrategy caseListAttribute(ListAttribute attributeIfc) {
-        AttributeIfc innerAttr = attributeIfc.getInnerAttribute();
-        AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key, innerAttr);
-        return new ArrayAttributeReadingStrategy(attributeIfc, innerStrategy);
+    protected AttributeReadingStrategy caseListAttribute(ArrayType<?> openType) {
+        Preconditions.checkState(lastAttribute instanceof ListAttribute);
+        AttributeReadingStrategy innerStrategy = prepareReadingStrategy(key, ((ListAttribute) lastAttribute).getInnerAttribute());
+        return new ArrayAttributeReadingStrategy(lastAttribute.getNullableDefault(), innerStrategy);
     }
 
 }
index c5c287f..be86a2a 100644 (file)
@@ -9,23 +9,14 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.base.Preconditions;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 
-import javax.management.openmbean.OpenType;
 import java.util.List;
 
-public class SimpleAttributeReadingStrategy extends AbstractAttributeReadingStrategy<AttributeIfc> {
+public class SimpleAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
 
-    public SimpleAttributeReadingStrategy(AttributeIfc attributeIfc) {
-        super(attributeIfc);
-    }
-
-    /**
-     * @param elementOpenType
-     */
-    public SimpleAttributeReadingStrategy(OpenType<?> elementOpenType) {
-        super(new AttributeIfcWrapper(elementOpenType));
+    public SimpleAttributeReadingStrategy(String nullableDefault) {
+        super(nullableDefault);
     }
 
     @Override
@@ -37,50 +28,11 @@ public class SimpleAttributeReadingStrategy extends AbstractAttributeReadingStra
         String textContent = xmlElement.getTextContent();
 
         Preconditions.checkNotNull(textContent, "This element should contain text %s", xmlElement);
-        return AttributeConfigElement.create(getAttributeIfc(), textContent);
+        return AttributeConfigElement.create(getNullableDefault(), postprocessParsedValue(textContent));
     }
 
-    /**
-     * Wrapper for JavaAttribute inner element attributes (in case JavaAttribute
-     * is array)
-     */
-    static class AttributeIfcWrapper implements AttributeIfc {
-
-        private final OpenType<?> elementOpenType;
-
-        public AttributeIfcWrapper(OpenType<?> elementOpenType) {
-            this.elementOpenType = elementOpenType;
-        }
-
-        @Override
-        public String getAttributeYangName() {
-            return null;
-        }
-
-        @Override
-        public String getNullableDescription() {
-            return null;
-        }
-
-        @Override
-        public String getNullableDefault() {
-            return null;
-        }
-
-        @Override
-        public String getUpperCaseCammelCase() {
-            return null;
-        }
-
-        @Override
-        public String getLowerCaseCammelCase() {
-            return null;
-        }
-
-        @Override
-        public OpenType<?> getOpenType() {
-            return elementOpenType;
-        }
-
+    protected Object postprocessParsedValue(String textContent) {
+        return textContent;
     }
+
 }
diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/SimpleCompositeAttributeReadingStrategy.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/SimpleCompositeAttributeReadingStrategy.java
new file mode 100644 (file)
index 0000000..9249ac9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
+
+import com.google.common.collect.Maps;
+
+import java.util.HashMap;
+
+public class SimpleCompositeAttributeReadingStrategy extends SimpleAttributeReadingStrategy {
+
+
+    private final String key;
+
+    public SimpleCompositeAttributeReadingStrategy(String nullableDefault, String key) {
+        super(nullableDefault);
+        this.key = key;
+    }
+
+    protected Object postprocessParsedValue(String textContent) {
+        HashMap<String,String> map = Maps.newHashMap();
+        map.put(key, textContent);
+        return map;
+    }
+
+}
index 3e63b92..853197c 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
@@ -44,6 +44,12 @@ public class ObjectMapper extends AttributeIfcSwitchStatement<AttributeMappingSt
     }
 
     public AttributeMappingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) {
+
+        if(attributeIfc instanceof DependencyAttribute) {
+            serviceNameOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getLocalName();
+            namespaceOfDepAttr = ((DependencyAttribute)attributeIfc).getDependency().getSie().getQName().getNamespace().toString();
+        }
+
         return switchAttribute(attributeIfc);
     }
 
@@ -56,45 +62,63 @@ public class ObjectMapper extends AttributeIfcSwitchStatement<AttributeMappingSt
     }
 
     @Override
-    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaAttribute(JavaAttribute attributeIfc) {
-
-        if (attributeIfc.getOpenType() instanceof SimpleType<?>)
-            return new SimpleAttributeMappingStrategy((SimpleType<?>) attributeIfc.getOpenType());
-        else if (attributeIfc.getOpenType() instanceof ArrayType<?>) {
-            ArrayType<?> arrayType = (ArrayType<?>) attributeIfc.getOpenType();
-            AttributeMappingStrategy<?, ? extends OpenType<?>> innerStrategy = new SimpleAttributeMappingStrategy(
-                    (SimpleType<?>) arrayType.getElementOpenType());
-            return new ArrayAttributeMappingStrategy(arrayType, innerStrategy);
+    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaSimpleAttribute(SimpleType<?> openType) {
+        return new SimpleAttributeMappingStrategy(openType);
+    }
+
+    @Override
+    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaArrayAttribute(ArrayType<?> openType) {
+
+        AttributeMappingStrategy<?, ? extends OpenType<?>> innerStrategy = new SimpleAttributeMappingStrategy(
+                (SimpleType<?>) openType.getElementOpenType());
+        return new ArrayAttributeMappingStrategy(openType, innerStrategy);
+    }
+
+    @Override
+    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseJavaCompositeAttribute(CompositeType openType) {
+        Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> innerStrategies = Maps.newHashMap();
+
+        Map<String, String> attributeMapping = Maps.newHashMap();
+
+        for (String innerAttributeKey : openType.keySet()) {
+
+            innerStrategies.put(innerAttributeKey, caseJavaAttribute(openType.getType(innerAttributeKey)));
+            attributeMapping.put(innerAttributeKey, innerAttributeKey);
         }
-        throw new IllegalStateException(JavaAttribute.class + " can only provide open type " + SimpleType.class
-                + " or " + ArrayType.class);
+
+        return new CompositeAttributeMappingStrategy(openType, innerStrategies, attributeMapping);
     }
 
+    private String serviceNameOfDepAttr;
+    private String namespaceOfDepAttr;
+
     @Override
     protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseDependencyAttribute(
-            DependencyAttribute attributeIfc) {
-        String serviceName = attributeIfc.getDependency().getSie().getQName().getLocalName();
-        String namespace = attributeIfc.getDependency().getSie().getQName().getNamespace().toString();
-        return new ObjectNameAttributeMappingStrategy((SimpleType<?>) attributeIfc.getOpenType(), dependencyTracker,
-                serviceName, namespace);
+            SimpleType<?> openType) {
+        return new ObjectNameAttributeMappingStrategy(openType, dependencyTracker,
+                serviceNameOfDepAttr, namespaceOfDepAttr);
     }
 
     @Override
-    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseTOAttribute(TOAttribute attributeIfc) {
+    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseTOAttribute(CompositeType openType) {
         Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> innerStrategies = Maps.newHashMap();
 
-        for (Entry<String, AttributeIfc> innerAttrEntry : attributeIfc.getJmxPropertiesToTypesMap().entrySet()) {
+        Preconditions.checkState(lastAttribute instanceof TOAttribute);
+        TOAttribute lastTO = (TOAttribute) lastAttribute;
+
+        for (Entry<String, AttributeIfc> innerAttrEntry : ((TOAttribute)lastAttribute).getJmxPropertiesToTypesMap().entrySet()) {
             innerStrategies.put(innerAttrEntry.getKey(), prepareStrategy(innerAttrEntry.getValue()));
         }
 
-        return new CompositeAttributeMappingStrategy((CompositeType) attributeIfc.getOpenType(), innerStrategies,
-                createJmxToYangMapping(attributeIfc));
+        return new CompositeAttributeMappingStrategy(openType, innerStrategies,
+                createJmxToYangMapping(lastTO));
     }
 
     @Override
-    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseListAttribute(ListAttribute attributeIfc) {
-        return new ArrayAttributeMappingStrategy(attributeIfc.getOpenType(),
-                prepareStrategy(attributeIfc.getInnerAttribute()));
+    protected AttributeMappingStrategy<?, ? extends OpenType<?>> caseListAttribute(ArrayType<?> openType) {
+        Preconditions.checkState(lastAttribute instanceof ListAttribute);
+        return new ArrayAttributeMappingStrategy(openType,
+                prepareStrategy(((ListAttribute) lastAttribute).getInnerAttribute()));
     }
 
 }
index 94a6947..c321164 100644 (file)
@@ -8,29 +8,24 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving;
 
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import java.util.Map;
+import java.util.Map.Entry;
 
 public class ObjectResolver extends AttributeIfcSwitchStatement<AttributeResolvingStrategy<?, ? extends OpenType<?>>> {
 
     private final Services serviceTracker;
-    private OpenType<?> openType;
 
     public ObjectResolver(Services serviceTracker) {
         this.serviceTracker = serviceTracker;
@@ -42,16 +37,14 @@ public class ObjectResolver extends AttributeIfcSwitchStatement<AttributeResolvi
 
         for (Entry<String, AttributeIfc> attrEntry : configDefinition.entrySet()) {
             strategies.put(attrEntry.getKey(),
-                    prepareStrategy(attrEntry.getValue(), attrEntry.getValue().getOpenType()));
+                    prepareStrategy(attrEntry.getValue()));
         }
 
         return strategies;
     }
 
-    private AttributeResolvingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc,
-            OpenType<?> openType) {
+    private AttributeResolvingStrategy<?, ? extends OpenType<?>> prepareStrategy(AttributeIfc attributeIfc) {
 
-        this.openType = openType;
         return switchAttribute(attributeIfc);
     }
 
@@ -64,45 +57,56 @@ public class ObjectResolver extends AttributeIfcSwitchStatement<AttributeResolvi
     }
 
     @Override
-    protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseJavaAttribute(JavaAttribute attributeIfc) {
-        if (attributeIfc.getOpenType() instanceof SimpleType<?>)
-            return new SimpleAttributeResolvingStrategy((SimpleType<?>) openType);
-        else if (attributeIfc.getOpenType() instanceof ArrayType<?>) {
-            ArrayType<?> arrayType = (ArrayType<?>) openType;
-            SimpleType<?> innerType = (SimpleType<?>) arrayType.getElementOpenType();
-            AttributeResolvingStrategy<?, ? extends OpenType<?>> strat = new SimpleAttributeResolvingStrategy(innerType);
-            return new ArrayAttributeResolvingStrategy(strat, arrayType);
+    protected AttributeResolvingStrategy<?, ? extends OpenType<?>>  caseJavaSimpleAttribute(SimpleType<?> openType) {
+        return new SimpleAttributeResolvingStrategy(openType);
+    }
+
+    @Override
+    protected AttributeResolvingStrategy<?, ? extends OpenType<?>>  caseJavaArrayAttribute(ArrayType<?> openType) {
+        SimpleType<?> innerType = (SimpleType<?>) openType.getElementOpenType();
+        AttributeResolvingStrategy<?, ? extends OpenType<?>> strat = new SimpleAttributeResolvingStrategy(innerType);
+        return new ArrayAttributeResolvingStrategy(strat, openType);
+    }
+
+    @Override
+    protected AttributeResolvingStrategy<?, ? extends OpenType<?>>  caseJavaCompositeAttribute(CompositeType openType) {
+        Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerMap = Maps.newHashMap();
+
+        Map<String, String> yangToJmxMapping = Maps.newHashMap();
+        for (String innerAttributeKey : openType.keySet()) {
+            innerMap.put(innerAttributeKey, caseJavaAttribute(openType.getType(innerAttributeKey)));
+            yangToJmxMapping.put(innerAttributeKey, innerAttributeKey);
         }
-        throw new IllegalStateException(JavaAttribute.class + " can only provide open type " + SimpleType.class
-                + " or " + ArrayType.class);
+        return new CompositeAttributeResolvingStrategy(innerMap, openType, yangToJmxMapping);
     }
 
     @Override
     protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseDependencyAttribute(
-            DependencyAttribute attributeIfc) {
+            SimpleType<?> openType) {
         return new ObjectNameAttributeResolvingStrategy(serviceTracker);
     }
 
     @Override
-    protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseTOAttribute(TOAttribute attributeIfc) {
-        CompositeType compositeType = (CompositeType) openType;
+    protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseTOAttribute(CompositeType openType) {
+        Preconditions.checkState(lastAttribute instanceof TOAttribute);
+        TOAttribute toAttribute = (TOAttribute) lastAttribute;
+
         Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> innerMap = Maps.newHashMap();
-        for (String innerName : compositeType.keySet()) {
-            Preconditions.checkState(attributeIfc instanceof TOAttribute, "Unexpected state, " + attributeIfc
-                    + " should be instance of " + TOAttribute.class.getName());
-            AttributeIfc innerAttributeIfc = attributeIfc.getJmxPropertiesToTypesMap().get(innerName);
+
+        for (String innerName : openType.keySet()) {
+
+            AttributeIfc innerAttributeIfc = toAttribute.getJmxPropertiesToTypesMap().get(innerName);
             innerMap.put(innerAttributeIfc.getAttributeYangName(),
-                    prepareStrategy(innerAttributeIfc, compositeType.getType(innerName)));
+                    prepareStrategy(innerAttributeIfc));
         }
-        return new CompositeAttributeResolvingStrategy(innerMap, compositeType, createYangToJmxMapping(attributeIfc));
+        return new CompositeAttributeResolvingStrategy(innerMap, openType, createYangToJmxMapping(toAttribute));
     }
 
     @Override
-    protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseListAttribute(ListAttribute attributeIfc) {
-        ArrayType<?> arrayType = (ArrayType<?>) openType;
-        OpenType<?> innerType = arrayType.getElementOpenType();
-        AttributeIfc inner = attributeIfc.getInnerAttribute();
-        return new ArrayAttributeResolvingStrategy(prepareStrategy(inner, innerType), arrayType);
+    protected AttributeResolvingStrategy<?, ? extends OpenType<?>> caseListAttribute(ArrayType<?> openType) {
+        Preconditions.checkState(lastAttribute instanceof ListAttribute);
+        AttributeIfc innerAttribute = ((ListAttribute) lastAttribute).getInnerAttribute();
+        return new ArrayAttributeResolvingStrategy(prepareStrategy(innerAttribute), openType);
     }
 
 }
index 4888dd0..99e9699 100644 (file)
@@ -11,14 +11,13 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attri
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
-import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributeIfcSwitchStatement;
 import org.w3c.dom.Document;
 
 import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.SimpleType;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -52,28 +51,33 @@ public class ObjectXmlWriter extends AttributeIfcSwitchStatement<AttributeWritin
     }
 
     @Override
-    protected AttributeWritingStrategy caseJavaAttribute(JavaAttribute attributeIfc) {
+    protected AttributeWritingStrategy caseJavaSimpleAttribute(SimpleType<?> openType) {
+        return new SimpleAttributeWritingStrategy(document, key);
+    }
 
-        if (attributeIfc.getOpenType() instanceof SimpleType<?>)
-            return new SimpleAttributeWritingStrategy(document, key);
-        else if (attributeIfc.getOpenType() instanceof ArrayType<?>) {
-            AttributeWritingStrategy innerStrategy = new SimpleAttributeWritingStrategy(document, key);
-            return new ArrayAttributeWritingStrategy(innerStrategy);
-        }
-        throw new IllegalStateException(JavaAttribute.class + " can only provide open type " + SimpleType.class
-                + " or " + ArrayType.class);
+    @Override
+    protected AttributeWritingStrategy caseJavaArrayAttribute(ArrayType<?> openType) {
+        AttributeWritingStrategy innerStrategy = new SimpleAttributeWritingStrategy(document, key);
+        return new ArrayAttributeWritingStrategy(innerStrategy);
     }
 
     @Override
-    protected AttributeWritingStrategy caseDependencyAttribute(DependencyAttribute attributeIfc) {
+    protected AttributeWritingStrategy caseJavaCompositeAttribute(CompositeType openType) {
+        return new SimpleCompositeAttributeWritingStrategy(document, key);
+    }
+
+    @Override
+    protected AttributeWritingStrategy caseDependencyAttribute(SimpleType<?> openType) {
         return new ObjectNameAttributeWritingStrategy(document, key);
     }
 
     @Override
-    protected AttributeWritingStrategy caseTOAttribute(TOAttribute attributeIfc) {
+    protected AttributeWritingStrategy caseTOAttribute(CompositeType openType) {
+        Preconditions.checkState(lastAttribute instanceof TOAttribute);
+
         Map<String, AttributeWritingStrategy> innerStrats = Maps.newHashMap();
         String currentKey = key;
-        for (Entry<String, AttributeIfc> innerAttrEntry : attributeIfc.getYangPropertiesToTypesMap().entrySet()) {
+        for (Entry<String, AttributeIfc> innerAttrEntry : ((TOAttribute) lastAttribute).getYangPropertiesToTypesMap().entrySet()) {
 
             AttributeWritingStrategy innerStrategy = prepareWritingStrategy(innerAttrEntry.getKey(),
                     innerAttrEntry.getValue(), document);
@@ -84,9 +88,11 @@ public class ObjectXmlWriter extends AttributeIfcSwitchStatement<AttributeWritin
     }
 
     @Override
-    protected AttributeWritingStrategy caseListAttribute(ListAttribute attributeIfc) {
-        AttributeIfc inner = attributeIfc.getInnerAttribute();
-        AttributeWritingStrategy innerStrategy = prepareWritingStrategy(key, inner, document);
+    protected AttributeWritingStrategy caseListAttribute(ArrayType<?> openType) {
+        Preconditions.checkState(lastAttribute instanceof ListAttribute);
+        AttributeIfc innerAttribute = ((ListAttribute) lastAttribute).getInnerAttribute();
+
+        AttributeWritingStrategy innerStrategy = prepareWritingStrategy(key, innerAttribute, document);
         return new ArrayAttributeWritingStrategy(innerStrategy);
     }
 
index 514183b..62ff682 100644 (file)
@@ -29,10 +29,16 @@ public class SimpleAttributeWritingStrategy implements AttributeWritingStrategy
 
     @Override
     public void writeElement(Element parentElement, String namespace, Object value) {
+        value = preprocess(value);
         Util.checkType(value, String.class);
         Element innerNode = XmlUtil.createTextElement(document, key, (String) value);
         XmlUtil.addNamespaceAttr(innerNode, namespace);
         parentElement.appendChild(innerNode);
     }
 
+    protected Object preprocess(Object value) {
+        return value;
+    }
+
+
 }
diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleCompositeAttributeWritingStrategy.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/SimpleCompositeAttributeWritingStrategy.java
new file mode 100644 (file)
index 0000000..10b643f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.w3c.dom.Document;
+
+import java.util.Map;
+
+public class SimpleCompositeAttributeWritingStrategy extends SimpleAttributeWritingStrategy {
+
+    /**
+     * @param document
+     * @param key
+     */
+    public SimpleCompositeAttributeWritingStrategy(Document document, String key) {
+        super(document, key);
+    }
+
+    protected Object preprocess(Object value) {
+        Util.checkType(value, Map.class);
+        Preconditions.checkArgument(((Map)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
+        return ((Map)value).values().iterator().next();
+    }
+
+}
index f96b3ac..f33a322 100644 (file)
@@ -52,21 +52,24 @@ public class Config {
         this.moduleNamesToConfigs = Collections.unmodifiableMap(moduleNamesToConfigs);
     }
 
-    private Map<String, Map<String, Collection<ObjectName>>> getMappedInstances(Set<ObjectName> instancesToMap,
-            Services serviceTracker) {
+    public static Map<String, Map<String, Collection<ObjectName>>> getMappedInstances(Set<ObjectName> instancesToMap,
+                                                                                Services serviceTracker, Map<String, Map<String, ModuleConfig>> configs) {
         Multimap<String, ObjectName> moduleToInstances = mapInstancesToModules(instancesToMap);
 
         Map<String, Map<String, Collection<ObjectName>>> retVal = Maps.newLinkedHashMap();
 
-        for (String namespace : moduleConfigs.keySet()) {
+        for (String namespace : configs.keySet()) {
 
             Map<String, Collection<ObjectName>> innerRetVal = Maps.newHashMap();
 
-            for (Entry<String, ModuleConfig> mbeEntry : moduleConfigs.get(namespace).entrySet()) {
+            for (Entry<String, ModuleConfig> mbeEntry : configs.get(namespace).entrySet()) {
 
                 String moduleName = mbeEntry.getKey();
                 Collection<ObjectName> instances = moduleToInstances.get(moduleName);
 
+                // TODO, this code does not support same module names from different namespaces
+                // Namespace should be present in ObjectName
+
                 if (instances == null)
                     continue;
 
@@ -86,7 +89,7 @@ public class Config {
         return retVal;
     }
 
-    private void addServices(Services serviceTracker, Collection<ObjectName> instances,
+    private static void addServices(Services serviceTracker, Collection<ObjectName> instances,
             Multimap<String, String> providedServices) {
         for (ObjectName instanceOn : instances) {
             for (Entry<String, String> serviceName : providedServices.entries()) {
@@ -115,7 +118,7 @@ public class Config {
         Services serviceTracker = new Services();
 
         Map<String, Map<String, Collection<ObjectName>>> moduleToInstances = getMappedInstances(instancesToMap,
-                serviceTracker);
+                serviceTracker, moduleConfigs);
 
         Element root = dataElement;
         if (maybeNamespace.isPresent()) {
index 4dbfba1..11e97eb 100644 (file)
@@ -9,8 +9,8 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime;
 
 import com.google.common.collect.Sets;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -40,17 +40,10 @@ public class ModuleRuntime {
         throw new IllegalStateException("Root runtime bean not found among " + runtimeBeanOns);
     }
 
-    public Element toXml(String namespace, String instanceName, Collection<ObjectName> runtimeBeanOns, Document document) {
-        Element moduleElement = document.createElement(XmlNetconfConstants.MODULE_KEY);
+    public Element toXml(String namespace, Collection<ObjectName> runtimeBeanOns,
+                         Document document, ModuleConfig moduleConfig, ObjectName configBeanON, Services serviceTracker) {
 
-        final String prefix = getPrefix(namespace);
-        Element typeElement = XmlUtil.createPrefixedTextElement(document, XmlNetconfConstants.TYPE_KEY, prefix,
-                moduleName);
-        XmlUtil.addPrefixedNamespaceAttr(typeElement, prefix, namespace);
-        moduleElement.appendChild(typeElement);
-
-        Element nameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, instanceName);
-        moduleElement.appendChild(nameElement);
+        Element moduleElement = moduleConfig.toXml(configBeanON, serviceTracker, document, namespace);
 
         ObjectName rootName = findRoot(runtimeBeanOns);
 
@@ -62,8 +55,4 @@ public class ModuleRuntime {
         return moduleElement;
     }
 
-    private String getPrefix(String namespace) {
-        return XmlNetconfConstants.PREFIX;
-    }
-
 }
index 8af1e0e..64f295a 100644 (file)
@@ -12,26 +12,37 @@ import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Config;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import javax.management.ObjectName;
+import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
 public class Runtime {
 
     private final Map<String, Map<String, ModuleRuntime>> moduleRuntimes;
+    private final Map<String, Map<String, ModuleConfig>> moduleConfigs;
 
-    public Runtime(Map<String, Map<String, ModuleRuntime>> moduleRuntimes) {
+    public Runtime(Map<String, Map<String, ModuleRuntime>> moduleRuntimes,
+            Map<String, Map<String, ModuleConfig>> moduleConfigs) {
         this.moduleRuntimes = moduleRuntimes;
+        this.moduleConfigs = moduleConfigs;
     }
 
     private Map<String, Multimap<String, ObjectName>> mapInstancesToModules(Set<ObjectName> instancesToMap) {
         Map<String, Multimap<String, ObjectName>> retVal = Maps.newHashMap();
 
+        // TODO map to namepsace, prevent module name conflicts
+        // this code does not support same module names from different namespaces
+        // Namespace should be present in ObjectName
+
         for (ObjectName objectName : instancesToMap) {
             String moduleName = ObjectNameUtil.getFactoryName(objectName);
 
@@ -49,7 +60,9 @@ public class Runtime {
         return retVal;
     }
 
-    public Element toXml(Set<ObjectName> instancesToMap, Document document) {
+    public Element toXml(Set<ObjectName> instancesToMap, Set<ObjectName> configBeans, Document document) {
+        Services serviceTracker = new Services();
+
         Element root = document.createElement(XmlNetconfConstants.DATA_KEY);
 
         Element modulesElement = document.createElement(XmlNetconfConstants.MODULES_KEY);
@@ -57,19 +70,30 @@ public class Runtime {
                 XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG);
         root.appendChild(modulesElement);
 
-        Map<String, Multimap<String, ObjectName>> moduleToInstances = mapInstancesToModules(instancesToMap);
+        Map<String, Multimap<String, ObjectName>> moduleToRuntimeInstance = mapInstancesToModules(instancesToMap);
+        Map<String, Map<String, Collection<ObjectName>>> moduleToConfigInstance = Config.getMappedInstances(
+                configBeans, serviceTracker, moduleConfigs);
+
+        for (String localNamespace : moduleConfigs.keySet()) {
+
+            Map<String, Collection<ObjectName>> instanceToMbe = moduleToConfigInstance.get(localNamespace);
 
-        for (String localNamespace : moduleRuntimes.keySet()) {
-            for (String moduleName : moduleRuntimes.get(localNamespace).keySet()) {
-                Multimap<String, ObjectName> instanceToRbe = moduleToInstances.get(moduleName);
+            for (String moduleName : moduleConfigs.get(localNamespace).keySet()) {
+                Multimap<String, ObjectName> instanceToRbe = moduleToRuntimeInstance.get(moduleName);
 
-                if (instanceToRbe == null)
-                    continue;
+                for (ObjectName instanceON : instanceToMbe.get(moduleName)) {
+                    String instanceName = ObjectNameUtil.getInstanceName(instanceON);
 
-                for (String instanceName : instanceToRbe.keySet()) {
-                    ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
-                    Element innerXml = moduleRuntime.toXml(localNamespace, instanceName, instanceToRbe.get(instanceName), document);
-                    modulesElement.appendChild(innerXml);
+                    Element runtimeXml;
+                    ModuleConfig moduleConfig = moduleConfigs.get(localNamespace).get(moduleName);
+                    if(instanceToRbe==null || instanceToRbe.containsKey(instanceName) == false) {
+                        runtimeXml = moduleConfig.toXml(instanceON, serviceTracker, document, localNamespace);
+                    } else {
+                        ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
+                        runtimeXml = moduleRuntime.toXml(localNamespace, instanceToRbe.get(instanceName), document,
+                                moduleConfig, instanceON, serviceTracker);
+                    }
+                    modulesElement.appendChild(runtimeXml);
                 }
 
             }
@@ -78,4 +102,14 @@ public class Runtime {
         return root;
     }
 
+    private ObjectName findInstance(Collection<ObjectName> objectNames, String instanceName) {
+        for (ObjectName objectName : objectNames) {
+            String name = ObjectNameUtil.getInstanceName(objectName);
+            if(name.equals(instanceName))
+                return objectName;
+        }
+
+        throw new UnsupportedOperationException("Unable to find config bean instance under name " + instanceName + " among " + objectNames);
+    }
+
 }
index 101af48..1fca164 100644 (file)
@@ -193,7 +193,7 @@ public class EditConfig extends AbstractConfigNetconfOperation {
         } catch (IllegalStateException e) {
             logger.warn("Error parsing xml", e);
             final Map<String, String> errorInfo = new HashMap<>();
-            errorInfo.put(ErrorTag.missing_attribute.name(), "Missing value for 'target' attribute");
+            errorInfo.put(ErrorTag.missing_attribute.name(), "Error parsing xml: " + e.getMessage());
             throw new NetconfDocumentedException(e.getMessage(), ErrorType.rpc, ErrorTag.missing_attribute,
                     ErrorSeverity.error, errorInfo);
         } catch (final IllegalArgumentException e) {
index b93843d..84a9f39 100644 (file)
@@ -18,10 +18,13 @@ import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorS
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.InstanceConfig;
+import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime.InstanceRuntime;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime.ModuleRuntime;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime.Runtime;
 import org.opendaylight.controller.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
+import org.opendaylight.controller.netconf.confignetconfconnector.operations.Datastore;
+import org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig.GetConfig;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.slf4j.Logger;
@@ -129,12 +132,21 @@ public class Get extends AbstractConfigNetconfOperation {
             throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application,
                     ErrorTag.operation_not_supported, ErrorSeverity.error, errorInfo);
         }
+
         final Set<ObjectName> runtimeBeans = configRegistryClient.lookupRuntimeBeans();
-        final Map<String, Map<String, ModuleRuntime>> moduleMappings = createModuleRuntimes(configRegistryClient,
+
+        //Transaction provider required only for candidate datastore
+        final Set<ObjectName> configBeans = Datastore.getInstanceQueryStrategy(Datastore.running, null)
+                .queryInstances(configRegistryClient);
+
+        final Map<String, Map<String, ModuleRuntime>> moduleRuntimes = createModuleRuntimes(configRegistryClient,
                 yangStoreSnapshot.getModuleMXBeanEntryMap());
-        final Runtime runtime = new Runtime(moduleMappings);
+        final Map<String, Map<String, ModuleConfig>> moduleConfigs = GetConfig.transform(configRegistryClient,
+                yangStoreSnapshot.getModuleMXBeanEntryMap());
+
+        final Runtime runtime = new Runtime(moduleRuntimes, moduleConfigs);
 
-        final Element element = runtime.toXml(runtimeBeans, document);
+        final Element element = runtime.toXml(runtimeBeans, configBeans, document);
 
         logger.info("{} operation successful", GET);
 
index 79b3e26..f2dfc70 100644 (file)
@@ -91,7 +91,7 @@ public class GetConfig extends AbstractConfigNetconfOperation {
     }
 
     // TODO refactor ... duplicate code
-    private Map<String, Map<String, ModuleConfig>> transform(final ConfigRegistryClient configRegistryClient,
+    public static Map<String, Map<String, ModuleConfig>> transform(final ConfigRegistryClient configRegistryClient,
             Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries) {
         return Maps.transformEntries(mBeanEntries,
                 new Maps.EntryTransformer<String, Map<String, ModuleMXBeanEntry>, Map<String, ModuleConfig>>() {
index 296b224..80b903b 100644 (file)
@@ -18,40 +18,22 @@ import org.junit.Test;
 import org.junit.matchers.JUnitMatchers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
 import org.opendaylight.controller.config.yang.store.impl.MbeParser;
-import org.opendaylight.controller.config.yang.test.impl.Asdf;
 import org.opendaylight.controller.config.yang.test.impl.ComplexDtoBInner;
 import org.opendaylight.controller.config.yang.test.impl.ComplexList;
 import org.opendaylight.controller.config.yang.test.impl.Deep;
-import org.opendaylight.controller.config.yang.test.impl.Deep2;
-import org.opendaylight.controller.config.yang.test.impl.Deep3;
-import org.opendaylight.controller.config.yang.test.impl.Deep4;
 import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.DtoAInner;
 import org.opendaylight.controller.config.yang.test.impl.DtoAInnerInner;
 import org.opendaylight.controller.config.yang.test.impl.DtoC;
 import org.opendaylight.controller.config.yang.test.impl.DtoD;
-import org.opendaylight.controller.config.yang.test.impl.InnerInnerRunningDataRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataAdditionalRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeRegistration;
 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistration;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistrator;
-import org.opendaylight.controller.config.yang.test.impl.NotStateBean;
-import org.opendaylight.controller.config.yang.test.impl.NotStateBeanInternal;
 import org.opendaylight.controller.config.yang.test.impl.Peers;
-import org.opendaylight.controller.config.yang.test.impl.RetValContainer;
-import org.opendaylight.controller.config.yang.test.impl.RetValList;
 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
@@ -143,7 +125,6 @@ public class NetconfMappingTest extends AbstractConfigTest {
         edit("netconfMessages/editConfig.xml");
         checkBinaryLeafEdited(getConfigCandidate());
 
-
         // default-operation:none, should not affect binary leaf
         edit("netconfMessages/editConfig_none.xml");
         checkBinaryLeafEdited(getConfigCandidate());
@@ -151,9 +132,10 @@ public class NetconfMappingTest extends AbstractConfigTest {
         // check after edit
         commit();
         Element response = getConfigRunning();
-
+        System.err.println(XmlUtil.toString(response));
         checkBinaryLeafEdited(response);
         checkTypeConfigAttribute(response);
+        checkTypedefs(response);
 
         edit("netconfMessages/editConfig_remove.xml");
 
@@ -375,7 +357,14 @@ public class NetconfMappingTest extends AbstractConfigTest {
             buf.append(XmlElement.fromDomElement(e).getTextContent());
         }
         assertEquals("810", buf.toString());
+    }
+
+    private void checkTypedefs(final Element response) {
+        NodeList children = response.getElementsByTagName("extended");
+        assertEquals(1, children.getLength());
 
+        children = response.getElementsByTagName("extended-twice");
+        assertEquals(1, children.getLength());
     }
 
     private void checkTypeConfigAttribute(Element response) {
@@ -407,51 +396,28 @@ public class NetconfMappingTest extends AbstractConfigTest {
     @Test
     public void testConfigNetconfRuntime() throws Exception {
 
-        ModuleIdentifier id = new ModuleIdentifier(NetconfTestImplModuleFactory.NAME, "instance");
-        RootRuntimeBeanRegistrator rootReg = new RootRuntimeBeanRegistratorImpl(internalJmxRegistrator, id);
-        NetconfTestImplRuntimeRegistrator registrator = new NetconfTestImplRuntimeRegistrator(rootReg);
-
-        NetconfTestImplRuntimeRegistration a = registerRoot(registrator);
-        InnerRunningDataRuntimeRegistration reg = registerInner(a);
-        registerInner2(reg);
-
-        id = new ModuleIdentifier(NetconfTestImplModuleFactory.NAME, "instance2");
-        rootReg = new RootRuntimeBeanRegistratorImpl(internalJmxRegistrator, id);
-        registrator = new NetconfTestImplRuntimeRegistrator(rootReg);
-
-        a = registerRoot(registrator);
-        registerAdditional(a);
-        registerAdditional(a);
-        registerAdditional(a);
-        registerAdditional(a);
-        reg = registerInner(a);
-        registerInner2(reg);
-        reg = registerInner(a);
-        registerInner2(reg);
-        registerInner2(reg);
-        reg = registerInner(a);
-        registerInner2(reg);
-        registerInner2(reg);
-        registerInner2(reg);
-        reg = registerInner(a);
-        registerInner2(reg);
-        registerInner2(reg);
-        registerInner2(reg);
-        registerInner2(reg);
+        createModule(INSTANCE_NAME);
 
-        Element response = get();
+        edit("netconfMessages/editConfig.xml");
+        checkBinaryLeafEdited(getConfigCandidate());
 
-        System.err.println(XmlUtil.toString(response));
+        // check after edit
+        commit();
+        Element response = get();
 
-        assertEquals(2, getElementsSize(response, "module"));
+        assertEquals(2/*With runtime beans*/ + 2 /*Without runtime beans*/, getElementsSize(response, "module"));
+        // data from state
         assertEquals(2, getElementsSize(response, "asdf"));
-        assertEquals(5, getElementsSize(response, "inner-running-data"));
-        assertEquals(5, getElementsSize(response, "deep2"));
-        assertEquals(11, getElementsSize(response, "inner-inner-running-data"));
-        assertEquals(11, getElementsSize(response, "deep3"));
-        assertEquals(11 * 2, getElementsSize(response, "list-of-strings"));
-        assertEquals(4, getElementsSize(response, "inner-running-data-additional"));
-        assertEquals(4, getElementsSize(response, "deep4"));
+        // data from running config
+        assertEquals(2, getElementsSize(response, "simple-short"));
+
+        assertEquals(8, getElementsSize(response, "inner-running-data"));
+        assertEquals(8, getElementsSize(response, "deep2"));
+        assertEquals(8 * 4, getElementsSize(response, "inner-inner-running-data"));
+        assertEquals(8 * 4, getElementsSize(response, "deep3"));
+        assertEquals(8 * 4 * 2, getElementsSize(response, "list-of-strings"));
+        assertEquals(8, getElementsSize(response, "inner-running-data-additional"));
+        assertEquals(8, getElementsSize(response, "deep4"));
         // TODO assert keys
 
         RuntimeRpc netconf = new RuntimeRpc(yangStoreSnapshot, configRegistryClient, NETCONF_SESSION_ID);
@@ -479,153 +445,6 @@ public class NetconfMappingTest extends AbstractConfigTest {
         return response.getElementsByTagName(elementName).getLength();
     }
 
-    private Object registerAdditional(final NetconfTestImplRuntimeRegistration a) {
-        class InnerRunningDataAdditionalRuntimeMXBeanTest implements InnerRunningDataAdditionalRuntimeMXBean {
-
-            private final int simpleInt;
-            private final String simpleString;
-
-            public InnerRunningDataAdditionalRuntimeMXBeanTest(final int simpleInt, final String simpleString) {
-                this.simpleInt = simpleInt;
-                this.simpleString = simpleString;
-            }
-
-            @Override
-            public Integer getSimpleInt3() {
-                return this.simpleInt;
-            }
-
-            @Override
-            public Deep4 getDeep4() {
-                final Deep4 d = new Deep4();
-                d.setBoool(false);
-                return d;
-            }
-
-            @Override
-            public String getSimpleString() {
-                return this.simpleString;
-            }
-
-            @Override
-            public void noArgInner() {
-            }
-
-        }
-
-        final int simpleInt = counter++;
-        return a.register(new InnerRunningDataAdditionalRuntimeMXBeanTest(simpleInt, "randomString_" + simpleInt));
-    }
-
-    private void registerInner2(final InnerRunningDataRuntimeRegistration reg) {
-        class InnerInnerRunningDataRuntimeMXBeanTest implements InnerInnerRunningDataRuntimeMXBean {
-
-            private final int simpleInt;
-
-            public InnerInnerRunningDataRuntimeMXBeanTest(final int simpleInt) {
-                this.simpleInt = simpleInt;
-            }
-
-            @Override
-            public List<NotStateBean> getNotStateBean() {
-                final NotStateBean notStateBean = new NotStateBean();
-                final NotStateBeanInternal notStateBeanInternal = new NotStateBeanInternal();
-                notStateBean.setNotStateBeanInternal(Lists.newArrayList(notStateBeanInternal));
-                return Lists.newArrayList(notStateBean);
-            }
-
-            @Override
-            public Integer getSimpleInt3() {
-                return this.simpleInt;
-            }
-
-            @Override
-            public Deep3 getDeep3() {
-                return new Deep3();
-            }
-
-            @Override
-            public List<String> getListOfStrings() {
-                return Lists.newArrayList("l1", "l2");
-            }
-
-            @Override
-            public List<RetValList> listOutput() {
-                return Lists.newArrayList(new RetValList());
-            }
-
-            @Override
-            public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
-                return aBoolean;
-            }
-
-            @Override
-            public RetValContainer containerOutput() {
-                return new RetValContainer();
-            }
-
-            @Override
-            public List<String> leafListOutput() {
-                return Lists.newArrayList("1", "2");
-            }
-
-        }
-
-        reg.register(new InnerInnerRunningDataRuntimeMXBeanTest(counter++));
-
-    }
-
-    private static int counter = 1000;
-
-    private InnerRunningDataRuntimeRegistration registerInner(final NetconfTestImplRuntimeRegistration a) {
-
-        class InnerRunningDataRuntimeMXBeanTest implements InnerRunningDataRuntimeMXBean {
-
-            private final int simpleInt;
-
-            public InnerRunningDataRuntimeMXBeanTest(final int simpleInt) {
-                this.simpleInt = simpleInt;
-            }
-
-            @Override
-            public Integer getSimpleInt3() {
-                return this.simpleInt;
-            }
-
-            @Override
-            public Deep2 getDeep2() {
-                return new Deep2();
-            }
-
-        }
-        return a.register(new InnerRunningDataRuntimeMXBeanTest(counter++));
-    }
-
-    private NetconfTestImplRuntimeRegistration registerRoot(final NetconfTestImplRuntimeRegistrator registrator) {
-        final NetconfTestImplRuntimeRegistration a = registrator.register(new NetconfTestImplRuntimeMXBean() {
-
-            @Override
-            public Long getCreatedSessions() {
-                return 11L;
-            }
-
-            @Override
-            public Asdf getAsdf() {
-                final Asdf asdf = new Asdf();
-                asdf.setSimpleInt(55);
-                asdf.setSimpleString("asdf");
-                return asdf;
-            }
-
-            @Override
-            public String noArg(final String arg1) {
-                return arg1.toUpperCase();
-            }
-
-        });
-        return a;
-    }
-
     private Element executeOp(final NetconfOperation op, final String filename) throws ParserConfigurationException,
             SAXException, IOException, NetconfDocumentedException {
 
@@ -643,7 +462,7 @@ public class NetconfMappingTest extends AbstractConfigTest {
 
     private List<InputStream> getYangs() throws FileNotFoundException {
         List<String> paths = Arrays.asList("/META-INF/yang/config.yang", "/META-INF/yang/rpc-context.yang",
-                "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang",
+                "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang", "/META-INF/yang/test-types.yang",
                 "/META-INF/yang/ietf-inet-types.yang");
         final Collection<InputStream> yangDependencies = new ArrayList<>();
         for (String path : paths) {
index 6c244a0..65cc2b4 100644 (file)
@@ -36,22 +36,16 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator;
-import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.store.api.YangStoreException;
 import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService;
-import org.opendaylight.controller.config.yang.test.impl.Asdf;
 import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistrator;
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.client.NetconfClient;
@@ -165,7 +159,7 @@ public class NetconfITTest extends AbstractConfigTest {
 
     static Collection<InputStream> getBasicYangs() throws IOException {
         List<String> paths = Arrays.asList("/META-INF/yang/config.yang", "/META-INF/yang/rpc-context.yang",
-                "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang",
+                "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang", "/META-INF/yang/test-types.yang",
                 "/META-INF/yang/ietf-inet-types.yang");
         final Collection<InputStream> yangDependencies = new ArrayList<>();
         List<String> failedToFind = new ArrayList<>();
@@ -281,7 +275,7 @@ public class NetconfITTest extends AbstractConfigTest {
         NetconfTestImplModuleMXBean proxy = configRegistryClient
                 .newMXBeanProxy(impl, NetconfTestImplModuleMXBean.class);
         proxy.setTestingDep(dep);
-        registerRuntimeBean();
+        proxy.setSimpleShort((short)0);
 
         transaction.commit();
 
@@ -306,29 +300,6 @@ public class NetconfITTest extends AbstractConfigTest {
         }
     }
 
-    private void registerRuntimeBean() {
-        BaseJMXRegistrator baseJMXRegistrator = new BaseJMXRegistrator(ManagementFactory.getPlatformMBeanServer());
-        RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = baseJMXRegistrator
-                .createRuntimeBeanRegistrator(new ModuleIdentifier(NetconfTestImplModuleFactory.NAME, "instance"));
-        NetconfTestImplRuntimeRegistrator reg = new NetconfTestImplRuntimeRegistrator(runtimeBeanRegistrator);
-        reg.register(new NetconfTestImplRuntimeMXBean() {
-            @Override
-            public Asdf getAsdf() {
-                return null;
-            }
-
-            @Override
-            public Long getCreatedSessions() {
-                return null;
-            }
-
-            @Override
-            public String noArg(String arg1) {
-                return "from no arg";
-            }
-        });
-    }
-
     @Test
 //    @Ignore
     public void testStartExi() throws Exception {
index 0611dce..d44652b 100644 (file)
 
                     <name>test1</name>
 
+                    <extended>
+                            1
+                    </extended>
+
+                    <extended-twice>
+                            1
+                    </extended-twice>
+
                     <simple-long-2>44</simple-long-2>
                     <binaryLeaf>8</binaryLeaf>
                     <binaryLeaf>1</binaryLeaf>
@@ -85,6 +93,8 @@
                         test-impl:impl-netconf
                     </type>
                     <name>test2</name>
+                    <simple-short>4</simple-short>
+
                     <testing-dep>
                         <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:test">prefix:testing</type>
                         <name>ref_dep</name>
index 413b78c..46b833c 100644 (file)
@@ -1,6 +1,6 @@
 <rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <no-arg xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
-        <context-instance>/modules/module[type='impl-netconf' and name='instance']</context-instance>
+        <context-instance>/modules/module[type='impl-netconf' and name='test1']</context-instance>
         <arg1>
             testarg1
         </arg1>
index cf15000..3d5117e 100644 (file)
@@ -1,7 +1,7 @@
 <rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
     <noArgInner xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
         <context-instance>
-            /modules/module[name='instance2'][type='impl-netconf']/inner-running-data-additional[key='randomString_1003']
+            /modules/module[name='test1'][type='impl-netconf']/inner-running-data-additional[key='1']
         </context-instance>
     </noArgInner>
 </rpc>
index 31f417e..c492ee7 100644 (file)
@@ -2,7 +2,7 @@
     <noArgInnerInner
             xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
         <context-instance>
-            /modules/module[type='impl-netconf'][name='instance2']/inner-running-data[key='1015']/inner-inner-running-data[key='1017']
+            /modules/module[type='impl-netconf'][name='test2']/inner-running-data[key='2']/inner-inner-running-data[key='3']
         </context-instance>
 
         <arg1>
index af0835b..4ba0349 100644 (file)
@@ -2,7 +2,7 @@
     <leaf-list-output
             xmlns="urn:opendaylight:params:xml:ns:yang:controller:test:impl">
         <context-instance>
-            /modules/module[type='impl-netconf'][name='instance2']/inner-running-data[key='1015']/inner-inner-running-data[key='1017']
+            /modules/module[type='impl-netconf'][name='test1']/inner-running-data[key='0']/inner-inner-running-data[key='1']
         </context-instance>
     </leaf-list-output>
 </rpc>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.