1 package iotrmi.Java.sample;
3 import java.io.IOException;
5 import java.util.Arrays;
6 import iotrmi.Java.IoTRMIObject;
8 public class CallBack_Skeleton {
10 private String[] methodSignatures = {
16 private CallBackInterface cb;
17 private IoTRMIObject rmiObj;
23 public CallBack_Skeleton(CallBackInterface _cb, int _port) throws
24 ClassNotFoundException, InstantiationException,
25 IllegalAccessException, IOException {
28 System.out.println("Creating CallBack_Skeleton and waiting!");
29 rmiObj = new IoTRMIObject(_port, methodSignatures);
33 public void waitRequestInvokeMethod() throws IOException {
35 // Loop continuously waiting for incoming bytes
38 rmiObj.getMethodBytes();
39 String methodSign = rmiObj.getSignature();
40 Object[] paramObj = null;
42 System.out.println("Method sign: " + methodSign);
44 if (methodSign.equals("intprintInt()")) {
45 //paramObj = rmiObj.getMethodParams(new Class<?>[] { },
46 // new Class<?>[] { null }, new Class<?>[] { null });
47 retObj = cb.printInt();
48 } else if (methodSign.equals("voidsetInt(int)")) {
49 paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
50 new Class<?>[] { null }, new Class<?>[] { null });
51 cb.setInt((int) paramObj[0]);
53 throw new Error("Signature un-recognized!");
54 System.out.println("Return object: " + retObj);
57 rmiObj.sendReturnObj(retObj);
59 System.out.println("Servicing remote call for method: " + methodSign);
64 public static void main(String[] args) throws Exception {
67 CallBack cb = new CallBack(23);
68 CallBack_Skeleton cbSkel = new CallBack_Skeleton(cb, port);
69 cbSkel.waitRequestInvokeMethod();