import swarm.Selector;$ @& J" S. ]+ v3 \
- E2 m* Y$ M8 J. \6 q, @
public class SwarmUtils {
/ h% Q9 \% r2 {. V" u( P0 n5 B public static Selector getSelector(String name, String method) {
% P& s! Z: l3 W% a Selector sel;
$ L. `6 X; q% E( G+ B4 M try {0 w6 l7 R/ Q8 d
sel = new Selector(Class.forName(name), method, false);
9 ~9 p; H* S4 P* G& O$ k4 x! `5 r } catch (Exception e) {
% }, n/ a( S. c0 t8 B# v3 l0 p- u System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + "."); u+ s; D1 P- J) `4 t/ c
System.err.println(name + "." + method + " returns " + e.getMessage()); g4 U' U; \# B# h! S
System.err.println("The process will be terminated.");
- U" W* u A7 _1 @! P System.exit(1);
; M3 g" x8 x! b6 ? return null;
: |/ e% W6 x4 C6 H4 ~! r7 [- { }
" e* r. u$ q t+ ^ return sel;. E% T, Q4 ]4 Z
}
3 w6 U* Q$ ~8 L! e
* E( w& L9 w( a public static Selector getSelector(Object obj, String method) {+ c3 z5 G* Z* {
Selector sel;6 i8 C5 n3 {" b* X* A) \
try {7 `+ m3 Z8 t, l8 [( I3 l8 V
sel = new Selector(obj.getClass(), method, false);4 |& y" C S* J
} catch (Exception e) {+ e. v, A. R+ ]
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
! |% n; O( F1 w1 }1 R2 K- s% b + (obj.getClass()).getName() + ".");+ Q! S. R# h" ?( e' [ [
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());! v1 h, G5 b L' y8 k
System.err.println("The process will be terminated.");$ |5 }6 n- A+ M$ b% M% b4 F
System.exit(1);
) q! L# s3 ], D6 m: F( H return null;2 [- M$ O8 K& M e% p& K
}7 L3 m5 V$ D4 B, C: {4 k+ ?
return sel;/ y7 t& [; l& P# v$ C
}6 F0 W5 B8 ~: v7 P! N
} |