Adding enum support for method argument; need to emulate the same functionality for...
[iot2.git] / iotjava / iotrmi / Java / sample / CallBack_CBSkeleton.java
1 package iotrmi.Java.sample;
2
3 import java.io.IOException;
4 import java.util.Set;
5 import java.util.Arrays;
6 import iotrmi.Java.IoTRMIObject;
7
8 public class CallBack_CBSkeleton implements CallBackInterface {
9
10         private int objectId = 0;       // Default value is 0
11         private final static String[] methodSignatures = {
12
13                 "intprintInt()",
14                 "voidsetInt(int)"
15         };
16         private CallBackInterface cb;
17
18
19         /**
20          * Constructors
21          */
22         public CallBack_CBSkeleton(CallBackInterface _cb, int _objectId) throws
23                 ClassNotFoundException, InstantiationException,
24                         IllegalAccessException, IOException {
25
26                 cb = _cb;
27                 objectId = _objectId;
28                 System.out.println("Creating CallBack_Skeleton and waiting!");
29         }
30
31         
32         public int printInt() {
33                 return cb.printInt();
34         }
35         
36         
37         public void ___printInt(IoTRMIObject rmiObj) throws IOException {
38                 Object retObj = printInt();
39                 rmiObj.sendReturnObj(retObj);
40         }
41
42
43         public void setInt(int _i) {
44                 cb.setInt(_i);
45         }
46         
47         
48         public void ___setInt(IoTRMIObject rmiObj) {
49                 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class }, 
50                         new Class<?>[] { null });
51                 setInt((int) paramObj[0]);
52         }
53         
54
55         public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
56
57                 int methodId = rmiObj.getMethodId();
58
59                 switch (methodId) {
60                         case 0: ___printInt(rmiObj); break;
61                         case 1: ___setInt(rmiObj); break;
62                         default: 
63                                 throw new Error("Method Id not recognized!");
64                 }
65         }
66
67
68         // Return method signatures
69         public static String[] getMethodSignatures() {
70
71                 return methodSignatures;
72         }
73
74
75         public static void main(String[] args) throws Exception {
76
77         }
78 }