import swarm.Selector;' Q4 k7 z. p8 L" J8 j. u/ G
& }4 v; J5 r& Gpublic class SwarmUtils {
6 `1 t: H0 x) F$ k public static Selector getSelector(String name, String method) {
( c7 C6 U! M9 S8 l9 v Selector sel;# X% l$ y3 N. g" T
try {2 `+ h. K0 m8 I
sel = new Selector(Class.forName(name), method, false);1 u. x. x( O- c+ ]( O! I
} catch (Exception e) {2 p3 r1 Y& q4 x0 k8 X/ S9 I- e0 i
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
& a: v. b9 e* J/ A$ | System.err.println(name + "." + method + " returns " + e.getMessage());) n% ]+ N% d* D1 G }+ ]
System.err.println("The process will be terminated.");
) O! @9 @' J F" e' L System.exit(1);0 v: l/ `8 D# J0 ~- j
return null;3 [9 L/ \6 d, f% _1 Z4 {6 G
}
3 g% F3 U% E1 ?; d return sel;/ F1 J# x* k, L, s# I( N# D
}
6 O! ]/ s& D# d/ N
. O) e+ @, U5 |4 ?9 @2 P public static Selector getSelector(Object obj, String method) {4 [: _" B: Y y. W. ? V
Selector sel;* e. [2 U' P& F- w. N% X
try {
% j0 F2 ]# p; t! N6 m* b sel = new Selector(obj.getClass(), method, false);
. o$ s0 X! @1 P) n7 u4 B( ^+ x } catch (Exception e) {; \8 b) E0 f; q, r
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
; J/ y4 b* q/ p6 d7 q( V + (obj.getClass()).getName() + ".");
6 Y/ o: |9 u. z$ Z! A System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
" @4 ?0 S8 @% ~) W* O1 I+ q9 t$ f System.err.println("The process will be terminated.");
8 ]" N" i0 k: B0 I1 ~& b System.exit(1);/ I! ] d" J5 Z u$ _# Y
return null;7 T* |2 f" g* w# k
}
, e5 P& C6 A& ], j return sel;
- q) i Y1 q* {3 j }9 l( Q9 d* R! T& U! A# G. ^
} |