import swarm.Selector;+ {. x) R, O8 @& X( ]- @- ~
% N3 [8 W7 l @3 j
public class SwarmUtils {. ^/ L, M, S0 R# }' O6 P G
public static Selector getSelector(String name, String method) {
* k1 X$ C& ]+ r$ c" W. u2 \ Selector sel;
- _" M& B6 Q4 \" n try {/ x/ x6 x' U9 @. }& p
sel = new Selector(Class.forName(name), method, false);+ t% E; i* R9 Z @. Z' h, Y% }
} catch (Exception e) {
# k& D' t8 j4 D4 @( N/ N2 C System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");- Z9 Y( a% D4 y$ y V( V. _6 |
System.err.println(name + "." + method + " returns " + e.getMessage());6 \/ ? L( c0 p9 d( p# G0 i
System.err.println("The process will be terminated.");
2 }; u2 N" D- n/ `& d System.exit(1);! R; @* L, C0 _( B& F; w
return null;, i% `0 \" \% _' Z, m' @
}1 r2 C5 S Y p4 z. t
return sel;) B0 D7 P9 R8 C
}$ N) d$ ?$ w% T5 C
1 N/ b5 N6 g' p& ?1 D public static Selector getSelector(Object obj, String method) {+ z( q+ c3 T1 t! _. n
Selector sel;: d5 ]; Z+ k9 H, I" o
try {
@% o& z& X# K# ?. I& ]- X* G7 Y3 } sel = new Selector(obj.getClass(), method, false);
: D3 a! t# Y' _7 ~4 Q } catch (Exception e) {
! Q, R4 X4 \/ }7 G System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
2 _+ T( k u% n# o# Z7 o3 U- ^ + (obj.getClass()).getName() + ".");4 i; C2 f3 a- h* ~* ~3 M
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
, s' V. {2 {+ P9 \/ ^. i System.err.println("The process will be terminated.");$ `) I8 P1 B; v: v) X- e1 r
System.exit(1);7 s9 E- t9 x" c7 i: o% {' J B
return null;
( f# n+ ~2 h: w( M+ I }+ G" a! m- Z9 W8 X* i/ t- g( F
return sel;8 u" u7 M* y6 ^
}
, P2 M' A( p4 a) r* V} |