[ONOS-5793] YANG model and model registry definition

Change-Id: I7b7113e0018b687d328ee43c452b982d4f34c48b
diff --git a/runtime/api/pom.xml b/runtime/api/pom.xml
new file mode 100644
index 0000000..462eb3a
--- /dev/null
+++ b/runtime/api/pom.xml
@@ -0,0 +1,63 @@
+<!--
+  ~ 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-api</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-api</artifactId>
+            <version>1.12-SNAPSHOT</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/runtime/api/src/main/java/org/onosproject/yang/runtime/api/AppModuleInfo.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/AppModuleInfo.java
new file mode 100644
index 0000000..f75f119
--- /dev/null
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/AppModuleInfo.java
@@ -0,0 +1,58 @@
+/*
+ * 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.api;
+
+import java.util.List;
+
+/**
+ * Representation of an entity which defines additional information about the
+ * module required for the model registration.
+ */
+public interface AppModuleInfo {
+
+    /**
+     * Returns the module class which will be required by YANG runtime to
+     * obtain the class loader.
+     *
+     * @return module JAVA class
+     */
+    Class<?> getModuleClass();
+
+    /**
+     * Sets module class.
+     *
+     * @param moduleClass module class
+     */
+    void setModuleClass(Class<?> moduleClass);
+
+    /**
+     * Reference RFC 7895
+     * Retrieves the list of YANG feature names from this module that are
+     * supported by the server, regardless of whether they are
+     * defined in the module or any included submodule.
+     *
+     * @return list of YANG features
+     */
+    List<String> getFeatureList();
+
+    /**
+     * Adds supported feature.
+     *
+     * @param feature supported feature
+     */
+    void addFeature(String feature);
+}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/DataFormat.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/DataFormat.java
similarity index 88%
rename from runtime/src/main/java/org/onosproject/yang/runtime/DataFormat.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/DataFormat.java
index 3902362..1ba26fb 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/DataFormat.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/DataFormat.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 /**
  * Abstraction of configuration data-format descriptor.
diff --git a/runtime/api/src/main/java/org/onosproject/yang/runtime/api/ModelRegistrationParam.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/ModelRegistrationParam.java
new file mode 100644
index 0000000..c1d2bf5
--- /dev/null
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/ModelRegistrationParam.java
@@ -0,0 +1,58 @@
+/*
+ * 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.api;
+
+import org.onosproject.yang.YangModel;
+import org.onosproject.yang.YangModuleId;
+
+/**
+ * Representation of model registration parameters.
+ */
+public interface ModelRegistrationParam {
+
+    /**
+     * Returns YANG model.
+     *
+     * @return YANG model
+     */
+    YangModel getYangModel();
+
+    /**
+     * Sets YANG model.
+     *
+     * @param model YANG model
+     */
+    void setYangModel(YangModel model);
+
+    /**
+     * Returns extended app related information of a module/sub-module.
+     *
+     * @param id YANG module identifier
+     * @return application module information
+     */
+    AppModuleInfo getAppModuleInfo(YangModuleId id);
+
+    /**
+     * Adds application module information associated with module identifier.
+     * It's expected that application should provide information for all the
+     * YANG modules.
+     *
+     * @param id   YANG module identifier
+     * @param info application information associated with module identifier
+     */
+    void addAppModuleInfo(YangModuleId id, AppModuleInfo info);
+}
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/YangModelRegistry.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangModelRegistry.java
similarity index 68%
rename from runtime/src/main/java/org/onosproject/yang/runtime/YangModelRegistry.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangModelRegistry.java
index 6048c11..036c399 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/YangModelRegistry.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangModelRegistry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 import org.onosproject.yang.YangModel;
 
@@ -28,16 +28,18 @@
     /**
      * Registers a new model.
      *
-     * @param model model to be registered
+     * @param param parameters having model to be registered with additional
+     *              informations provided by app
      */
-    void registerModel(YangModel model);
+    void registerModel(ModelRegistrationParam param);
 
     /**
      * Unregisters the specified model.
      *
-     * @param model model to be unregistered
+     * @param param parameters having model to be registered with additional
+     *              informations provided by app
      */
-    void unregisterModel(YangModel model);
+    void unregisterModel(ModelRegistrationParam param);
 
     /**
      * Returns collection of all registered models.
@@ -45,5 +47,4 @@
      * @return collection of models
      */
     Set<YangModel> getModels();
-
 }
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/YangRuntimeService.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangRuntimeService.java
similarity index 94%
rename from runtime/src/main/java/org/onosproject/yang/runtime/YangRuntimeService.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangRuntimeService.java
index 4b9599a..745eaf5 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/YangRuntimeService.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangRuntimeService.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 import org.onosproject.yang.model.DataNode;
 
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializer.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializer.java
similarity index 95%
rename from runtime/src/main/java/org/onosproject/yang/runtime/YangSerializer.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializer.java
index e6cf197..3409d0b 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializer.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 import org.onosproject.yang.model.DataNode;
 
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerContext.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerContext.java
similarity index 88%
rename from runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerContext.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerContext.java
index e2b2cbf..dbc543e 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerContext.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 /**
  * Representation of a context for encoding and decoding YANG models via
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerRegistry.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerRegistry.java
similarity index 92%
rename from runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerRegistry.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerRegistry.java
index 13aae92..1d1b335 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/YangSerializerRegistry.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/YangSerializerRegistry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.onosproject.yang.runtime;
+package org.onosproject.yang.runtime.api;
 
 import java.util.Set;
 
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/package-info.java b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/package-info.java
similarity index 86%
rename from runtime/src/main/java/org/onosproject/yang/runtime/package-info.java
rename to runtime/api/src/main/java/org/onosproject/yang/runtime/api/package-info.java
index 6b8a685..5a0f954 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/package-info.java
+++ b/runtime/api/src/main/java/org/onosproject/yang/runtime/api/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016-present Open Networking Laboratory
+ * 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.
@@ -17,4 +17,4 @@
 /**
  * Set of facilities for processing and working with compiled YANG models.
  */
-package org.onosproject.yang.runtime;
\ No newline at end of file
+package org.onosproject.yang.runtime.api;
\ No newline at end of file
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 372f8bb..09d4b8b 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -25,15 +25,14 @@
     </parent>
 
     <artifactId>onos-yang-runtime</artifactId>
-    <packaging>jar</packaging>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>api</module>
+    </modules>
 
     <dependencies>
         <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-yang-model</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.4</version>
@@ -43,11 +42,6 @@
             <artifactId>slf4j-api</artifactId>
             <version>1.7.21</version>
         </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-yang-compiler-api</artifactId>
-            <version>1.12-SNAPSHOT</version>
-        </dependency>
     </dependencies>
 
     <build>