private void writePropertiesJavaCallbackStub(String intface, String newIntface, boolean callbackExist, Set<String> callbackClasses) {
println("private IoTRMICall rmiCall;");
+ println("private String address;");
+ println("private int[] ports;\n");
// Get the object Id
println("private static int objectId = 0;");
if (callbackExist) {
*/
private void writeConstructorJavaCallbackStub(String intface, boolean callbackExist, Set<String> callbackClasses) {
+ // TODO: If we want callback in callback, then we need to add address and port initializations
println("public " + intface + "(IoTRMICall _rmiCall, int _objectId) throws Exception {");
println("objectId = _objectId;");
println("rmiCall = _rmiCall;");
String callbackType = (String) it.next();
println("listCallbackObj = new ArrayList<" + callbackType + ">();");
println("___initCallBack();");
+ println("// TODO: Add address and port initialization here if we want callback in callback!");
}
println("}\n");
}
/**
* HELPER: writeInitCallbackJavaSkeleton() writes the init callback method for skeleton class
*/
- private void writeInitCallbackJavaSkeleton() {
+ private void writeInitCallbackJavaSkeleton(boolean callbackSkeleton) {
- println("public void ___regCB() throws IOException {");
+ // This is a callback skeleton generation
+ if (callbackSkeleton)
+ println("public void ___regCB(IoTRMIObject rmiObj) throws IOException {");
+ else
+ println("public void ___regCB() throws IOException {");
println("Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class, String.class, int.class },");
println("\tnew Class<?>[] { null, null, null });");
println("rmiCall = new IoTRMICall((int) paramObj[0], (String) paramObj[1], (int) paramObj[2]);");
/**
* HELPER: writeMethodJavaSkeleton() writes the method of the skeleton class
*/
- private void writeMethodJavaSkeleton(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses) {
+ private void writeMethodJavaSkeleton(Collection<String> methods, InterfaceDecl intDecl, Set<String> callbackClasses,
+ boolean callbackSkeleton) {
for (String method : methods) {
writeStdMethodBodyJavaSkeleton(methParams, methodId, intDecl.getMethodType(method));
println("}\n");
if (isCallbackMethod)
- writeInitCallbackJavaSkeleton();
+ writeInitCallbackJavaSkeleton(callbackSkeleton);
}
}
// Write constructor
writeConstructorJavaSkeleton(newSkelClass, intface);
// Write methods
- writeMethodJavaSkeleton(methods, intDecl, callbackClasses);
+ writeMethodJavaSkeleton(methods, intDecl, callbackClasses, false);
// Write method helper
writeMethodHelperJavaSkeleton(methods, intDecl, callbackClasses);
// Write waitRequestInvokeMethod() - main loop
// Print case -9999 (callback handler) if callback exists
if (callbackExist) {
int methodId = intDecl.getHelperMethodNumId(method);
- println("case " + methodId + ": ___regCB(); break;");
+ println("case " + methodId + ": ___regCB(rmiObj); break;");
}
println("default: ");
println("throw new Error(\"Method Id \" + methodId + \" not recognized!\");");
// Write constructor
writeConstructorJavaCallbackSkeleton(newSkelClass, intface);
// Write methods
- writeMethodJavaSkeleton(methods, intDecl, callbackClasses);
+ writeMethodJavaSkeleton(methods, intDecl, callbackClasses, true);
// Write method helper
writeMethodHelperJavaCallbackSkeleton(methods, intDecl, callbackClasses);
// Write waitRequestInvokeMethod() - main loop