import swarm.Selector;
Q" W6 X7 U1 w5 q
1 M9 n( U6 s/ f4 \/ }( [5 n9 K. d2 Z6 zpublic class SwarmUtils {
6 ]" Z) t0 Z5 Q% e- Q public static Selector getSelector(String name, String method) {
# C/ t8 m( K0 P' I: b6 _ Selector sel;& L8 R, ~0 K8 b$ f
try {( j" x* I4 \$ R& v
sel = new Selector(Class.forName(name), method, false);# r1 x% R* b) P
} catch (Exception e) {
5 d+ C& w8 I- e System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 M1 y2 B* _- m* k9 M$ ? System.err.println(name + "." + method + " returns " + e.getMessage());' z9 K/ L: R( ^% F
System.err.println("The process will be terminated.");
; D: i7 |( D% w( z, s5 G System.exit(1);+ \, i" K9 B7 y6 E" W7 @ |
return null;
+ g/ f$ F% n A, F3 | }
( @: t0 j( B+ \& y- w, B return sel;7 o" M* R4 l; R6 w
}
2 ^# m+ c% g& h8 x6 Q y; N
: ?- t5 R) `- v* H" a public static Selector getSelector(Object obj, String method) {
9 F- n" C; E, j% D Selector sel;
8 [3 K/ b' V! K2 e; K try {
0 |. K: D v0 c) e. @1 j sel = new Selector(obj.getClass(), method, false);2 C( h( x; e+ M4 c7 J
} catch (Exception e) {
- H6 h8 u. i2 M# | System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "/ }. g5 c3 F \5 F' T0 Q
+ (obj.getClass()).getName() + ".");- S: ?# V: E8 N4 V. Q8 c/ t/ j
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());, \8 {% N/ Z8 z3 R5 Y G
System.err.println("The process will be terminated.");
' C1 t: d* {2 f2 L System.exit(1);. G: g; n' N7 m( e
return null;
& g+ k4 s7 u8 a }
: d2 o% }( M t7 Q, Z" c+ A3 ? return sel;, A, Q) m. \3 N- J( P4 ]" M
}
6 [& S; ?6 l0 s0 b6 }, n} |