Merge "Fixing mutability for ResourceId."
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaServiceFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaServiceFragmentFiles.java
index fd99fb1..8818347 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaServiceFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaServiceFragmentFiles.java
@@ -39,8 +39,10 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
import static org.onosproject.yang.compiler.utils.UtilConstants.INPUT;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MODEL_OBJECT_PKG;
import static org.onosproject.yang.compiler.utils.UtilConstants.OUTPUT;
import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_INPUT_VAR_NAME;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.VOID;
import static org.onosproject.yang.compiler.utils.io.impl.FileSystemUtil.closeFile;
@@ -110,9 +112,21 @@
throws IOException {
addResolvedAugmentedDataNodeImports(curNode);
+ JavaQualifiedTypeInfoTranslator typeInfo =
+ new JavaQualifiedTypeInfoTranslator();
+ typeInfo.setClassInfo(RPC_SERVICE);
+ typeInfo.setPkgInfo(MODEL_OBJECT_PKG);
+ typeInfo.setForInterface(true);
+ ((JavaCodeGeneratorInfo) curNode)
+ .getTempJavaCodeFragmentFiles().getServiceTempFiles()
+ .getJavaImportData().addImportInfo(typeInfo,
+ getJavaClassName(SERVICE),
+ getJavaFileInfo().getPackage());
+
List<String> imports = ((JavaCodeGeneratorInfo) curNode)
.getTempJavaCodeFragmentFiles().getServiceTempFiles()
.getJavaImportData().getImports(true);
+
createPackage(curNode);
/*boolean notification = false;
if (curNode instanceof YangJavaModuleTranslator) {
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
index aa608b6..ada4c85 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -21,7 +21,6 @@
import org.onosproject.yang.compiler.datamodel.YangIdentity;
import org.onosproject.yang.compiler.datamodel.YangList;
import org.onosproject.yang.compiler.datamodel.YangNode;
-import org.onosproject.yang.compiler.datamodel.YangNotification;
import org.onosproject.yang.compiler.translator.exception.TranslatorException;
import org.onosproject.yang.compiler.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yang.compiler.translator.tojava.JavaFileInfoTranslator;
@@ -88,6 +87,7 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_COMMAND;
import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_EXTENDED_COMMAND;
import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_HANDLER;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SPACE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SUBJECT;
@@ -298,10 +298,12 @@
* @return definition
*/
private static String getRpcInterfaceDefinition(String yangName, YangNode curNode) {
- JavaExtendsListHolder holder = ((TempJavaCodeFragmentFilesContainer) curNode)
+ /*JavaExtendsListHolder holder = ((TempJavaCodeFragmentFilesContainer)
+ curNode)
.getTempJavaCodeFragmentFiles().getServiceTempFiles()
.getJavaExtendsListHolder();
- if (holder.getExtendsList() != null && !holder.getExtendsList().isEmpty()) {
+ if (holder.getExtendsList() != null && !holder.getExtendsList()
+ .isEmpty()) {
curNode = curNode.getChild();
while (curNode != null) {
if (curNode instanceof YangNotification) {
@@ -309,9 +311,10 @@
}
curNode = curNode.getNextSibling();
}
- }
+ }*/
if (yangName.matches(REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE)) {
- return getDefaultDefinition(INTERFACE, yangName, PUBLIC);
+ return getDefaultDefinitionWithExtends(INTERFACE, yangName,
+ PUBLIC, RPC_SERVICE);
}
String name = getSuffixedName(
yangName.substring(0, yangName.length() - 7), SERVICE);
diff --git a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
index c7ac66b..830b3c6 100644
--- a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
+++ b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
@@ -1937,6 +1937,7 @@
"DefaultModelObjectData";
public static final String STRING_JOINER_CLASS = "StringJoiner";
public static final String AUGMENTABLE = "Augmentable";
+ public static final String RPC_SERVICE = "RpcService";
// No instantiation.
private UtilConstants() {
diff --git a/model/src/main/java/org/onosproject/yang/model/RpcService.java b/model/src/main/java/org/onosproject/yang/model/RpcService.java
new file mode 100644
index 0000000..2f19b5f
--- /dev/null
+++ b/model/src/main/java/org/onosproject/yang/model/RpcService.java
@@ -0,0 +1,25 @@
+/*
+ * 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.model;
+
+/**
+ * Token representation of a YANG RPC end-point.
+ * <p>
+ * All generated RPC interfaces will extend this interface.
+ */
+public interface RpcService {
+}