Adding enum support for method argument; need to emulate the same functionality for...
[iot2.git] / iotjava / iotrmi / Java / sample / CallBack_CBSkeleton.java
index c038ec7e4a7df6dafe1e713026c06181fdd7fa59..0e01eba2619aac8d3f2a37f9c9be46a90324fd6b 100644 (file)
@@ -28,24 +28,40 @@ public class CallBack_CBSkeleton implements CallBackInterface {
                System.out.println("Creating CallBack_Skeleton and waiting!");
        }
 
+       
+       public int printInt() {
+               return cb.printInt();
+       }
+       
+       
+       public void ___printInt(IoTRMIObject rmiObj) throws IOException {
+               Object retObj = printInt();
+               rmiObj.sendReturnObj(retObj);
+       }
+
 
-       public Object invokeMethod(IoTRMIObject rmiObj) throws IOException {
+       public void setInt(int _i) {
+               cb.setInt(_i);
+       }
+       
+       
+       public void ___setInt(IoTRMIObject rmiObj) {
+               Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
+                       new Class<?>[] { null });
+               setInt((int) paramObj[0]);
+       }
+       
 
-               String methodSign = rmiObj.getSignature();
-               Object[] paramObj = null;
-               Object retObj = null;
+       public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
 
-               if (methodSign.equals("intprintInt()")) {
-                       retObj = printInt();
-               } else if (methodSign.equals("voidsetInt(int)")) {
-                       paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
-                               new Class<?>[] { null }, new Class<?>[] { null });
-                       setInt((int) paramObj[0]);
-               } else
-                       throw new Error("Signature not recognized!");
-               System.out.println("Return object: " + retObj);
+               int methodId = rmiObj.getMethodId();
 
-               return retObj;
+               switch (methodId) {
+                       case 0: ___printInt(rmiObj); break;
+                       case 1: ___setInt(rmiObj); break;
+                       default: 
+                               throw new Error("Method Id not recognized!");
+               }
        }
 
 
@@ -56,21 +72,7 @@ public class CallBack_CBSkeleton implements CallBackInterface {
        }
 
 
-       public int printInt() {
-               return cb.printInt();
-       }
-
-
-       public void setInt(int _i) {
-               cb.setInt(_i);
-       }
-
-
        public static void main(String[] args) throws Exception {
 
-               int port = 5010;
-               CallBack cb = new CallBack(23);
-               CallBack_Skeleton cbSkel = new CallBack_Skeleton(cb, port);
-               cbSkel.waitRequestInvokeMethod();
        }
 }