import swarm.Selector;/ T5 @. I5 }$ e; t
3 ?7 l- y$ S2 y1 O. j
public class SwarmUtils {: e; k/ H; i& y, h5 q6 N% W2 G' g
public static Selector getSelector(String name, String method) {, B6 S! k4 H+ u4 Z
Selector sel;
2 S8 y" r4 A: C0 M+ h7 F try {
; F0 s$ t, O! D* N6 L+ H sel = new Selector(Class.forName(name), method, false);
9 H h4 B/ o1 I; `( {" ^+ a# m } catch (Exception e) {
; L. k' O& {4 [# O6 o' e& l8 m System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");8 ^8 @$ v& s5 [% Q
System.err.println(name + "." + method + " returns " + e.getMessage());
1 ~* c# S: \( ^" `4 V' J8 y System.err.println("The process will be terminated.");
6 Q4 x: \, Z5 K+ x( B$ l$ g System.exit(1);
. v! O+ @6 A) T5 j return null;- Z: v: g8 H y+ R. w7 v0 l- h
}
) }, w* _# O, }! q! B t1 }& r3 o return sel;! C" j' K. h& e3 ^ n3 O6 r6 ^
}" n: y8 B, ^/ ~# H2 i$ g; X7 u
3 \' D, r# y) O# i! z$ [$ I0 }. K; d public static Selector getSelector(Object obj, String method) {% Q5 n9 M$ ?" x( N+ M+ y1 A! l
Selector sel;' u2 s, z& f m) U# D
try {* R+ [* b; ?* ]1 A( Z+ m
sel = new Selector(obj.getClass(), method, false);
) L/ n) O7 z7 ~& v. r$ T& ? } catch (Exception e) {
8 G/ @: y" ^9 o9 U4 a; v System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
5 e+ G0 t) w) K: U1 ], ?7 Y + (obj.getClass()).getName() + ".");& o: F3 J* J* f# K1 s, O B
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" Z8 P g- I; E' P% m+ Z9 ? System.err.println("The process will be terminated.");
& C; p: K3 _ W# Q System.exit(1);
7 D" c+ S* i8 e9 @8 I) `5 H/ T return null;
& `5 |0 ? [) U) ?. \- i }2 Q1 R& {" ?4 |2 q
return sel;2 s& f" J7 L. F
}! R6 Z0 u [" a1 d4 U% I
} |