f43877822a4ff00ed358e3088bb3c517735717e6
[iot2.git] / iotjava / iotrmi / Java / sample / CallBack_CBStub.java
1 package iotrmi.Java.sample;
2
3 import java.io.IOException;
4 import iotrmi.Java.IoTRMICall;
5
6 public class CallBack_CBStub implements CallBackInterface {
7
8         /**
9          * Class Properties
10          */
11         private IoTRMICall rmiCall;
12
13         private int objectId = 0;       // Default value is 0
14
15         /**
16          * Constructors
17          */
18         public CallBack_CBStub(IoTRMICall _rmiCall, int _objectId) throws IOException {
19
20                 objectId = _objectId;
21                 rmiCall = _rmiCall;
22         }
23
24
25         public int printInt() {
26
27                 int methodId = 0;
28                 Class<?> retType = int.class;
29                 Class<?>[] paramCls = new Class<?>[] { };
30                 Object[] paramObj = new Object[] { };
31                 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
32                 return (int)retObj;
33         }
34
35
36         public void setInt(int _i) {
37
38                 int methodId = 1;
39                 Class<?> retType = void.class;
40                 Class<?>[] paramCls = new Class<?>[] { int.class };
41                 Object[] paramObj = new Object[] { _i };
42                 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
43         }
44
45
46         public static void main(String[] args) throws Exception {
47
48                 int port = 5010;
49                 String address = "localhost";
50                 int rev = 0;
51
52                 CallBack_Stub cbstub = new CallBack_Stub(port, address, rev);
53                 cbstub.setInt(23);
54                 cbstub.printInt();
55         }
56 }