1 package SpeakerController;
3 import java.io.IOException;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import iotrmi.Java.IoTRMICall;
8 import iotrmi.Java.IoTRMIObject;
10 import iotcode.interfaces.*;
12 public class GPSGatewaySmart_Stub implements GPSGatewaySmart {
14 private IoTRMICall rmiCall;
15 private String callbackAddress;
18 private final static int objectId = 0;
19 // Callback properties
20 private IoTRMIObject rmiObj;
21 List<GPSGatewayCallback> listCallbackObj;
22 private int objIdCnt = 0;
23 private final static int object0Id = 0; //GPSGatewaySmartCallback
24 private static Integer[] object0Permission = { 0, 1 };
25 private static List<Integer> set0Allowed;
28 public GPSGatewaySmart_Stub(int _port, String _skeletonAddress, String _callbackAddress, int _rev, int[] _ports) throws Exception {
29 callbackAddress = _callbackAddress;
31 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev);
32 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
33 listCallbackObj = new ArrayList<GPSGatewayCallback>();
34 set0Allowed.add(-9999);
38 public void setNewRoomIDAvailable(boolean bValue) {
40 Class<?> retType = void.class;
41 Class<?>[] paramCls = new Class<?>[] { boolean.class };
42 Object[] paramObj = new Object[] { bValue };
43 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
46 public void setNewRingStatusAvailable(boolean bValue) {
48 Class<?> retType = void.class;
49 Class<?>[] paramCls = new Class<?>[] { boolean.class };
50 Object[] paramObj = new Object[] { bValue };
51 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
56 Class<?> retType = void.class;
57 Class<?>[] paramCls = new Class<?>[] { };
58 Object[] paramObj = new Object[] { };
59 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
64 Class<?> retType = void.class;
65 Class<?>[] paramCls = new Class<?>[] { };
66 Object[] paramObj = new Object[] { };
67 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
72 Class<?> retType = void.class;
73 Class<?>[] paramCls = new Class<?>[] { };
74 Object[] paramObj = new Object[] { };
75 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
78 public int getRoomID() {
80 Class<?> retType = int.class;
81 Class<?>[] paramCls = new Class<?>[] { };
82 Object[] paramObj = new Object[] { };
83 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
87 public void registerCallback(GPSGatewayCallback _callbackTo) {
89 GPSGatewayCallback_CallbackSkeleton skel0 = new GPSGatewayCallback_CallbackSkeleton(_callbackTo, callbackAddress, objIdCnt++);
90 listCallbackObj.add(skel0);
91 } catch (Exception ex) {
93 throw new Error("Exception when generating skeleton objects!");
97 Class<?> retType = void.class;
98 Class<?>[] paramCls = new Class<?>[] { int.class };
99 Object[] paramObj = new Object[] { new Integer(1) };
100 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
103 public void ___initCallBack() {
104 Thread thread = new Thread() {
107 rmiObj = new IoTRMIObject(ports[0]);
109 byte[] method = rmiObj.getMethodBytes();
110 int objId = IoTRMIObject.getObjectId(method);
111 GPSGatewayCallback_CallbackSkeleton skel = (GPSGatewayCallback_CallbackSkeleton) listCallbackObj.get(objId);
113 int methodId = IoTRMIObject.getMethodId(method);
114 if (!set0Allowed.contains(methodId)) {
115 throw new Error("Callback object for GPSGatewayCallback is not allowed to access method: " + methodId);
117 skel.invokeMethod(rmiObj);
119 throw new Error("GPSGatewayCallback: Object with Id " + objId + " not found!");
122 } catch (Exception ex) {
123 ex.printStackTrace();
124 throw new Error("Error instantiating class GPSGatewayCallback_CallbackSkeleton!");
130 int methodId = -9998;
131 Class<?> retType = void.class;
132 Class<?>[] paramCls = new Class<?>[] { int[].class, String.class, int.class };
133 Object[] paramObj = new Object[] { ports, callbackAddress, 0 };
134 rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
137 public boolean getRingStatus() {
139 Class<?> retType = boolean.class;
140 Class<?>[] paramCls = new Class<?>[] { };
141 Object[] paramObj = new Object[] { };
142 Object retObj = rmiCall.remoteCall(objectId, methodId, retType, null, paramCls, paramObj);
143 return (boolean)retObj;