import swarm.Selector;
& n+ M. ^' d& O: Z1 p+ e1 h5 w2 I i, M) ^, Z. x6 o
public class SwarmUtils {) s! p2 Z8 R0 S0 L ~+ D
public static Selector getSelector(String name, String method) {
a% r$ J9 g1 K# f2 k3 U( n Selector sel;( V% F. m4 x0 g0 e
try {
4 u c: q% t* a; T+ J- h$ t6 v) j sel = new Selector(Class.forName(name), method, false);; J @4 y3 A2 b/ y6 H2 I0 ]
} catch (Exception e) {1 Z. n- P& l0 D/ K4 e; n. Q
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
g3 A3 U. |5 C5 Y System.err.println(name + "." + method + " returns " + e.getMessage());, [$ J3 G1 S. S
System.err.println("The process will be terminated.");4 m5 p2 d" \; L
System.exit(1);3 n: J Y& i$ w
return null;
3 [* C# g9 ~9 R) W* u0 w0 D( v& u }4 W5 W. Z. X3 w7 B# R7 m: U
return sel;
8 L6 R0 d2 @0 H8 Z9 M% p }# s/ M _" z# O* d. C: I
$ y$ e2 U0 c6 W public static Selector getSelector(Object obj, String method) {/ }' L2 ~% m+ I7 \+ x3 q4 ?
Selector sel;
* ~2 H3 j. ]9 K5 h: I |8 a try {' G9 n# F7 p" m5 n7 M( v
sel = new Selector(obj.getClass(), method, false);" J0 R7 O6 Q0 ]8 s( g0 f
} catch (Exception e) {
l' B9 g6 w* k9 G1 {% R: t5 ]) w System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ") W S1 g- ?( W& i2 C
+ (obj.getClass()).getName() + ".");( u- }- A+ T9 `4 [
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" y/ H8 G$ f; V) J System.err.println("The process will be terminated.");
! n: c$ {4 ~- J5 A6 J5 k4 S System.exit(1);" Z4 X5 L; |* n. |# [
return null;
) q6 a% m9 V1 v p5 \ }
; U; n8 [5 P6 S1 C, v2 s! x* F return sel;7 x/ m$ _$ I6 G7 b' c9 s% A6 O
}
2 J# ?+ l7 O+ b6 `2 R} |