import swarm.Selector; B2 p3 l; U$ a6 H- j; K+ M
+ t1 v/ L; k0 U/ K9 ?% p. upublic class SwarmUtils {
; }# i, F' x; E7 p$ d- \0 U public static Selector getSelector(String name, String method) {
3 [$ g. R5 r% i8 P2 U& G+ r- \ Selector sel;' y5 F: f5 t' _& C
try {
# m# y, I4 I: E& l) L6 z sel = new Selector(Class.forName(name), method, false);
+ o. B# s3 U/ g4 G+ E } catch (Exception e) {' h q1 \: r* x
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");$ r7 H |. Q- P6 o8 {) ^ F
System.err.println(name + "." + method + " returns " + e.getMessage());- y& Y4 o8 T/ j- Q; @' M
System.err.println("The process will be terminated.");
: v5 J2 g( ~. e System.exit(1);
$ f# _7 ?3 z3 N6 U2 i return null;; t" P }, p* A7 B) k+ b
}
! Z- e) B4 e* N$ J. L; }% v return sel;
9 i: E2 R% r0 |5 M& o }
# Z" H3 ?2 [7 o, T3 p$ }$ I$ A: p4 p. h& o9 c2 l* N" y
public static Selector getSelector(Object obj, String method) {
/ ]1 d$ ?' j4 e4 Z6 v# I1 m3 i2 ] Selector sel;
6 ]: ]# P4 Z" I- c try {
2 }' {2 U, Y: w6 V) @1 W" t sel = new Selector(obj.getClass(), method, false);
( H' I5 i f3 j- `0 s9 h2 }3 u8 p; W8 @, a } catch (Exception e) {
' s" f. p2 W& b# q9 F$ y System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "# t6 m1 b! ^8 c7 z" k- V4 j! f
+ (obj.getClass()).getName() + ".");9 y! F o$ X, E( Y3 H. r
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage()); ~/ W N! \+ P1 w
System.err.println("The process will be terminated.");; F K9 U! W8 F1 O
System.exit(1);1 P r9 m# }5 W8 N8 I: D
return null;# s& {) G* p0 ?( N/ b% ]
}
+ M2 T+ J6 y6 ]' H8 k$ L4 @ return sel;5 \. V) G- r |3 V# _, d
}
) U/ Z% B: ]& I8 E0 x3 Q# |7 l} |