1 package iotcode.GPSPhoneGateway;
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 GPSGateway_Skeleton implements GPSGateway {
14 private GPSGateway mainObj;
15 private IoTRMIObject rmiObj;
17 private String callbackAddress;
18 private int objIdCnt = 0;
19 private IoTRMICall rmiCall;
22 private final static int object0Id = 0; //GPSGatewaySmart
23 private static Integer[] object0Permission = { 5, 6, 2, 1, 0, 3, 7, 4 };
24 private static List<Integer> set0Allowed;
27 public GPSGateway_Skeleton(GPSGateway _mainObj, String _callbackAddress, int _port) throws Exception {
29 callbackAddress = _callbackAddress;
30 rmiObj = new IoTRMIObject(_port);
31 set0Allowed = new ArrayList<Integer>(Arrays.asList(object0Permission));
32 set0Allowed.add(-9998);
33 ___waitRequestInvokeMethod();
48 public int getRoomID() {
49 return mainObj.getRoomID();
52 public boolean getRingStatus() {
53 return mainObj.getRingStatus();
56 public void setNewRoomIDAvailable(boolean bValue) {
57 mainObj.setNewRoomIDAvailable(bValue);
60 public void setNewRingStatusAvailable(boolean bValue) {
61 mainObj.setNewRingStatusAvailable(bValue);
64 public void registerCallback(GPSGatewaySmartCallback _callbackTo) {
65 mainObj.registerCallback(_callbackTo);
68 public void ___regCB() throws IOException {
69 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int[].class, String.class, int.class },new Class<?>[] { null, null, null });
70 ports = (int[]) paramObj[0];
71 rmiCall = new IoTRMICall(ports[0], (String) paramObj[1], (int) paramObj[2]);
74 public void ___init() {
75 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
80 public void ___start() {
81 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
86 public void ___stop() {
87 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
92 public void ___getRoomID() throws IOException {
93 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
95 Object retObj = getRoomID();
96 rmiObj.sendReturnObj(retObj);
99 public void ___getRingStatus() throws IOException {
100 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { },
102 Object retObj = getRingStatus();
103 rmiObj.sendReturnObj(retObj);
106 public void ___setNewRoomIDAvailable() {
107 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { boolean.class },
108 new Class<?>[] { null });
109 setNewRoomIDAvailable((boolean) paramObj[0]);
112 public void ___setNewRingStatusAvailable() {
113 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { boolean.class },
114 new Class<?>[] { null });
115 setNewRingStatusAvailable((boolean) paramObj[0]);
118 public void ___registerCallback() {
119 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
120 new Class<?>[] { null });
122 GPSGatewaySmartCallback stub0 = new GPSGatewaySmartCallback_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
124 registerCallback(stub0);
125 } catch(Exception ex) {
126 ex.printStackTrace();
127 throw new Error("Exception from callback object instantiation!");
131 private void ___waitRequestInvokeMethod() throws IOException {
133 rmiObj.getMethodBytes();
134 int _objectId = rmiObj.getObjectId();
135 int methodId = rmiObj.getMethodId();
136 if (_objectId == object0Id) {
137 if (!set0Allowed.contains(methodId)) {
138 throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId);
142 throw new Error("Object Id: " + _objectId + " not recognized!");
145 case 0: ___init(); break;
146 case 1: ___start(); break;
147 case 2: ___stop(); break;
148 case 3: ___getRoomID(); break;
149 case 4: ___getRingStatus(); break;
150 case 5: ___setNewRoomIDAvailable(); break;
151 case 6: ___setNewRingStatusAvailable(); break;
152 case 7: ___registerCallback(); break;
153 case -9998: ___regCB(); break;
155 throw new Error("Method Id " + methodId + " not recognized!");