fea29b13b725a946307d73a713f5b906c87b685b
[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         private String address;
13
14         private int objectId = 0;       // Default value is 0
15         private final static String[] methodSignatures = {
16
17                 "intprintInt()",
18                 "voidsetInt(int)"
19         };
20
21         /**
22          * Constructors
23          */
24         public CallBack_CBStub(IoTRMICall _rmiCall, int _objectId, String _address) throws IOException {
25
26                 address = _address;
27                 objectId = _objectId;
28                 rmiCall = _rmiCall;
29         }
30
31
32         // Return method signatures
33         public static String[] getMethodSignatures() {
34
35                 return methodSignatures;
36         }
37
38
39         public int printInt() {
40
41                 String sign = "intprintInt()";
42                 Class<?> retType = int.class;
43                 Class<?>[] paramCls = new Class<?>[] { };
44                 Object[] paramObj = new Object[] { };
45                 Object retObj = rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
46                 return (int)retObj;
47         }
48
49
50         public void setInt(int _i) {
51
52                 String sign = "voidsetInt(int)";
53                 Class<?> retType = void.class;
54                 Class<?>[] paramCls = new Class<?>[] { int.class };
55                 Object[] paramObj = new Object[] { _i };
56                 rmiCall.remoteCall(objectId, sign, retType, null, null, paramCls, paramObj);
57         }
58
59
60         public static void main(String[] args) throws Exception {
61
62                 int port = 5010;
63                 String address = "localhost";
64                 int rev = 0;
65
66                 CallBack_Stub cbstub = new CallBack_Stub(port, address, rev);
67                 cbstub.setInt(23);
68                 cbstub.printInt();
69         }
70 }