| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package jpype.proxy; |
| 17 |
|
| 18 |
import java.util.LinkedList; |
| 19 |
import java.util.List; |
| 20 |
|
| 21 |
public class ProxyTriggers |
| 22 |
{ |
| 23 |
|
| 24 |
public static String[] testProxy(Object itf) |
| 25 |
{ |
| 26 |
List<String> methods = new LinkedList<>(); |
| 27 |
if (itf instanceof TestInterface1) |
| 28 |
{ |
| 29 |
methods.add("Test Method1 = " + ((TestInterface1) itf).testMethod1()); |
| 30 |
} |
| 31 |
if (itf instanceof TestInterface2) |
| 32 |
{ |
| 33 |
methods.add("Test Method2 = " + ((TestInterface2) itf).testMethod2()); |
| 34 |
} |
| 35 |
if (itf instanceof TestInterface3) |
| 36 |
{ |
| 37 |
methods.add("Test Method3 = " + ((TestInterface3) itf).testMethod3()); |
| 38 |
} |
| 39 |
return methods.toArray(new String[0]); |
| 40 |
} |
| 41 |
|
| 42 |
public void testProxyWithThread(final TestThreadCallback itf) |
| 43 |
{ |
| 44 |
itf.notifyValue("Waiting for thread start"); |
| 45 |
Thread t = new Thread(new Runnable() |
| 46 |
{ |
| 47 |
public void run() |
| 48 |
{ |
| 49 |
for (int i = 1; i <= 3; i++) |
| 50 |
{ |
| 51 |
itf.notifyValue(String.valueOf(i)); |
| 52 |
} |
| 53 |
|
| 54 |
} |
| 55 |
}); |
| 56 |
t.start(); |
| 57 |
try |
| 58 |
{ |
| 59 |
t.join(); |
| 60 |
itf.notifyValue("Thread finished"); |
| 61 |
} catch (InterruptedException ex) |
| 62 |
{ |
| 63 |
Thread.currentThread().interrupt(); |
| 64 |
itf.notifyValue("Thread has been interrupted"); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
public Object[] testCallbackWithParameters(TestInterface2 itf) |
| 69 |
{ |
| 70 |
byte[] vals = |
| 71 |
{ |
| 72 |
1, 2, 3, 4 |
| 73 |
}; |
| 74 |
return itf.write(vals, 12, 13); |
| 75 |
} |
| 76 |
|
| 77 |
public boolean testEquals(Object o) |
| 78 |
{ |
| 79 |
return o.equals(o); |
| 80 |
} |
| 81 |
} |