[ONOS-5877][ONOS-5886] runtime api implementation changes.

Change-Id: Ie341b11b2c1a60734c894596a7f601f1c7280bb8
diff --git a/compiler/plugin/pom.xml b/compiler/plugin/pom.xml
index bcf0061..f34cf1d 100644
--- a/compiler/plugin/pom.xml
+++ b/compiler/plugin/pom.xml
@@ -34,6 +34,7 @@
     <modules>
         <module>maven</module>
         <module>buck</module>
+        <module>utils</module>
     </modules>
 
     <dependencies>
diff --git a/compiler/plugin/utils/pom.xml b/compiler/plugin/utils/pom.xml
new file mode 100644
index 0000000..edebb59
--- /dev/null
+++ b/compiler/plugin/utils/pom.xml
@@ -0,0 +1,63 @@
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-yang-compiler-plugin</artifactId>
+        <version>1.12-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-yang-compiler-plugin-utils</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-tool</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>RELEASE</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.0.2</version>
+                <configuration>
+                    <skipIfEmpty>true</skipIfEmpty>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>default</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java b/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java
new file mode 100644
index 0000000..24797b8
--- /dev/null
+++ b/compiler/plugin/utils/src/main/java/org/onosproject/yang/compiler/plugin/utils/YangApacheUtils.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.plugin.utils;
+
+import org.onosproject.yang.DefaultYangModel;
+import org.onosproject.yang.DefaultYangModule;
+import org.onosproject.yang.DefaultYangModuleId;
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.YangModuleId;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import static java.nio.file.Paths.get;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.parseJarFile;
+import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_META_DATA;
+import static org.onosproject.yang.compiler.utils.UtilConstants.YANG_RESOURCES;
+import static org.osgi.framework.FrameworkUtil.getBundle;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Utilities for runtime to use apache tools.
+ */
+public final class YangApacheUtils {
+
+    private static final String SYSTEM = SLASH + "system" + SLASH;
+    private static final String MAVEN = "mvn:";
+    private static final String JAR = ".jar";
+    private static final String USER_DIRECTORY = "user.dir";
+    private static final String DATE_FORMAT = "yyyy-mm-dd";
+    private static final String ONOS = "org.onosproject";
+    private static final Logger log = getLogger(YangApacheUtils.class);
+
+    /**
+     * Returns YANG model for generated module class.
+     *
+     * @param modClass generated module class
+     * @return YANG model
+     */
+    public static YangModel getYangModel(Class<?> modClass) {
+        BundleContext context = getBundle(modClass).getBundleContext();
+        if (context != null) {
+            Bundle[] bundles = context.getBundles();
+            Bundle bundle;
+            int len = bundles.length;
+            List<YangNode> curNodes;
+            String jarPath;
+            String metaPath;
+            for (int i = len - 1; i >= 0; i--) {
+                bundle = bundles[i];
+                if (bundle.getSymbolicName().contains(ONOS)) {
+                    jarPath = getJarPathFromBundleLocation(
+                            bundle.getLocation(), context.getProperty(USER_DIRECTORY));
+                    metaPath = jarPath + SLASH +
+                            YANG_RESOURCES + SLASH + YANG_META_DATA;
+                    curNodes = processJarParsingOperations(jarPath);
+                    // process model creations.
+                    if (curNodes != null && !curNodes.isEmpty()) {
+                        return processYangModel(metaPath, curNodes);
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns YANG model for application.
+     *
+     * @param path path for metadata file
+     * @return YANG model
+     */
+    public static YangModel processYangModel(String path, List<YangNode>
+            curNodes) {
+        DefaultYangModel model = new DefaultYangModel();
+        YangModuleId id;
+        for (YangSchemaNode node : curNodes) {
+            id = processModuleId((YangNode) node);
+            org.onosproject.yang.YangModule module =
+                    new DefaultYangModule(id, get(node.getFileName()), get(path));
+            model.addModule(id, module);
+        }
+        return model;
+    }
+
+    /**
+     * Returns YANG module id for a given YANG module node.
+     *
+     * @param module YANG module
+     * @return YANG module id for a given YANG module node
+     */
+    public static YangModuleId processModuleId(YangNode module) {
+        String rev = getDateInStringFormat(module);
+        return new DefaultYangModuleId(module.getName(), rev);
+    }
+
+    /**
+     * Returns date in string format.
+     *
+     * @param schemaNode schema node
+     * @return date in string format
+     */
+    public static String getDateInStringFormat(YangNode schemaNode) {
+        if (schemaNode != null) {
+            if (schemaNode.getRevision() != null) {
+                return new SimpleDateFormat(DATE_FORMAT)
+                        .format(schemaNode.getRevision().getRevDate());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns jar path from bundle mvnLocationPath.
+     *
+     * @param mvnLocationPath mvnLocationPath of bundle
+     * @return path of jar
+     */
+    private static String getJarPathFromBundleLocation(String mvnLocationPath,
+                                                       String currentDirectory) {
+        String path = currentDirectory + SYSTEM;
+        if (mvnLocationPath.contains(MAVEN)) {
+            String[] strArray = mvnLocationPath.split(MAVEN);
+            if (strArray[1].contains(File.separator)) {
+                String[] split = strArray[1].split(File.separator);
+                if (split[0].contains(PERIOD)) {
+                    String[] groupId = split[0].split(Pattern.quote(PERIOD));
+                    return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
+                            SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Process jar file for fetching YANG nodes.
+     *
+     * @param path jar file path
+     * @return YANG schema nodes
+     */
+    private static List<YangNode> processJarParsingOperations(String path) {
+        //Deserialize data model and get the YANG node set.
+        String jar = path + JAR;
+        try {
+            File file = new File(jar);
+            if (file.exists()) {
+                return parseJarFile(path + JAR, path);
+            }
+        } catch (IOException e) {
+            log.error(" failed to parse the jar file in path {} : {} ", path,
+                      e.getMessage());
+        }
+        return null;
+    }
+}
diff --git a/runtime/app/pom.xml b/runtime/app/pom.xml
new file mode 100644
index 0000000..973b6a2
--- /dev/null
+++ b/runtime/app/pom.xml
@@ -0,0 +1,99 @@
+<!--
+  ~ Copyright 2017-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-yang-runtime</artifactId>
+        <version>1.12-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-yang-runtime-app</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-model</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-datamodel</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime-uils</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-api</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>RELEASE</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.onosproject</groupId>
+                <artifactId>onos-yang-compiler-maven-plugin</artifactId>
+                <version>${project.version}</version>
+                <configuration>
+                    <yangFilesDir>src/test/resources</yangFilesDir>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>default</id>
+                        <goals>
+                            <goal>yang2java</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.0.2</version>
+                <configuration>
+                    <skipIfEmpty>true</skipIfEmpty>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>default</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultAppModuleInfo.java b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultAppModuleInfo.java
new file mode 100644
index 0000000..8fdc82b
--- /dev/null
+++ b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultAppModuleInfo.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.onosproject.yang.runtime.api.AppModuleInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents default application module information.
+ */
+public class DefaultAppModuleInfo implements AppModuleInfo {
+
+    private Class<?> module;
+    private final List<String> features;
+
+    /**
+     * Creates an instance of application module information.
+     */
+    public DefaultAppModuleInfo() {
+        features = new ArrayList<>();
+    }
+
+    @Override
+    public Class<?> getModuleClass() {
+        return module;
+    }
+
+    @Override
+    public void setModuleClass(Class<?> moduleClass) {
+        checkNotNull(moduleClass);
+        module = moduleClass;
+    }
+
+    @Override
+    public List<String> getFeatureList() {
+        return features;
+    }
+
+    @Override
+    public void addFeature(String feature) {
+        features.add(feature);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(module, features);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        DefaultAppModuleInfo that = (DefaultAppModuleInfo) obj;
+        return Objects.equals(module, that.module);
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(getClass())
+                .add("moduleClass", module)
+                .add("features", features)
+                .toString();
+    }
+}
diff --git a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultModelRegistrationParam.java b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultModelRegistrationParam.java
new file mode 100644
index 0000000..36d72be
--- /dev/null
+++ b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultModelRegistrationParam.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.YangModuleId;
+import org.onosproject.yang.runtime.api.AppModuleInfo;
+import org.onosproject.yang.runtime.api.ModelRegistrationParam;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents default model registration parameter.
+ */
+public class DefaultModelRegistrationParam implements ModelRegistrationParam {
+
+    private YangModel model;
+    private final Map<YangModuleId, AppModuleInfo> appInfoMap;
+
+    /**
+     * Creates an instance of model registration parameter.
+     */
+    public DefaultModelRegistrationParam() {
+        appInfoMap = new LinkedHashMap<>();
+    }
+
+    @Override
+    public YangModel getYangModel() {
+        return model;
+    }
+
+    @Override
+    public void setYangModel(YangModel model) {
+        checkNotNull(model);
+        this.model = model;
+    }
+
+    @Override
+    public AppModuleInfo getAppModuleInfo(YangModuleId id) {
+        return appInfoMap.get(id);
+    }
+
+    @Override
+    public void addAppModuleInfo(YangModuleId id, AppModuleInfo info) {
+        appInfoMap.put(id, info);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(appInfoMap, model);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        DefaultModelRegistrationParam that = (DefaultModelRegistrationParam) obj;
+        if (appInfoMap.size() == that.appInfoMap.size()) {
+            for (Map.Entry<YangModuleId, AppModuleInfo> entry : appInfoMap.entrySet()) {
+                if (!that.appInfoMap.containsKey(entry.getKey()) ||
+                        !that.appInfoMap.containsValue(entry.getValue())) {
+                    return false;
+                }
+            }
+            return Objects.equals(model, that.model);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(getClass())
+                .add("model", model)
+                .add("appInfo", appInfoMap)
+                .toString();
+    }
+}
diff --git a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java
new file mode 100644
index 0000000..691cf2d
--- /dev/null
+++ b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java
@@ -0,0 +1,433 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.YangModuleId;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.runtime.api.AppModuleInfo;
+import org.onosproject.yang.runtime.api.ModelRegistrationParam;
+import org.onosproject.yang.runtime.api.YangModelRegistry;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import static java.util.Collections.sort;
+import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.getDateInStringFormat;
+import static org.onosproject.yang.runtime.utils.RuntimeHelper.getInterfaceClassName;
+import static org.onosproject.yang.runtime.utils.RuntimeHelper.getNodes;
+import static org.onosproject.yang.runtime.utils.RuntimeHelper.getOpParamClassName;
+import static org.onosproject.yang.runtime.utils.RuntimeHelper.getServiceName;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Represents YANG model registry implementation.
+ */
+public class DefaultYangModelRegistry implements YangModelRegistry {
+
+    private static final Logger log = getLogger(DefaultYangModelRegistry.class);
+    private static final String AT = "@";
+
+    /*
+     * Map for storing YANG schema nodes. Key will be the schema name of
+     * module node defined in YANG file.
+     */
+    private final ConcurrentMap<String, ConcurrentMap<String, YangSchemaNode>>
+            yangSchemaStore;
+
+    /*
+     * Map for storing YANG schema nodes with respect to root's generated
+     * interface file name.
+     */
+    private final ConcurrentMap<String, YangSchemaNode> interfaceNameKeyStore;
+
+    /*
+     * Map for storing YANG schema nodes root's generated op param file name.
+     */
+    private final ConcurrentMap<String, YangSchemaNode> opParamNameKeyStore;
+
+    /*
+     * Map for storing YANG schema nodes with respect to app name. Key will
+     * be the registered class name.
+     */
+    private final ConcurrentMap<String, YangSchemaNode> appNameKeyStore;
+
+    /*
+     * Map for storing registered classes. Will be used by YOB for class
+     * loading operations. key will be qualified name of generated class.
+     * It will be maintained for top level class i.e. module.
+     */
+    private final ConcurrentMap<String, Class<?>> registerClassStore;
+
+    /**
+     * Map for storing schema nodes with respect to namespace. Will be used
+     * by YCH in scenario where module name is not present in XML.
+     */
+    private final ConcurrentMap<String, YangSchemaNode> nameSpaceSchemaStore;
+
+    /**
+     * Set of YANG models.
+     */
+    private final Set<YangModel> models;
+
+    /**
+     * Creates an instance of default YANG schema registry.
+     */
+    public DefaultYangModelRegistry() {
+        models = new LinkedHashSet<>();
+        yangSchemaStore = new ConcurrentHashMap<>();
+        interfaceNameKeyStore = new ConcurrentHashMap<>();
+        opParamNameKeyStore = new ConcurrentHashMap<>();
+        registerClassStore = new ConcurrentHashMap<>();
+        appNameKeyStore = new ConcurrentHashMap<>();
+        nameSpaceSchemaStore = new ConcurrentHashMap<>();
+    }
+
+    @Override
+    public void registerModel(ModelRegistrationParam param) {
+        YangModel model = param.getYangModel();
+        if (model != null) {
+            Set<YangNode> curNodes = getNodes(model);
+            models.add(model);
+            AppModuleInfo info;
+            Class<?> service;
+            for (YangModuleId id : model.getYangModulesId()) {
+                info = param.getAppModuleInfo(id);
+                if (info != null) {
+                    service = info.getModuleClass();
+                    String name = service.getName();
+                    if (!verifyIfApplicationAlreadyRegistered(service)) {
+                        if (!registerClassStore.containsKey(name)) {
+                            registerClassStore.put(name, service);
+                        }
+                        if (curNodes != null && !curNodes.isEmpty()) {
+                            processRegistration(service, curNodes);
+                        }
+                    }
+                }
+            }
+        } else {
+            throw new RuntimeException("model can not be null.");
+        }
+    }
+
+    @Override
+    public void unregisterModel(ModelRegistrationParam param) {
+        synchronized (DefaultYangModelRegistry.class) {
+            YangModel model = param.getYangModel();
+            if (model != null) {
+                AppModuleInfo info;
+                for (YangModuleId id : model.getYangModulesId()) {
+                    info = param.getAppModuleInfo(id);
+                    YangSchemaNode curNode;
+                    Class<?> sClass = info.getModuleClass();
+                    String serviceName = sClass.getName();
+                    //Remove registered class from store.
+                    registerClassStore.remove(serviceName);
+                    //check if service is in app store.
+                    curNode = appNameKeyStore.get(serviceName);
+                    if (curNode == null) {
+                        curNode = interfaceNameKeyStore.get(serviceName);
+                    }
+
+                    if (curNode != null) {
+                        removeSchemaNode(curNode);
+                        interfaceNameKeyStore.remove(getInterfaceClassName(curNode));
+                        opParamNameKeyStore.remove(getOpParamClassName(curNode));
+                        appNameKeyStore.remove(serviceName);
+                        nameSpaceSchemaStore.remove(curNode.getNameSpace()
+                                                            .getModuleNamespace());
+                        log.info(" service class {} of model {} is " +
+                                         "unregistered.", sClass
+                                         .getSimpleName(), param);
+                    } else {
+                        throw new RuntimeException(sClass.getSimpleName() +
+                                                           " service was not registered.");
+                    }
+                }
+            } else {
+                throw new RuntimeException("model can not be null.");
+            }
+        }
+    }
+
+    @Override
+    public Set<YangModel> getModels() {
+        return models;
+    }
+
+    /**
+     * Returns schema node for the given name. Name should be schema defined
+     * name.
+     *
+     * @param schemaName schema name
+     * @return YANG schema node
+     */
+    public YangSchemaNode getForSchemaName(String schemaName) {
+        return getForNameWithRev(schemaName);
+    }
+
+    /**
+     * Returns schema node for the given name. Name should be generated class
+     * name. the name provided here should be for registered service class.
+     *
+     * @param appName application name
+     * @return YANG schema node
+     */
+    public YangSchemaNode getForAppName(String appName) {
+        YangSchemaNode node = appNameKeyStore.get(appName);
+        if (node == null) {
+            log.error("{} not found.", appName);
+        }
+        return node;
+    }
+
+    /**
+     * Returns schema node for the given name. Name should be generated class
+     * name. the name provided here should be for registered interface class.
+     *
+     * @param name interface class name
+     * @return YANG schema node
+     */
+    public YangSchemaNode getForInterfaceFileName(String name) {
+        YangSchemaNode node = interfaceNameKeyStore.get(name);
+        if (node == null) {
+            log.error("{} not found.", name);
+        }
+        return node;
+    }
+
+    /**
+     * Returns schema node for the given name. Name should be generated class
+     * name. the name provided here should be for registered op param class.
+     *
+     * @param name opparm class name
+     * @return YANG schema node
+     */
+    public YangSchemaNode getForOpPramFileName(
+            String name) {
+        YangSchemaNode node = opParamNameKeyStore.get(name);
+        if (node == null) {
+            log.error("{} not found.", name);
+        }
+        return node;
+    }
+
+    /**
+     * Returns schema node for the given name. Name should be nodes namespace
+     * defined in YANG file
+     *
+     * @param nameSpace name space of YANG file
+     * @return YANG schema node
+     */
+    public YangSchemaNode getForNameSpace(String nameSpace) {
+
+        YangSchemaNode node = nameSpaceSchemaStore.get(nameSpace);
+        if (node == null) {
+            log.error("node with {} namespace not found.", nameSpace);
+        }
+        return node;
+    }
+
+    /**
+     * Returns registered service for given schema node.
+     *
+     * @param schemaNode schema node
+     * @return registered class
+     */
+    public Class<?> getRegisteredClass(YangSchemaNode schemaNode) {
+        String interfaceName = getInterfaceClassName(schemaNode);
+        String serviceName = getServiceName(schemaNode);
+        Class<?> regClass = registerClassStore.get(serviceName);
+        if (regClass == null) {
+            regClass = registerClassStore.get(interfaceName);
+        }
+        return regClass;
+    }
+
+    /**
+     * Process application registration.
+     *
+     * @param service service class
+     * @param nodes   YANG nodes
+     */
+    private void processRegistration(Class<?> service, Set<YangNode> nodes) {
+
+        // process storing operations.
+        YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(), nodes);
+        if (schemaNode != null) {
+            //Process application context for registrations.
+            processApplicationContext(schemaNode, service.getName());
+        }
+    }
+
+    /**
+     * Returns the node for which corresponding class is generated.
+     *
+     * @param name  generated class name
+     * @param nodes list of yang nodes
+     * @return node for which corresponding class is generated
+     */
+    private YangNode findNodeWhichShouldBeReg(String name,
+                                              Set<YangNode> nodes) {
+        for (YangNode node : nodes) {
+            if (name.equals(getServiceName(node)) ||
+                    name.equals(getInterfaceClassName(node))) {
+                return node;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Verifies if application is already registered with runtime.
+     *
+     * @param appClass application class
+     * @return true if application already registered
+     */
+    private boolean verifyIfApplicationAlreadyRegistered(Class<?> appClass) {
+        String appName = appClass.getName();
+        return registerClassStore.containsKey(appName) ||
+                interfaceNameKeyStore.containsKey(appName);
+    }
+
+    /**
+     * Process an application an updates the maps for YANG model registry.
+     *
+     * @param appNode application YANG schema nodes
+     * @param name    class name
+     */
+    private void processApplicationContext(YangSchemaNode appNode, String name) {
+
+        //Update map for which registrations is being called.
+        try {
+            if (appNode.isNotificationPresent()) {
+                //TODO: add logic for getting wrt RPC.
+                appNameKeyStore.put(name, appNode);
+            }
+        } catch (DataModelException e) {
+            e.printStackTrace();
+        }
+
+        // Updates schema store.
+        addToSchemaStore(appNode);
+        // update interface store.
+        interfaceNameKeyStore.put(getInterfaceClassName(appNode), appNode);
+
+        //update op param store.
+        opParamNameKeyStore.put(getOpParamClassName(appNode), appNode);
+
+        //update namespaceSchema store.
+        nameSpaceSchemaStore.put(appNode.getNameSpace().getModuleNamespace(), appNode);
+
+        log.info("successfully registered this application {}", name);
+    }
+
+    /**
+     * Returns schema node based on the revision.
+     *
+     * @param name name of the schema node
+     * @return schema node based on the revision
+     */
+    private YangSchemaNode getForNameWithRev(String name) {
+        ConcurrentMap<String, YangSchemaNode> revMap;
+        YangSchemaNode schemaNode;
+        if (name.contains(AT)) {
+            String[] revArray = name.split(AT);
+            revMap = yangSchemaStore.get(revArray[0]);
+            schemaNode = revMap.get(name);
+            if (schemaNode == null) {
+                log.error("{} not found.", name);
+            }
+            return schemaNode;
+        }
+        if (yangSchemaStore.containsKey(name)) {
+            revMap = yangSchemaStore.get(name);
+            if (revMap != null && !revMap.isEmpty()) {
+                YangSchemaNode node = revMap.get(name);
+                if (node != null) {
+                    return node;
+                }
+                String revName = getLatestVersion(revMap);
+                return revMap.get(revName);
+            }
+        }
+        log.error("{} not found.", name);
+        return null;
+    }
+
+    private String getLatestVersion(ConcurrentMap<String, YangSchemaNode> revMap) {
+        List<String> keys = new ArrayList<>();
+        for (Map.Entry<String, YangSchemaNode> entry : revMap.entrySet()) {
+            keys.add(entry.getKey());
+        }
+        sort(keys);
+        return keys.get(keys.size() - 1);
+    }
+
+    /**
+     * Adds schema node when different revision of node has received.
+     *
+     * @param schemaNode schema node
+     */
+    private void addToSchemaStore(YangSchemaNode schemaNode) {
+
+        String date = getDateInStringFormat((YangNode) schemaNode);
+        String name = schemaNode.getName();
+        String revName = name;
+        if (date != null) {
+            revName = name + AT + date;
+        }
+        //check if already present.
+        if (!yangSchemaStore.containsKey(name)) {
+            ConcurrentMap<String, YangSchemaNode> revStore =
+                    new ConcurrentHashMap<>();
+            revStore.put(revName, schemaNode);
+            yangSchemaStore.put(name, revStore);
+        } else {
+            yangSchemaStore.get(name).put(revName, schemaNode);
+        }
+    }
+
+    /**
+     * Removes schema node from schema map.
+     *
+     * @param removableNode schema node which needs to be removed
+     */
+    private void removeSchemaNode(YangSchemaNode removableNode) {
+        String name = removableNode.getName();
+        String revName = name;
+        String date = getDateInStringFormat((YangNode) removableNode);
+        if (date != null) {
+            revName = name + AT + date;
+        }
+        ConcurrentMap<String, YangSchemaNode> revMap = yangSchemaStore.get(name);
+        if (revMap != null && !revMap.isEmpty() && revMap.size() != 1) {
+            revMap.remove(revName);
+        } else {
+            yangSchemaStore.remove(removableNode.getName());
+        }
+    }
+}
diff --git a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/package-info.java b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/package-info.java
new file mode 100644
index 0000000..d4e7f72
--- /dev/null
+++ b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of runtime api.
+ */
+package org.onosproject.yang.runtime.app;
\ No newline at end of file
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java
new file mode 100644
index 0000000..8445d34
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java
@@ -0,0 +1,400 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangRevision;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.getDateInStringFormat;
+
+/**
+ * Unit test for model registry.
+ */
+public class DefaultYangModelRegistryTest {
+
+    private static final String SERVICE_NAME_3 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network3.rev20151208.IetfNetwork3Service";
+    private static final String SCHEMA_NAME_3 = "ietf-network3";
+    private static final String INTERFACE_NAME_3 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network3.rev20151208.IetfNetwork3";
+    private static final String OP_PARAM_NAME_3 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network3.rev20151208.IetfNetwork3OpParam";
+
+    private static final String SCHEMA_NAME_4_14 = "ietf-network4@2014-00-08";
+    private static final String SCHEMA_NAME_4_15 = "ietf-network4@2015-00-08";
+    private static final String SCHEMA_NAME_4_16 = "ietf-network4@2016-00-08";
+    private static final String SCHEMA_NAME_4_17 = "ietf-network4@2017-00-08";
+    private static final String SCHEMA_NAME_4 = "ietf-network4";
+    private static final String SERVICE_NAME_REV_14 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20141208.IetfNetwork4Service";
+    private static final String INTERFACE_NAME_REV_14 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20141208.IetfNetwork4";
+    private static final String OP_PARAM_NAME_REV_14 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20141208.IetfNetwork4OpParam";
+
+    private static final String SERVICE_NAME_REV_15 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20151208.IetfNetwork4Service";
+    private static final String INTERFACE_NAME_REV_15 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20151208.IetfNetwork4";
+    private static final String OP_PARAM_NAME_REV_15 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20151208.IetfNetwork4OpParam";
+
+    private static final String SERVICE_NAME_REV_16 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20161208.IetfNetwork4Service";
+    private static final String INTERFACE_NAME_REV_16 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20161208.IetfNetwork4";
+    private static final String OP_PARAM_NAME_REV_16 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20161208.IetfNetwork4OpParam";
+
+    private static final String SERVICE_NAME_REV_17 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20171208.IetfNetwork4Service";
+    private static final String INTERFACE_NAME_REV_17 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20171208.IetfNetwork4";
+    private static final String OP_PARAM_NAME_REV_17 =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.rev20171208.IetfNetwork4OpParam";
+
+    private static final String SERVICE_NAME_NO_REV =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.IetfNetwork4Service";
+    private static final String INTERFACE_NAME_NO_REV =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.IetfNetwork4";
+    private static final String OP_PARAM_NAME_NO_REV =
+            "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
+                    ".network4.IetfNetwork4OpParam";
+
+    private static final String UN_REG_SCHEMA_NAME = "ietf-routing";
+    private static final String UN_REG_INTERFACE_NAME = "IetfRouting";
+    private static final String UN_REG_OP_PARAM_NAME = "IetfRoutingOpParam";
+    private static final String UN_REG_SERVICE_NAME = "IetfRoutingService";
+    private static final String CHECK = "check";
+    private static final String DATE_NAMESPACE = "2015-00-08";
+    private static final String NAMESPACE =
+            "urn:ietf:params:xml:ns:yang:ietf-network4:check:namespace";
+
+    private final TestYangSchemaNodeProvider provider =
+            new TestYangSchemaNodeProvider();
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Unit test case in which schema node should be present.
+     *
+     * @throws IOException when fails to do IO operation
+     */
+    @Test
+    public void testForGetSchemaNode()
+            throws IOException {
+
+        provider.processSchemaRegistry();
+
+        DefaultYangModelRegistry registry = provider.registry();
+
+        YangSchemaNode yangNode = registry.getForSchemaName(SCHEMA_NAME_3);
+        assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_3);
+        assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_3);
+        assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
+
+//        provider.unregisterService(SERVICE_NAME_3);
+        //TODO: fix unregister UT.
+//
+//        yangNode = registry.getForAppName(SERVICE_NAME_3);
+//        assertThat(true, is(yangNode == null));
+//
+//        yangNode = registry.getForSchemaName(SCHEMA_NAME_3);
+//        assertThat(true, is(yangNode == null));
+//
+//        yangNode =
+//                registry.getForInterfaceFileName(
+//                        INTERFACE_NAME_3);
+//        assertThat(true, is(yangNode == null));
+//
+//        yangNode =
+//                registry.getForOpPramFileName(
+//                        OP_PARAM_NAME_3);
+//        assertThat(true, is(yangNode == null));
+    }
+
+    /**
+     * Unit test case in which schema node should be present with multi
+     * revisions.
+     *
+     * @throws IOException when fails to do IO operation
+     */
+    @Test
+    public void testForGetSchemaNodeWhenNoRevision()
+            throws IOException {
+
+        provider.processSchemaRegistry();
+        DefaultYangModelRegistry registry =
+                provider.registry();
+
+        //Service with rev.
+        YangSchemaNode yangNode = registry.getForSchemaName(SCHEMA_NAME_4_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_REV_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_REV_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //       provider.unregisterService(SERVICE_NAME_REV_15);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_15);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which does not have revision.
+        
+        // asset should pass with false.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(((YangNode) yangNode).getRevision() == null));
+
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_NO_REV);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_NO_REV);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //provider.unregisterService(SERVICE_NAME_NO_REV);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_NO_REV);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which have different revision.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(yangNode != null));
+        //TODO: ureg.
+//        assertThat(true, is(((YangNode) yangNode).getRevision() != null));
+    }
+
+    /**
+     * Unit test case in which schema node should be present with multi
+     * revisions.
+     *
+     * @throws IOException when fails to do IO operation
+     */
+    //TODO: add unreg in UT
+    public void testForGetSchemaNodeWhenMultiRevision()
+            throws IOException {
+
+        provider.processSchemaRegistry();
+        DefaultYangModelRegistry registry =
+                provider.registry();
+
+        //Service with rev.
+        YangSchemaNode yangNode = registry.getForSchemaName(SCHEMA_NAME_4_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_REV_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_REV_15);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //As we have not registered an  application this object should be null.
+        Object object = registry.getRegisteredClass(yangNode);
+        assertThat(true, is(object == null));
+//        provider.unregisterService(SERVICE_NAME_REV_15);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_15);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which does not have revision.
+        // asset should pass with false.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(((YangNode) yangNode).getRevision() == null));
+
+        //Service with different revision.
+        yangNode = registry
+                .getForAppName(SERVICE_NAME_REV_16);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4_16);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_REV_16);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_REV_16);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //As we have not registered an  application this object should be null.
+        object = registry.getRegisteredClass(yangNode);
+        assertThat(true, is(object == null));
+//        provider.unregisterService(SERVICE_NAME_REV_16);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_16);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which have different revision.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(((YangNode) yangNode).getRevision() == null));
+
+        //Service with different revision.
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_17);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4_17);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_REV_17);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_REV_17);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //As we have not registered an  application this object should be null.
+        object = registry.getRegisteredClass(yangNode);
+        assertThat(true, is(object == null));
+//        provider.unregisterService(SERVICE_NAME_REV_17);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_17);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which have different revision.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(((YangNode) yangNode).getRevision() == null));
+
+        //Service no revision.
+        yangNode = registry.getForAppName(SERVICE_NAME_NO_REV);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_NO_REV);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_NO_REV);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //As we have not registered an  application this object should be null.
+        object = registry.getRegisteredClass(yangNode);
+        assertThat(true, is(object == null));
+        //       provider.unregisterService(SERVICE_NAME_NO_REV);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_NO_REV);
+        assertThat(true, is(yangNode == null));
+
+        //Here the yangNode should be the node which have different revision.
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
+        assertThat(true, is(yangNode != null));
+        assertThat(true, is(((YangNode) yangNode).getRevision() != null));
+
+        //Service with different revision.
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_14);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode = registry.getForSchemaName(SCHEMA_NAME_4_14);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForInterfaceFileName(
+                        INTERFACE_NAME_REV_14);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        yangNode =
+                registry.getForOpPramFileName(
+                        OP_PARAM_NAME_REV_14);
+        assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
+
+        //As we have not registered an  application this object should be null.
+        object = registry.getRegisteredClass(yangNode);
+        assertThat(true, is(object == null));
+//        provider.unregisterService(SERVICE_NAME_REV_14);
+
+        yangNode = registry.getForAppName(SERVICE_NAME_REV_14);
+        assertThat(true, is(yangNode == null));
+    }
+
+    /**
+     * get schema for namespace in decode test.
+     */
+    @Test
+    public void testGetNodeWrtNamespace() {
+        provider.processSchemaRegistry();
+        DefaultYangModelRegistry registry = provider.registry();
+
+        YangSchemaNode yangNode = registry.getForNameSpace(NAMESPACE);
+        assertThat(true, is(CHECK.equals(yangNode.getName())));
+
+        YangRevision rev = ((YangNode) yangNode).getRevision();
+        assertThat(true, is(rev != null));
+
+        String date = getDateInStringFormat((YangNode) yangNode);
+        assertThat(true, is(DATE_NAMESPACE.equals(date)));
+    }
+}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestYangSchemaNodeProvider.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestYangSchemaNodeProvider.java
new file mode 100644
index 0000000..a42f2fb
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestYangSchemaNodeProvider.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.runtime.api.AppModuleInfo;
+import org.onosproject.yang.runtime.api.ModelRegistrationParam;
+import org.onosproject.yang.runtime.api.YangModelRegistry;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.deSerializeDataModel;
+import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.processModuleId;
+import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.processYangModel;
+import static org.onosproject.yang.compiler.utils.UtilConstants.TEMP;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.deleteDirectory;
+import static org.onosproject.yang.runtime.utils.RuntimeHelper.getInterfaceClassName;
+
+/**
+ * Represents mock bundle context. provides bundle context for YSR to do unit
+ * testing.
+ * //TODO: add unreg ut.
+ */
+public class TestYangSchemaNodeProvider {
+
+    private static final String FS = File.separator;
+    private static final String PATH = System.getProperty("user.dir") +
+            FS + "target" + FS + "classes" + FS;
+    private static final String SER_FILE_PATH = "yang" + FS + "resources" +
+            FS + "YangMetaData.ser";
+    private static final String META_PATH = PATH + SER_FILE_PATH;
+    private static final String TEMP_FOLDER_PATH = PATH + TEMP;
+    private YangModelRegistry reg = new DefaultYangModelRegistry();
+    private List<YangNode> nodes = new ArrayList<>();
+
+    /**
+     * Creates an instance of mock bundle context.
+     */
+    public TestYangSchemaNodeProvider() {
+    }
+
+    /**
+     * Process YANG schema node for a application.
+     */
+    public void processSchemaRegistry() {
+        try {
+            //Need to deserialize generated meta data file for unit tests.
+            Set<YangNode> appNode = deSerializeDataModel(META_PATH);
+            nodes.addAll(appNode);
+
+            //Process loading class file.
+            String appName;
+            ClassLoader classLoader = TestYangSchemaNodeProvider.class.getClassLoader();
+            for (YangSchemaNode node : nodes) {
+
+                //If service class is not generated then use
+                // interface file to load this class.
+                appName = getInterfaceClassName(node);
+                Class<?> cls;
+                try {
+                    cls = classLoader.loadClass(appName);
+                } catch (ClassNotFoundException e) {
+                    continue;
+                }
+
+                //Create model registration param.
+                ModelRegistrationParam param = new
+                        DefaultModelRegistrationParam();
+
+                //create a new YANG model
+                YangModel model = processYangModel(META_PATH, nodes);
+                //set YANG model
+                param.setYangModel(model);
+                //generate app info.
+                AppModuleInfo info = new DefaultAppModuleInfo();
+                info.setModuleClass(cls);
+                param.addAppModuleInfo(processModuleId((YangNode) node), info);
+                reg.registerModel(param);
+            }
+            deleteDirectory(TEMP_FOLDER_PATH);
+        } catch (IOException e) {
+        }
+    }
+
+    /**
+     * Returns schema registry.
+     *
+     * @return schema registry
+     */
+    public DefaultYangModelRegistry registry() {
+        return (DefaultYangModelRegistry) reg;
+    }
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang b/runtime/app/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang
new file mode 100644
index 0000000..7e5726e
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang
@@ -0,0 +1,80 @@
+   module check {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4:check:namespace";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2015-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+         container networks {
+             leaf id {
+                 type int32;
+             }
+             container network {
+                  leaf ip-address {
+                      type int32;
+                  }
+             }
+         }
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
new file mode 100644
index 0000000..a537824
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
@@ -0,0 +1,71 @@
+   module ietf-network4 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+         container networks {
+             leaf id {
+                 type int32;
+             }
+             container network {
+                  leaf ip-address {
+                      type int32;
+                  }
+             }
+         }
+
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
new file mode 100644
index 0000000..b181f36
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
@@ -0,0 +1,81 @@
+   module ietf-network4 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2015-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+         container networks {
+             leaf id {
+                 type int32;
+             }
+             container network {
+                  leaf ip-address {
+                      type int32;
+                  }
+             }
+         }
+
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
new file mode 100644
index 0000000..29d5485
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
@@ -0,0 +1,80 @@
+   module ietf-network4 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2016-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+         container networks {
+             leaf id {
+                 type int32;
+             }
+             container network {
+                  leaf ip-address {
+                      type int32;
+                  }
+             }
+         }
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
new file mode 100644
index 0000000..c8a2a0a
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
@@ -0,0 +1,81 @@
+   module ietf-network4 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2014-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+         container networks {
+             leaf id {
+                 type int32;
+             }
+             container network {
+                  leaf ip-address {
+                      type int32;
+                  }
+             }
+         }
+
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
new file mode 100644
index 0000000..9352fb4
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
@@ -0,0 +1,76 @@
+   module ietf-network4 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2017-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+     container network {
+          leaf ip {
+             type int32;
+          }
+     }
+
+}
diff --git a/runtime/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang b/runtime/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
new file mode 100644
index 0000000..0e86062
--- /dev/null
+++ b/runtime/app/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
@@ -0,0 +1,81 @@
+   module ietf-network3 {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network3";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2015-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+     container networks {
+         leaf id {
+            type int32;
+         }
+         container network {
+              leaf ip-address {
+                  type int32;
+              }
+         }
+     }
+
+}
diff --git a/runtime/pom.xml b/runtime/pom.xml
index b287993..6760614 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -29,6 +29,7 @@
 
     <modules>
         <module>api</module>
+        <module>app</module>
         <module>utils</module>
     </modules>
 
diff --git a/runtime/utils/pom.xml b/runtime/utils/pom.xml
index 80ff720..336bd44 100644
--- a/runtime/utils/pom.xml
+++ b/runtime/utils/pom.xml
@@ -10,6 +10,16 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-yang-runtime</artifactId>
+        <version>1.12-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-yang-runtime-uils</artifactId>
+    <packaging>jar</packaging>
+
     <dependencies>
         <dependency>
             <groupId>org.onosproject</groupId>
@@ -18,20 +28,20 @@
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-api</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
             <artifactId>onos-yang-runtime-api</artifactId>
             <version>1.12-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-compiler-plugin-utils</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
     </dependencies>
-
-    <parent>
-        <groupId>org.onosproject</groupId>
-        <artifactId>onos-yang-runtime</artifactId>
-        <version>1.12-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>onos-yang-runtime-utils</artifactId>
-    <packaging>jar</packaging>
-
     <build>
         <plugins>
             <plugin>
diff --git a/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/RuntimeHelper.java b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/RuntimeHelper.java
new file mode 100644
index 0000000..d30b337
--- /dev/null
+++ b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/RuntimeHelper.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.utils;
+
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.YangModule;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.getYangModel;
+import static org.onosproject.yang.compiler.utils.UtilConstants.OP_PARAM;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
+
+/**
+ * Represents utility for runtime. These utilities can be used by application
+ * to get YANG model for their application and also it can be used by runtime
+ * to get the YANG node for given YANG model.
+ */
+public final class RuntimeHelper {
+
+    /**
+     * Returns YANG model for given generated class.
+     *
+     * @param aClass generated class for module node
+     * @return YANG model
+     */
+    public static YangModel getModel(Class<?> aClass) {
+        return getYangModel(aClass);
+    }
+
+    /**
+     * Returns YANG node for given YANG model.
+     *
+     * @param model YANG model
+     * @return YANG node for given model
+     */
+    public static Set<YangNode> getNodes(YangModel model) {
+        Set<YangNode> nodes = new HashSet<>();
+        Iterator<YangModule> it = model.getYangModules().iterator();
+        YangModule module;
+        InputStream is;
+        if (it.hasNext()) {
+            module = it.next();
+            is = module.getMetadata();
+            ObjectInputStream os;
+            try {
+                os = new ObjectInputStream(is);
+                nodes.addAll((Set<YangNode>) os.readObject());
+                os.close();
+                is.close();
+            } catch (IOException | ClassNotFoundException e) {
+                throw new RuntimeException("failed to deserialize model" + e
+                        .getLocalizedMessage());
+            }
+        }
+        return nodes;
+    }
+
+
+    /**
+     * Returns schema node's generated interface class name.
+     *
+     * @param schemaNode schema node
+     * @return schema node's generated interface class name
+     */
+    public static String getInterfaceClassName(YangSchemaNode schemaNode) {
+        return schemaNode.getJavaPackage() + PERIOD +
+                getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
+    }
+
+    /**
+     * Returns schema node's generated op param class name.
+     *
+     * @param schemaNode schema node
+     * @return schema node's generated op param class name
+     */
+    public static String getOpParamClassName(YangSchemaNode schemaNode) {
+        return getInterfaceClassName(schemaNode) + OP_PARAM;
+    }
+
+    /**
+     * Returns schema node's generated service class name.
+     *
+     * @param schemaNode schema node
+     * @return schema node's generated service class name
+     */
+    public static String getServiceName(YangSchemaNode schemaNode) {
+        return getInterfaceClassName(schemaNode) + SERVICE;
+    }
+}