import swarm.Selector;
0 V8 W4 D1 n# k, U2 u
0 X$ n& Y3 v+ ?public class SwarmUtils {2 G: ~( \; j7 g1 w3 A
public static Selector getSelector(String name, String method) {
1 }$ I" g/ e( G: a6 ` Selector sel;
% x" A! `; y' \0 Y" i try {
" i7 U1 e! A O4 b) m sel = new Selector(Class.forName(name), method, false);+ f2 k# ]! b6 R1 k1 N) H
} catch (Exception e) {0 Y: q4 q/ k1 M+ }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 K" M8 G5 a8 v! p% F0 X System.err.println(name + "." + method + " returns " + e.getMessage());. |/ l5 J! t2 l! L E' T& N
System.err.println("The process will be terminated.");! H) v$ z- @5 y& x2 C1 ]4 D
System.exit(1);
& ^5 U: I: D: t return null;4 s8 k2 Z: l) M' Q1 ^
}' G( n6 f) O$ W& }
return sel;% A) S3 E& l* b8 a
}' D+ N5 g* O5 n" r
- y3 Z: l. t. w8 [ _% q; @0 _4 A
public static Selector getSelector(Object obj, String method) {
9 f0 S# c+ R* F3 k! Y Selector sel;
. s0 `# s) H# E) D" o try {: \/ K# A1 A' y* i, J! |/ S" Y$ T: X
sel = new Selector(obj.getClass(), method, false);
, R! f: Z) i/ B$ {, Z1 Q } catch (Exception e) {
0 o# E5 Z# l4 s# P. s- y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 o) L9 e8 J6 w. \/ z + (obj.getClass()).getName() + ".");) D7 j3 K# X( H! M* {; E Q8 e
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
, A W* i9 H, I* m! K% f4 q' `6 l System.err.println("The process will be terminated.");
! f9 d' d( w1 F: N+ h System.exit(1);( _( q. b/ t: k: C% K) |& p) T: {* d
return null;# w+ ^) L, V- F" k+ w, D1 y
}- N/ n$ Q9 e! I; M8 W
return sel;
' H. W- a8 K/ H1 e. H `5 f. B, C }
( x* Q. _& A0 J( x# S: ~( g} |