import swarm.Selector;
8 P1 @ G3 b$ C/ w- n1 }3 v2 ?$ g3 x4 n I& ]; \1 s
public class SwarmUtils {4 f x6 e# @) A% C& ]
public static Selector getSelector(String name, String method) {+ U# m6 k/ W" A$ l* j' v
Selector sel;
0 V% B3 S/ e F$ p3 R: I1 j7 \ try { L; [; K4 z4 F; {' V
sel = new Selector(Class.forName(name), method, false); t6 v( o4 g" r* A
} catch (Exception e) {! L+ H o) a. K+ V- F9 p* j
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");4 \4 x4 p: V+ G3 d& M/ f
System.err.println(name + "." + method + " returns " + e.getMessage());) Q- @& T' ?; g+ c9 P& C" W
System.err.println("The process will be terminated.");
' D% F/ p) T2 t( B. U System.exit(1);3 W' _8 ^" c) L1 D$ p4 M& z
return null;4 k$ _+ Y) H+ q; C/ a
}5 g% ~8 w' y. i0 A4 O5 Q
return sel;
/ C. L+ b) O. | }1 `" i: G/ e7 U! l/ [ _8 f/ P
+ }7 X2 u% [( P% ~ g public static Selector getSelector(Object obj, String method) {% e; c0 _, j+ A' q: Y
Selector sel;
& K& Q( f# V6 w3 @- G5 a9 [! o try {
" a. e/ ^0 \% k( s- R. s/ q sel = new Selector(obj.getClass(), method, false);9 ^" _/ m# L3 y* G# ?- N! m
} catch (Exception e) {3 ]+ s% K# G; y0 h
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
8 i2 [/ Z' @" t1 F' U + (obj.getClass()).getName() + ".");
( `6 c+ `" w! @ L, W System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());$ a0 t0 U6 d8 p' U# h9 `
System.err.println("The process will be terminated.");
- y) e. y0 t0 Q System.exit(1);7 n! I$ L D6 {0 q; Q$ Z6 }
return null;
" {: w/ \0 w I% a. f/ c } f3 O" w' w& g e! l2 U( ]
return sel;$ W. P# ~, u+ g2 G4 Z; N
}
0 M" o$ j0 Y9 H} |