import swarm.Selector;
) b' W/ W$ I8 O/ f J9 F1 P5 I' g9 T* z: y/ ?8 u% G
public class SwarmUtils {
/ C/ Z* |) _. h3 B4 J) N3 Z# `- h public static Selector getSelector(String name, String method) {
3 D$ ~, E" t. o7 q; Q2 y& L: T Selector sel;7 a H+ S; x, N
try {
: k0 a. ?- e6 Z3 t& G b( l sel = new Selector(Class.forName(name), method, false);% T# \% @3 Y, f( F% C2 h# J1 @
} catch (Exception e) {$ y# d; i* T& T
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
& ^" R- |7 g# b7 T1 @ System.err.println(name + "." + method + " returns " + e.getMessage());) X' G: v7 @$ I! l2 b# ?8 Y$ d, t
System.err.println("The process will be terminated.");
& s! N' l! l" I- e System.exit(1);4 m) s O- Y B" N) O
return null;
5 Z6 c* V+ Z' a6 w5 P }
8 D8 N* e% Q5 i8 i3 S Y return sel;
3 P; Y+ k9 `6 g4 c" q8 [ }
% G* M! P" k1 a& h ]* C) [& W B% L" @( Q3 ~, b/ \ k# b
public static Selector getSelector(Object obj, String method) {
3 k# H1 \) t- ?, I9 x/ I1 m; n Selector sel;
0 h G3 P( Q8 | \. u0 H try {* q, G, n! v A1 y
sel = new Selector(obj.getClass(), method, false);
8 g% X! B: R8 c& v } catch (Exception e) {
: F0 x9 S6 U6 ^3 Q System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "4 O1 v2 \' c; }
+ (obj.getClass()).getName() + ".");3 ?1 E# P I1 V0 C- L3 i
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());2 t" }! m0 d" T2 X0 {
System.err.println("The process will be terminated.");
8 t7 i n: N" j' j) K System.exit(1);
G0 e$ N6 p( @0 ] h+ e return null;: C- l( O6 e. v$ ~- N
}
+ b1 u2 s7 z) }. ? return sel;# I5 c1 O# `$ d$ J5 ~& v& \
}
' h# i% q9 l$ h% T! ~} |