import swarm.Selector;
. u" X# Y5 j. A2 l) v7 l( \' K Y3 G; I
public class SwarmUtils {
( Y3 }5 G5 p3 ^) B! v; D8 q, r public static Selector getSelector(String name, String method) {" V- q6 m2 q) o/ b7 M h1 n m; d
Selector sel;0 R/ Z4 |3 |! i- E
try {
. y7 q- |. V$ a# @+ S, k0 ^ sel = new Selector(Class.forName(name), method, false);! v" k( C0 R% W; U2 b
} catch (Exception e) {
+ S4 U7 l) S9 i0 ]5 `* @" c' ]! X System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ C2 W2 W8 K& |' A n6 @! t- m ~, Q System.err.println(name + "." + method + " returns " + e.getMessage());5 W/ F& m9 i( ~1 d
System.err.println("The process will be terminated.");" g; D/ ?8 K- ?( e' T. N
System.exit(1);/ I5 G, g1 } H" f) Q
return null;. q" O2 f; E$ S n0 J# r
}# b/ q+ _# _7 L8 s6 Q
return sel;
# _6 t! n2 N' d }+ g p4 X8 I% ^* O+ Y" E+ X }( }
2 E G. ~5 m0 z
public static Selector getSelector(Object obj, String method) {
' A7 G2 C0 E- A/ ^7 Z1 |0 J Selector sel;0 v7 X% w; ?& a+ Y R$ o9 l- f
try {% x3 x& z, ~' p' B/ e5 b$ l8 `
sel = new Selector(obj.getClass(), method, false);
0 O0 g8 {, F2 R$ L0 {8 Z2 i } catch (Exception e) {/ z* p6 ^$ f8 B; b2 H+ O
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ". A- X1 v& a( `: j
+ (obj.getClass()).getName() + ".");! {$ C$ s1 v2 F
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());# q) Y; R& m0 |4 u, q( ^
System.err.println("The process will be terminated.");; u7 j1 E: S. `( p' f! e
System.exit(1);/ q4 [3 s& b1 n/ W" d
return null;' c3 O4 g0 H* f; Z, O
}& C- j, r; Z3 T# k
return sel;
) _7 o& c1 c- L1 x/ f! l }
6 N" u1 C- \+ L! O* Q8 ]5 o} |