Working Java v.1.0 for arbitrary calls of callback objects
[iot2.git] / iotjava / iotrmi / Java / basics / TestClass.java
index 124800490d16454092e4d5e1fa23fd36a72e78b5..48748d0546c7ba5cac88e3832bef5e1c8195c153 100644 (file)
@@ -33,13 +33,29 @@ public class TestClass implements TestClassInterface {
                cblist = new ArrayList<CallBackInterfaceWithCallBack>();
        }
 
+       
+       public int callBack() {
+               
+               int sum = 0;
+               System.out.println("Callback called! cblist: " + cblist.size());
+               for (CallBackInterfaceWithCallBack cb : cblist) {
+                       sum = sum + cb.printInt();
+                       //TestClass tci = new TestClass();
+                       cb.needCallback(this);
+                       //cb.needCallback(this);
+                       //cb.needCallback(tci);
+                       System.out.println("Inside the loop!");
+               }
+               System.out.println("Executed callback of callback! Returning value: " + sum + "\n\n");
+               return sum;
+       }
 
        // Callback
        //public void registerCallback(CallBackInterface _cb) {
        public void registerCallback(CallBackInterfaceWithCallBack _cb) {
 
                cblist.add(_cb);
-               System.out.println("Registering callback object!");
+               System.out.println("Registering callback object! Items: " + cblist.size());
        }
 
 
@@ -73,18 +89,6 @@ public class TestClass implements TestClassInterface {
        }
 
 
-       public int callBack() {
-               
-               int sum = 0;
-               System.out.println("Callback called!");
-               for (CallBackInterfaceWithCallBack cb : cblist) {
-                       sum = sum + cb.printInt();
-                       cb.needCallback(this);
-               }
-               return sum;
-       }
-
-
        // Single variables
        public byte getByte(byte in) {
 
@@ -520,4 +524,10 @@ public class TestClass implements TestClassInterface {
                intA = newA;
                return intA;
        }
+
+       public static void main(String[] args) {
+
+               TestClass tc = new TestClass();
+               System.out.println("Get short: " + tc.getShort((short) 1234));
+       }
 }