import swarm.Selector;# m7 ^& ?7 N" D0 P) C& r% |% I) J/ n
7 K: Y! B* K7 L9 E J; upublic class SwarmUtils {0 x( d% t2 h% }/ {* e
public static Selector getSelector(String name, String method) {6 T- R2 l& b! }1 }
Selector sel;
: ?' H! y5 J; X9 `4 O! Y, | E try {; T' e$ b8 @! [, G& R8 W m _# z
sel = new Selector(Class.forName(name), method, false);
7 ~5 r5 N5 a2 X Q# d } catch (Exception e) {
* E2 @& u& m& W3 a$ M& h/ j System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
+ s. Z2 e6 u. D* e System.err.println(name + "." + method + " returns " + e.getMessage());+ R' @" P3 [, t- S& k! w
System.err.println("The process will be terminated.");
; j2 Y5 D/ Q. P# u; u8 D System.exit(1);2 V0 U. t$ |% U, [+ W( u Z& \* a
return null;
" V$ ]0 t/ J: n7 @0 B }
. `- a" U# |( P) o4 K, [: H return sel;
; _; q5 g& p. f- p2 m }$ [ k! t* _- L; d
4 m3 y8 a/ e* W/ X/ y+ w& V6 P6 O
public static Selector getSelector(Object obj, String method) {* p& E7 c/ U+ c4 h& n) F
Selector sel;5 w" J( r" E N" Y3 a
try {
6 C [6 q1 z/ x5 t ]' r; }& ^ sel = new Selector(obj.getClass(), method, false);5 f! S7 [8 }2 m
} catch (Exception e) {, L( G# T. F! N" b& i0 p
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
; M, O* G- Y" Q6 @ + (obj.getClass()).getName() + ".");
) J3 q4 ~+ x& w! g( _) H" z System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());# X* [' X9 P- }6 }$ H5 W
System.err.println("The process will be terminated.");
# C S* c6 g# Z System.exit(1);) Q j q) k4 n& W
return null;2 P) J" k% |6 u$ {: w4 t
}# z# F K7 D( ?) m) y+ F
return sel;4 |3 S9 G$ j' A# ]( W
}# q! n" f$ c, S/ O
} |