import swarm.Selector;4 Y3 }. _7 C7 ~+ a/ Y4 m% l# A
, R- k& r+ N3 `% G! y z, {% N& @! Ppublic class SwarmUtils {
6 g5 }2 x) x! Y. I) ~ public static Selector getSelector(String name, String method) {
2 _% E& Z' B3 q! }/ D, l( z Selector sel;; e4 r5 h# C9 Z& I
try {& ?1 j( i! b& i9 C
sel = new Selector(Class.forName(name), method, false);3 E* D0 w* b- e: j
} catch (Exception e) {' V6 r" K9 X+ u: ]/ S
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
- q7 o$ M/ x; _; w2 C System.err.println(name + "." + method + " returns " + e.getMessage());
: X8 L$ `4 ]; N- k6 N- S System.err.println("The process will be terminated.");
& |! F+ F) v9 z* k$ x% x System.exit(1);
3 T& |2 _9 r2 a return null;: b- C. |. M) D6 `
} n6 z" E9 Q' F& l% K. Z; v1 r! k
return sel;' b: k! Y2 u( r1 q
}! m8 y$ O( z7 [. C9 J1 c
( b6 A3 K4 @& u: N* ^9 V( y0 L public static Selector getSelector(Object obj, String method) {) I" y) M5 e6 J* ?. b
Selector sel;
0 ~1 M4 b7 D2 u4 l* M try {
( m y* G/ c8 G0 r& y; J6 M sel = new Selector(obj.getClass(), method, false);
# A6 N- h% z6 H4 D" R+ U } catch (Exception e) {( t# @9 }: @# l" B | M
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
" t* ~4 G% }3 o1 u$ O + (obj.getClass()).getName() + ".");. ?, |8 b2 E P9 I/ I n; }4 L u$ q
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
3 w' P7 e8 \) r5 d0 I q# R System.err.println("The process will be terminated.");! H2 g5 J& f" A5 ~
System.exit(1);( ]: G7 x5 w: c
return null;. j* X2 j; K0 T8 H
}
/ U8 b& Y& B4 u+ y4 X return sel;6 S$ P; ], ?7 l* e5 Z. H, v- p2 c1 H/ s
}0 ~" V K* `3 f
} |