Adjusting and cleaning up ZigbeeTest to install Vigilia ZigBee gateway and devices.
[iot2.git] / iotjava / iotrmi / Java / sample / CallBack_Skeleton.java
index 8c587f8c07c94006382cb998dc494983d264d08e..77a3c815f452fb9d5aabb4a4b393789fea45bc75 100644 (file)
@@ -8,11 +8,6 @@ import iotrmi.Java.IoTRMIObject;
 public class CallBack_Skeleton implements CallBackInterface {
 
        private int objectId = 0;       // Default value is 0
-       private final static String[] methodSignatures = {
-
-               "intprintInt()",
-               "voidsetInt(int)"
-       };
        private CallBackInterface cb;
        private IoTRMIObject rmiObj;
 
@@ -26,7 +21,7 @@ public class CallBack_Skeleton implements CallBackInterface {
 
                cb = _cb;
                System.out.println("Creating CallBack_Skeleton and waiting!");
-               rmiObj = new IoTRMIObject(_port, methodSignatures);
+               rmiObj = new IoTRMIObject(_port);
                ___waitRequestInvokeMethod();
        }
 
@@ -36,8 +31,9 @@ public class CallBack_Skeleton implements CallBackInterface {
        }
        
        
-       public int ___printInt() {
-               return printInt();
+       public void ___printInt() throws IOException {
+               Object retObj = printInt();
+               rmiObj.sendReturnObj(retObj);
        }
 
 
@@ -48,7 +44,7 @@ public class CallBack_Skeleton implements CallBackInterface {
        
        public void ___setInt() {
                Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-                       new Class<?>[] { null }, new Class<?>[] { null });
+                       new Class<?>[] { null });
                setInt((int) paramObj[0]);
        }
        
@@ -63,35 +59,19 @@ public class CallBack_Skeleton implements CallBackInterface {
                        if (objId == objectId) {
                        // Multiplex based on object Id
                                rmiObj.getMethodBytes();
-                               String methodSign = rmiObj.getSignature();
-                               Object[] paramObj = null;
-                               Object retObj = null;
-                               System.out.println("Method sign: " + methodSign);
-
-                               if (methodSign.equals("intprintInt()")) {
-                                       retObj = ___printInt();
-                               } else if (methodSign.equals("voidsetInt(int)")) {
-                                       ___setInt();
-                               } else
-                                       throw new Error("Signature not recognized!");
-                               System.out.println("Return object: " + retObj);
-
-                               if (retObj != null) {
-                                       rmiObj.sendReturnObj(retObj);
+                               int methodId = rmiObj.getMethodId();
+
+                               switch (methodId) {
+                                       case 0: ___printInt(); break;
+                                       case 1: ___setInt(); break;
+                                       default:
+                                               throw new Error("Method Id not recognized!");
                                }
-                               System.out.println("Servicing remote call for method: " + methodSign);
                        }
                }
        }
 
 
-       // Return method signatures
-       public static String[] getMethodSignatures() {
-
-               return methodSignatures;
-       }
-
-
        public static void main(String[] args) throws Exception {
 
                int port = 5010;