import swarm.Selector;6 v) Q6 W/ |; e
' W4 g3 G3 Q. x: p; r4 z" w7 epublic class SwarmUtils {+ l, T. ~* G) T
public static Selector getSelector(String name, String method) {
$ G! w9 m0 x( l% O, H, X: W3 { Selector sel;8 A( i9 k' T' a+ ^1 C* r5 O4 [
try {
: n$ b, `/ o# j2 A# i9 { sel = new Selector(Class.forName(name), method, false);
7 [$ ?' I& |3 a2 I9 V) i } catch (Exception e) {# `, O/ ?% c! f& x0 w) t8 C' k
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* ?% Q" Z3 K5 N# e8 n4 w. j
System.err.println(name + "." + method + " returns " + e.getMessage());
1 B; h P$ D. D/ z/ A System.err.println("The process will be terminated.");
' q0 W; i* B2 a% ^) Y% f System.exit(1);
. |$ Z9 Y2 C3 c0 M' p return null;' _. v9 Y1 |' B0 m
}
3 F% R/ p. i2 Y4 I& T return sel;
3 p) j1 G( T5 e }
9 d) O) j; a) E: L7 J$ }; W) {: T& _, p, T$ r% @+ `" \
public static Selector getSelector(Object obj, String method) {
a/ T& [$ P8 b/ C1 v/ z9 y' V Selector sel;
; P' B' S$ `* `, e5 h" d p9 a9 z try {
" y$ u! ]: ~" ^( l. Z5 D* p8 M1 ^6 X sel = new Selector(obj.getClass(), method, false);4 b' b5 U! [! |3 B% f0 M: h3 r" L% v
} catch (Exception e) {1 ~$ Z" B* ?2 S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
/ R( _ }: N: t. F + (obj.getClass()).getName() + ".");
# i9 f4 ]0 N5 H" r) n System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
- E/ H# M* B6 { System.err.println("The process will be terminated.");
; h" j K; K. H9 Y) w System.exit(1);# o* X }* P& ]
return null;& g/ v; c6 O8 W& Z+ T" U: K
}
+ @2 Q1 w) Z& e, b0 H5 K4 b! D return sel;
/ L9 D" {& I( ^5 G8 A* S }7 B1 e0 E: u5 J' F% Y8 }$ a
} |