import swarm.Selector;4 q. `5 I# s3 l j
5 A9 K- V- w; l$ dpublic class SwarmUtils {$ X& J. w$ d" c3 w& D3 o
public static Selector getSelector(String name, String method) {7 X: m0 t8 k. p Q
Selector sel;% O! ~7 w& X; U2 E2 C4 Q( g- F
try {. A' V R, S; D: {) r( O, W
sel = new Selector(Class.forName(name), method, false);- j! v. n7 p# W& o2 z& p, ?
} catch (Exception e) {" N& \8 H5 f. K1 Q) K( v
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; w# A7 ^4 Z" r! U2 k$ a" w
System.err.println(name + "." + method + " returns " + e.getMessage());: l, d# F/ q; Z; m
System.err.println("The process will be terminated.");
8 w1 v; O; d/ U; t3 k' j8 y System.exit(1);
" a" K4 C& B+ a- T1 Q$ R4 b( Y$ D5 V return null;+ a9 g0 M, t% v( N8 `/ P. o
} a5 u& @; t, y& h
return sel;
/ q* N) S8 d% z% } }, l, i4 h( U9 r
2 ]- ]' [( W; u$ Z# S" t- A
public static Selector getSelector(Object obj, String method) {
2 r: N7 ?: _) o! _: B; d I: q Selector sel;* y/ `. H i* U- q& b; x8 t0 J
try {
& L( m3 H$ S* j3 w+ U. i1 T7 E5 h sel = new Selector(obj.getClass(), method, false);$ A0 n' [7 ^5 n w( f o% l
} catch (Exception e) {( ?: g! V! c. k4 n/ R+ y6 j$ R
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "9 k. l/ `; ]+ u7 s- W
+ (obj.getClass()).getName() + ".");) e( ^; y1 N G6 i& T- R
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
) \1 ]; g+ L+ e2 c+ I/ C System.err.println("The process will be terminated.");
4 E. w6 K: t& M) [ System.exit(1);
# R2 C; f [& s) u7 Q* k return null;
0 i- x6 w' p7 [9 q9 j. F) M/ |. J }4 {' ]' J/ B# j; r! @
return sel;
' B. A, ^" }. X3 Q! p9 R$ ] }9 M- A/ V. Y2 V; `, C/ n
} |