import swarm.Selector;
2 n3 ]8 A, a( V& \1 X6 a' q$ b0 |
h g/ w8 B: ~public class SwarmUtils {; m, Z: Y. U, P7 C8 R' ^* L- U
public static Selector getSelector(String name, String method) {
Z8 d2 Y2 _4 V' e- P5 c. Z) t4 v1 { Selector sel;. o A, _5 o! b/ w* E4 T
try { }2 T0 ~. s; V% k1 O* l: l
sel = new Selector(Class.forName(name), method, false);
; _ R+ _( p& |8 `1 C% b0 b# _4 M } catch (Exception e) {( [# L: y" c& ~) Q8 y. C
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
( a2 K( V" x8 I% B System.err.println(name + "." + method + " returns " + e.getMessage());
. \+ U4 f' E& D6 C6 j) [' j System.err.println("The process will be terminated.");5 i. ^1 t/ ~3 c
System.exit(1);
/ D5 @& T* W+ a3 \3 g return null;* }! }3 S" O. a4 u$ n; ?5 }
}! {+ i* y. |+ {4 U: m& h
return sel;1 Z0 z E3 z) _3 l! N" x, x
}
+ m5 X. v% {+ m. _, U% k, c1 J7 ]
8 Q( j# o+ @. b& @! c" G public static Selector getSelector(Object obj, String method) {
* ]0 ?$ e$ v+ g! } Selector sel;
) I- L! @8 d/ z8 d try {+ `2 ^! E$ q# g. n' x+ v" u; t
sel = new Selector(obj.getClass(), method, false);
0 B2 \7 }3 w$ X& p+ u/ u } catch (Exception e) {. W6 C( @1 M' B3 ~% _
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 h9 ~, g9 K# u6 x) B% h* @& I + (obj.getClass()).getName() + ".");' e: J$ ?+ @, b1 P) N6 L
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
& I5 g& \& ~* [( U( P* S( X& c2 _ System.err.println("The process will be terminated."); a6 {0 b1 T7 O2 F& l5 k
System.exit(1);; ^# N, E) K) H# @* i1 Q- B
return null; t( `4 T' p* H' B
}( D/ ?! K* G1 j4 u
return sel;. n9 k* k' u( ^2 ~
}* a+ I; o. j0 R4 j* p7 O
} |