Model registration dependecies resolved and model converter added.
Change-Id: Ie828741bfc87d530cb3e0af7a46b5ce4107c3b21
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 2ffc01f..56e61ed 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>RELEASE</version>
+ <version>5.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -86,8 +86,13 @@
<instructions>
<Export-Package>
org.onosproject.yang.runtime.*,
- org.osgi.*,
- org.onosproject.yang.compiler.datamodel.*
+ org.onosproject.yang.compiler.datamodel.*,
+ org.onosproject.yang.compiler.translator.*,
+ org.onosproject.yang.compiler.utils.*,
+ org.onosproject.yang.compiler.linker.*,
+ org.onosproject.yang.compiler.tool.*,
+ org.onosproject.yang.compiler.parser.*,
+ org.antlr.v4.*,
</Export-Package>
</instructions>
</configuration>
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
index 04823cf..521d266 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/helperutils/YangApacheUtils.java
@@ -45,17 +45,16 @@
*/
public final class YangApacheUtils {
- public static final String SLASH = File.separator;
- public static final String HYPHEN = "-";
- public static final String PERIOD = ".";
- public static final String YANG_META_DATA = "YangMetaData.ser";
- public static final String YANG_RESOURCES = "yang/resources";
+ private static final String SLASH = File.separator;
+ private static final String HYPHEN = "-";
+ private static final String PERIOD = ".";
+ private static final String YANG_META_DATA = "YangMetaData.ser";
+ private static final String YANG_RESOURCES = "yang/resources";
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);
// Forbid construction.
@@ -71,25 +70,17 @@
public static YangModel getYangModel(Class<?> modClass) {
BundleContext context = getBundle(modClass).getBundleContext();
if (context != null) {
- Bundle[] bundles = context.getBundles();
- Bundle bundle;
- int len = bundles.length;
+ Bundle bundle = context.getBundle();
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);
- }
- }
+ 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;
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultModelConverter.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultModelConverter.java
new file mode 100644
index 0000000..7c2faf8
--- /dev/null
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultModelConverter.java
@@ -0,0 +1,50 @@
+/*
+ * 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.impl;
+
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ModelObjectData;
+import org.onosproject.yang.model.ResourceData;
+
+/**
+ * Represents implementation of default model converter.
+ */
+public class DefaultModelConverter implements ModelConverter {
+
+ private final DefaultYangModelRegistry reg;
+
+ /**
+ * Creates an instance of default model converter.
+ *
+ * @param registry default YANG model registry
+ */
+ public DefaultModelConverter(DefaultYangModelRegistry registry) {
+ reg = registry;
+ }
+
+ @Override
+ public ModelObjectData createModel(ResourceData data) {
+ //TODO: add implementation.
+ return null;
+ }
+
+ @Override
+ public ResourceData createDataNode(ModelObjectData modelData) {
+ //TODO: add implementation.
+ return null;
+ }
+}