import swarm.Selector;
0 D m; D5 c1 \' l! G
7 q4 l9 J! L' i. O- Epublic class SwarmUtils {
+ V1 K# r5 o3 ]) I" U6 u* f, h public static Selector getSelector(String name, String method) {, z# [4 c9 a/ R- Z! e: f# ~
Selector sel;
: U9 {: u9 F6 X7 g try {
$ X% x2 l- i! J) L sel = new Selector(Class.forName(name), method, false);/ I1 n2 o$ ~/ r1 n
} catch (Exception e) {
9 l/ ?# o8 n2 l, [- w$ X# U. R System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
9 F F" @1 _/ w( e) S System.err.println(name + "." + method + " returns " + e.getMessage());% E* V' M* u$ j$ d
System.err.println("The process will be terminated.");
2 t, O4 E! e8 d7 C1 |- s9 C1 @ System.exit(1);4 s- k& K1 z# g, f% s) j
return null;& n8 F0 }( ~' R1 L4 P
}
) R4 I |3 ?. a3 P! t9 }5 F return sel;
4 `: A/ }% L# s% z7 q }' u/ l, b5 y# W3 e1 [$ n: I
" L& f) k: n( ]" y- z+ F7 ]/ U( C public static Selector getSelector(Object obj, String method) {
1 P: Z' b7 b* i5 F Selector sel;7 i. p$ i: T+ a/ E. `9 h; J
try {
7 B2 I% H7 }, X' j sel = new Selector(obj.getClass(), method, false);
* ~5 v; `/ ^) J7 [6 |) s) E } catch (Exception e) {' }" {/ W" {/ o% D$ @
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 _1 t( b. T- I F. I
+ (obj.getClass()).getName() + ".");) e1 t( M& S8 I, S& U
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
6 y8 I" p- D: P) b$ h7 l# i: s2 j System.err.println("The process will be terminated."); ]' t1 p, f4 L3 r
System.exit(1);
, J' r# V; r7 ?, i return null;
: C ` |& q3 _. s/ H. K! j }. e( b- [" y6 r: B
return sel;) |) W4 X/ k" z* c
}
7 E, b, A$ i5 @2 q. h& q} |