import swarm.Selector;
$ x( `' T2 N6 M5 E* m6 _4 L5 N6 H. |0 F5 \, D
public class SwarmUtils {9 u8 H) {) i9 l. Y
public static Selector getSelector(String name, String method) {1 i0 Y6 W6 p: q9 R$ f- E. r
Selector sel;
. A) e* e9 ]; v6 ?& g- g try {. E. i% @7 W# q( \
sel = new Selector(Class.forName(name), method, false);
9 F, \! M2 { B } catch (Exception e) {& R4 ^' F( K( R* J3 Y( F7 k" U
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
( W6 U0 X Y+ O9 [ System.err.println(name + "." + method + " returns " + e.getMessage());
r; Z S+ m: c0 b1 M* l% a System.err.println("The process will be terminated.");6 r; x5 E$ o9 C
System.exit(1);" M1 c3 _2 d! Y: t" D$ E, w
return null;# a# X# D! a1 J) X" {
}
, k/ d$ G @* V) ]! O return sel;. m9 F( f, V6 `# F5 A: Y# d2 N
}
: p( n# R1 R5 O# H& ~) R8 [: z1 Y' v. q2 v
public static Selector getSelector(Object obj, String method) {
& L; d/ B/ {8 Z( o Selector sel;* A/ x3 [ w9 d; [4 p* Q5 H
try {2 u! K, N& B& k E$ w- M: u% C* Z
sel = new Selector(obj.getClass(), method, false);
8 R) u* l p% Y4 V9 E* @ } catch (Exception e) {" ^/ k6 r/ e6 e, x: H
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "' f7 i& b$ T1 B0 |: v
+ (obj.getClass()).getName() + ".");9 y+ {0 I/ d+ l5 E4 U
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
% _9 @6 N3 ]3 x: l, c3 i1 J System.err.println("The process will be terminated.");% g6 i! E2 t# a
System.exit(1);- G, V" Y$ f( M' p& |
return null;/ l# P5 x6 J2 R
}
/ u6 G* E# @+ \7 s( a9 w- \ return sel;
/ m; G$ b; Z- C! x/ l } L) P/ y! }( O; c, y! n! Z
} |