public class CallBack_CBSkeleton implements CallBackInterface {
private int objectId = 0; // Default value is 0
- private final static String[] methodSignatures = {
-
- "intprintInt()",
- "voidsetInt(int)"
- };
private CallBackInterface cb;
System.out.println("Creating CallBack_Skeleton and waiting!");
}
-
- public Object invokeMethod(IoTRMIObject rmiObj) throws IOException {
-
- String methodSign = rmiObj.getSignature();
- Object[] paramObj = null;
- Object retObj = null;
-
- if (methodSign.equals("intprintInt()")) {
- retObj = printInt();
- } else if (methodSign.equals("voidsetInt(int)")) {
- paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
- new Class<?>[] { null }, new Class<?>[] { null });
- setInt((int) paramObj[0]);
- } else
- throw new Error("Signature not recognized!");
- System.out.println("Return object: " + retObj);
-
- return retObj;
- }
-
-
- // Return method signatures
- public static String[] getMethodSignatures() {
-
- return methodSignatures;
- }
-
-
+
public int printInt() {
return cb.printInt();
}
+
+
+ public void ___printInt(IoTRMIObject rmiObj) throws IOException {
+ Object retObj = printInt();
+ rmiObj.sendReturnObj(retObj);
+ }
public void setInt(int _i) {
cb.setInt(_i);
}
+
+
+ public void ___setInt(IoTRMIObject rmiObj) {
+ Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
+ new Class<?>[] { null });
+ setInt((int) paramObj[0]);
+ }
+
+
+ public void invokeMethod(IoTRMIObject rmiObj) throws IOException {
+
+ int methodId = rmiObj.getMethodId();
+
+ switch (methodId) {
+ case 0: ___printInt(rmiObj); break;
+ case 1: ___setInt(rmiObj); break;
+ default:
+ throw new Error("Method Id not recognized!");
+ }
+ }
public static void main(String[] args) throws Exception {
- int port = 5010;
- CallBack cb = new CallBack(23);
- CallBack_Skeleton cbSkel = new CallBack_Skeleton(cb, port);
- cbSkel.waitRequestInvokeMethod();
}
}