import swarm.Selector; z7 v9 r( \3 c. b
0 T& ~9 w8 Q7 x2 G5 _) o
public class SwarmUtils {: b3 F* D3 A: Z" \3 @ q, J
public static Selector getSelector(String name, String method) {+ e8 h* C, H& i, h# q
Selector sel;
& g' T2 @+ t( v4 U# v$ m try {8 V- [1 s# [- D. n. C6 f8 _) K
sel = new Selector(Class.forName(name), method, false);
p$ n) ~) U3 V% S } catch (Exception e) {
g* h+ t" X" r3 U System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");! t ]" |/ D6 H
System.err.println(name + "." + method + " returns " + e.getMessage());+ V$ g. M3 z! c3 f# w" T
System.err.println("The process will be terminated.");. g5 t9 d; M2 ~
System.exit(1);
8 `' F: X X' F return null;# h: m1 z c. a8 z6 P
}# j) P6 R" D$ h2 o) a
return sel;1 x1 z, a6 k: U8 |4 U
}% R$ R# Q; F4 S% T( y7 m
# _; L6 e: a: Y' K7 [ public static Selector getSelector(Object obj, String method) {! ~+ L2 k/ I. X# [, N( l+ s* }
Selector sel;
3 p' E) D, F. s. C try {3 k1 T# P6 p6 l1 t
sel = new Selector(obj.getClass(), method, false);
0 W- j$ _9 ~: I& `2 ]5 w: B8 E } catch (Exception e) {0 A6 P& C& i6 o1 ?
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
. o+ @$ X8 G. p+ ^ + (obj.getClass()).getName() + ".");
9 u2 Y, J) A8 D' i0 K2 d( D$ _: z System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
' z0 m3 O) E0 r4 n( ~, f System.err.println("The process will be terminated.");, }5 R: D) J+ @* \) W! M
System.exit(1);9 p2 M* v) \0 `8 X/ |
return null;
7 [* M0 b" K1 M3 J }
& N' \- U6 `/ Z return sel;
V9 B& O, a. Z" }3 {# U }7 @* z: t9 Z) K5 k
} |