import swarm.Selector;; R0 s" N! R) i! C, p& g
3 T1 f2 Z! l+ H0 _9 G/ [! Dpublic class SwarmUtils {
5 L' {: z& Y: C% S& q* R/ \' ~ public static Selector getSelector(String name, String method) {& b, J5 |7 B6 P% c
Selector sel;
8 L g" E# I* O3 A. b try {7 y' M+ z1 G" M$ x
sel = new Selector(Class.forName(name), method, false);4 n3 k0 x( i6 s0 k1 R4 d9 _
} catch (Exception e) {
2 M+ S7 H& J8 t* H2 g6 a5 r System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
' G: L% X. o ?" N7 I7 a. w6 Z System.err.println(name + "." + method + " returns " + e.getMessage());
7 w3 l, y: a% m7 M Z System.err.println("The process will be terminated.");( H- r" M# {: l0 {) G
System.exit(1);
( g0 ~" e. p+ `. ?+ n& _& H return null;
6 `# w3 M5 U" h, ^ }
, M8 C" e" a' m" y' `6 p5 a return sel;
! l! P8 A; r* ?' N- D9 }/ d0 L2 g }
7 S+ x$ B# y$ O. R3 u" W- j$ {* n" e4 M9 U5 _
public static Selector getSelector(Object obj, String method) {
% j7 U& l: n- q* X8 | Selector sel;% V( K8 a$ z i" E' h: `
try {# E, g6 s" J3 v) ?' Y
sel = new Selector(obj.getClass(), method, false);
" X2 ~4 M% I: x } catch (Exception e) {( w+ K. ? k& q% ^; E) y3 |8 H0 d
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 s6 v t3 Y) V+ M! C) E0 u0 f4 B
+ (obj.getClass()).getName() + ".");
! ~- i' x6 T# S" x. J System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
+ E! N- G c4 L8 u, ^) d System.err.println("The process will be terminated.");
) \; V6 j9 _3 Z0 d2 X' X& q" p System.exit(1);1 D( K8 l- y( B+ i- J* U* }
return null;3 M1 C$ C- h9 U$ D
}
6 X) V% c# r; d/ c. |* P' t return sel;) U7 V" e, l7 c
}
' Q4 A7 f. |4 D. L, q} |