import swarm.Selector;
3 y s! X3 B/ ?" k# M3 e; c. p+ U$ G# j) @/ O% w$ \# y0 d
public class SwarmUtils {
1 O: Q: o, [) n' c public static Selector getSelector(String name, String method) {
* n% ^# C. R& f9 h Selector sel;! N8 z) G9 w4 D# w1 g( D
try {# S" [ U9 J1 |: M, V" F
sel = new Selector(Class.forName(name), method, false);, w4 v+ T) P- @* `7 N, _
} catch (Exception e) {
1 p7 o, `( d& ~' J/ `" F; G System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");* A; C2 S. h- x3 ], w
System.err.println(name + "." + method + " returns " + e.getMessage());
6 }. b3 v8 B( v2 M* M System.err.println("The process will be terminated.");
+ @( S9 m) @4 c* s! C System.exit(1);1 V L/ z& e4 s8 @6 W1 j- k
return null;
9 f1 T' ]: X2 D- s/ o- z( a1 A+ l) i }
' X1 e1 I; m E' A+ j9 B return sel;
2 q; d$ o) I: N! [) g, K# p# T }
7 H0 e7 D. \6 u1 U
/ i2 B' G. s4 e; f# N public static Selector getSelector(Object obj, String method) {, M6 K7 T" \" W8 t; b6 {. a1 F
Selector sel;2 @( A, e) u y# |
try {8 D8 |4 j- N9 N6 a! C$ z* p) r. m
sel = new Selector(obj.getClass(), method, false);* H W/ c' F4 A( }9 m
} catch (Exception e) {3 g( e) t" {+ o$ E8 }
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "9 l7 r% L. n% B$ q; S# z* d
+ (obj.getClass()).getName() + ".");
0 x1 j* q. N+ N2 }# e System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ t! f1 @/ W; ?/ Q* ^7 C8 ]. X System.err.println("The process will be terminated.");5 |* Z3 a; m, N8 q! n. X
System.exit(1);5 v" N, D9 R5 q
return null;/ M4 g2 J$ a/ v% d9 y( j' g2 `
}; i- f; k$ S, z5 k% D0 x! v
return sel;2 W! l# g' V4 [/ m+ ?0 @
}
6 m2 q) I [3 v7 j% r8 p} |