import swarm.Selector;, c+ K0 s& u. _6 M; E9 W
7 R: t6 I5 u/ W" q: {: Spublic class SwarmUtils {
6 x( ?" h+ a1 `; B public static Selector getSelector(String name, String method) {
; d. [1 b8 C- Q; K1 v& h4 S. \+ h! z Selector sel;
3 D; a2 x5 |! ]2 a" x0 m: F try {
7 }0 ^1 F) Q7 x n; X2 P. ]4 t sel = new Selector(Class.forName(name), method, false);6 k9 X- a4 M5 c$ h
} catch (Exception e) {
$ R" w' z1 I8 T) F* D System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");5 a: ]* t- P8 b. U8 w J
System.err.println(name + "." + method + " returns " + e.getMessage());
# Z* m0 @- K/ @ System.err.println("The process will be terminated.");+ {; g! A- u- w1 {! G. c0 z
System.exit(1);
1 Y/ f/ _$ l5 u7 G3 j s return null;6 W! h# U, I; Q/ e/ l4 d
}' H$ f7 N, K- h: j: x. e
return sel;, W2 n9 e+ |; G# B3 D
}
! M. L! l" T/ I% ?1 q( ^; K
) _: z+ v+ w% W& U5 x/ o public static Selector getSelector(Object obj, String method) {* l N. D% q9 \7 `& q
Selector sel;
$ i! ]: `! a( F5 p" b- A9 g try {4 l* x# j4 y! w& j& Y0 H
sel = new Selector(obj.getClass(), method, false);' v! V) M( A% N' t" t, c2 g
} catch (Exception e) {
! H4 k1 p* { ?; }5 Q" i System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
8 g: ^% x- M# W- |2 o# D + (obj.getClass()).getName() + ".");. f/ _0 _( Q3 n1 C
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());# k/ |& b0 p# e2 K
System.err.println("The process will be terminated.");, C9 X' D. u3 g3 m# \! M
System.exit(1);& w. ]* }+ ]- G5 L& r( J. e
return null;4 g$ s, U, A8 {7 L% z
}
" w& K1 }6 x0 P' O6 y return sel;
9 {3 c8 _7 P% H4 _/ p# u }
$ b H, ?* ~ I5 ]} |